babylon.d.ts 2.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652
  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. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5233. */
  5234. export class PerformanceMonitor {
  5235. private _enabled;
  5236. private _rollingFrameTime;
  5237. private _lastFrameTimeMs;
  5238. /**
  5239. * constructor
  5240. * @param frameSampleSize The number of samples required to saturate the sliding window
  5241. */
  5242. constructor(frameSampleSize?: number);
  5243. /**
  5244. * Samples current frame
  5245. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5246. */
  5247. sampleFrame(timeMs?: number): void;
  5248. /**
  5249. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5250. */
  5251. readonly averageFrameTime: number;
  5252. /**
  5253. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5254. */
  5255. readonly averageFrameTimeVariance: number;
  5256. /**
  5257. * Returns the frame time of the most recent frame
  5258. */
  5259. readonly instantaneousFrameTime: number;
  5260. /**
  5261. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5262. */
  5263. readonly averageFPS: number;
  5264. /**
  5265. * Returns the average framerate in frames per second using the most recent frame time
  5266. */
  5267. readonly instantaneousFPS: number;
  5268. /**
  5269. * Returns true if enough samples have been taken to completely fill the sliding window
  5270. */
  5271. readonly isSaturated: boolean;
  5272. /**
  5273. * Enables contributions to the sliding window sample set
  5274. */
  5275. enable(): void;
  5276. /**
  5277. * Disables contributions to the sliding window sample set
  5278. * Samples will not be interpolated over the disabled period
  5279. */
  5280. disable(): void;
  5281. /**
  5282. * Returns true if sampling is enabled
  5283. */
  5284. readonly isEnabled: boolean;
  5285. /**
  5286. * Resets performance monitor
  5287. */
  5288. reset(): void;
  5289. }
  5290. /**
  5291. * RollingAverage
  5292. *
  5293. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5294. */
  5295. export class RollingAverage {
  5296. /**
  5297. * Current average
  5298. */
  5299. average: number;
  5300. /**
  5301. * Current variance
  5302. */
  5303. variance: number;
  5304. protected _samples: Array<number>;
  5305. protected _sampleCount: number;
  5306. protected _pos: number;
  5307. protected _m2: number;
  5308. /**
  5309. * constructor
  5310. * @param length The number of samples required to saturate the sliding window
  5311. */
  5312. constructor(length: number);
  5313. /**
  5314. * Adds a sample to the sample set
  5315. * @param v The sample value
  5316. */
  5317. add(v: number): void;
  5318. /**
  5319. * Returns previously added values or null if outside of history or outside the sliding window domain
  5320. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5321. * @return Value previously recorded with add() or null if outside of range
  5322. */
  5323. history(i: number): number;
  5324. /**
  5325. * Returns true if enough samples have been taken to completely fill the sliding window
  5326. * @return true if sample-set saturated
  5327. */
  5328. isSaturated(): boolean;
  5329. /**
  5330. * Resets the rolling average (equivalent to 0 samples taken so far)
  5331. */
  5332. reset(): void;
  5333. /**
  5334. * Wraps a value around the sample range boundaries
  5335. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5336. * @return Wrapped position in sample range
  5337. */
  5338. protected _wrapPosition(i: number): number;
  5339. }
  5340. }
  5341. declare module BABYLON {
  5342. /**
  5343. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5344. * The underlying implementation relies on an associative array to ensure the best performances.
  5345. * The value can be anything including 'null' but except 'undefined'
  5346. */
  5347. export class StringDictionary<T> {
  5348. /**
  5349. * This will clear this dictionary and copy the content from the 'source' one.
  5350. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5351. * @param source the dictionary to take the content from and copy to this dictionary
  5352. */
  5353. copyFrom(source: StringDictionary<T>): void;
  5354. /**
  5355. * Get a value based from its key
  5356. * @param key the given key to get the matching value from
  5357. * @return the value if found, otherwise undefined is returned
  5358. */
  5359. get(key: string): T | undefined;
  5360. /**
  5361. * Get a value from its key or add it if it doesn't exist.
  5362. * This method will ensure you that a given key/data will be present in the dictionary.
  5363. * @param key the given key to get the matching value from
  5364. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5365. * The factory will only be invoked if there's no data for the given key.
  5366. * @return the value corresponding to the key.
  5367. */
  5368. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5369. /**
  5370. * Get a value from its key if present in the dictionary otherwise add it
  5371. * @param key the key to get the value from
  5372. * @param val if there's no such key/value pair in the dictionary add it with this value
  5373. * @return the value corresponding to the key
  5374. */
  5375. getOrAdd(key: string, val: T): T;
  5376. /**
  5377. * Check if there's a given key in the dictionary
  5378. * @param key the key to check for
  5379. * @return true if the key is present, false otherwise
  5380. */
  5381. contains(key: string): boolean;
  5382. /**
  5383. * Add a new key and its corresponding value
  5384. * @param key the key to add
  5385. * @param value the value corresponding to the key
  5386. * @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
  5387. */
  5388. add(key: string, value: T): boolean;
  5389. /**
  5390. * Update a specific value associated to a key
  5391. * @param key defines the key to use
  5392. * @param value defines the value to store
  5393. * @returns true if the value was updated (or false if the key was not found)
  5394. */
  5395. set(key: string, value: T): boolean;
  5396. /**
  5397. * Get the element of the given key and remove it from the dictionary
  5398. * @param key defines the key to search
  5399. * @returns the value associated with the key or null if not found
  5400. */
  5401. getAndRemove(key: string): Nullable<T>;
  5402. /**
  5403. * Remove a key/value from the dictionary.
  5404. * @param key the key to remove
  5405. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5406. */
  5407. remove(key: string): boolean;
  5408. /**
  5409. * Clear the whole content of the dictionary
  5410. */
  5411. clear(): void;
  5412. /**
  5413. * Gets the current count
  5414. */
  5415. readonly count: number;
  5416. /**
  5417. * Execute a callback on each key/val of the dictionary.
  5418. * Note that you can remove any element in this dictionary in the callback implementation
  5419. * @param callback the callback to execute on a given key/value pair
  5420. */
  5421. forEach(callback: (key: string, val: T) => void): void;
  5422. /**
  5423. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5424. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5425. * Note that you can remove any element in this dictionary in the callback implementation
  5426. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5427. * @returns the first item
  5428. */
  5429. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5430. private _count;
  5431. private _data;
  5432. }
  5433. }
  5434. declare module BABYLON {
  5435. /**
  5436. * Helper class that provides a small promise polyfill
  5437. */
  5438. export class PromisePolyfill {
  5439. /**
  5440. * Static function used to check if the polyfill is required
  5441. * If this is the case then the function will inject the polyfill to window.Promise
  5442. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5443. */
  5444. static Apply(force?: boolean): void;
  5445. }
  5446. }
  5447. declare module BABYLON {
  5448. /**
  5449. * Class used to store data that will be store in GPU memory
  5450. */
  5451. export class Buffer {
  5452. private _engine;
  5453. private _buffer;
  5454. /** @hidden */
  5455. _data: Nullable<DataArray>;
  5456. private _updatable;
  5457. private _instanced;
  5458. /**
  5459. * Gets the byte stride.
  5460. */
  5461. readonly byteStride: number;
  5462. /**
  5463. * Constructor
  5464. * @param engine the engine
  5465. * @param data the data to use for this buffer
  5466. * @param updatable whether the data is updatable
  5467. * @param stride the stride (optional)
  5468. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5469. * @param instanced whether the buffer is instanced (optional)
  5470. * @param useBytes set to true if the stride in in bytes (optional)
  5471. */
  5472. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5473. /**
  5474. * Create a new VertexBuffer based on the current buffer
  5475. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5476. * @param offset defines offset in the buffer (0 by default)
  5477. * @param size defines the size in floats of attributes (position is 3 for instance)
  5478. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5479. * @param instanced defines if the vertex buffer contains indexed data
  5480. * @param useBytes defines if the offset and stride are in bytes
  5481. * @returns the new vertex buffer
  5482. */
  5483. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5484. /**
  5485. * Gets a boolean indicating if the Buffer is updatable?
  5486. * @returns true if the buffer is updatable
  5487. */
  5488. isUpdatable(): boolean;
  5489. /**
  5490. * Gets current buffer's data
  5491. * @returns a DataArray or null
  5492. */
  5493. getData(): Nullable<DataArray>;
  5494. /**
  5495. * Gets underlying native buffer
  5496. * @returns underlying native buffer
  5497. */
  5498. getBuffer(): Nullable<WebGLBuffer>;
  5499. /**
  5500. * Gets the stride in float32 units (i.e. byte stride / 4).
  5501. * May not be an integer if the byte stride is not divisible by 4.
  5502. * DEPRECATED. Use byteStride instead.
  5503. * @returns the stride in float32 units
  5504. */
  5505. getStrideSize(): number;
  5506. /**
  5507. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5508. * @param data defines the data to store
  5509. */
  5510. create(data?: Nullable<DataArray>): void;
  5511. /** @hidden */
  5512. _rebuild(): void;
  5513. /**
  5514. * Update current buffer data
  5515. * @param data defines the data to store
  5516. */
  5517. update(data: DataArray): void;
  5518. /**
  5519. * Updates the data directly.
  5520. * @param data the new data
  5521. * @param offset the new offset
  5522. * @param vertexCount the vertex count (optional)
  5523. * @param useBytes set to true if the offset is in bytes
  5524. */
  5525. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5526. /**
  5527. * Release all resources
  5528. */
  5529. dispose(): void;
  5530. }
  5531. /**
  5532. * Specialized buffer used to store vertex data
  5533. */
  5534. export class VertexBuffer {
  5535. /** @hidden */
  5536. _buffer: Buffer;
  5537. private _kind;
  5538. private _size;
  5539. private _ownsBuffer;
  5540. private _instanced;
  5541. private _instanceDivisor;
  5542. /**
  5543. * The byte type.
  5544. */
  5545. static readonly BYTE: number;
  5546. /**
  5547. * The unsigned byte type.
  5548. */
  5549. static readonly UNSIGNED_BYTE: number;
  5550. /**
  5551. * The short type.
  5552. */
  5553. static readonly SHORT: number;
  5554. /**
  5555. * The unsigned short type.
  5556. */
  5557. static readonly UNSIGNED_SHORT: number;
  5558. /**
  5559. * The integer type.
  5560. */
  5561. static readonly INT: number;
  5562. /**
  5563. * The unsigned integer type.
  5564. */
  5565. static readonly UNSIGNED_INT: number;
  5566. /**
  5567. * The float type.
  5568. */
  5569. static readonly FLOAT: number;
  5570. /**
  5571. * Gets or sets the instance divisor when in instanced mode
  5572. */
  5573. instanceDivisor: number;
  5574. /**
  5575. * Gets the byte stride.
  5576. */
  5577. readonly byteStride: number;
  5578. /**
  5579. * Gets the byte offset.
  5580. */
  5581. readonly byteOffset: number;
  5582. /**
  5583. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5584. */
  5585. readonly normalized: boolean;
  5586. /**
  5587. * Gets the data type of each component in the array.
  5588. */
  5589. readonly type: number;
  5590. /**
  5591. * Constructor
  5592. * @param engine the engine
  5593. * @param data the data to use for this vertex buffer
  5594. * @param kind the vertex buffer kind
  5595. * @param updatable whether the data is updatable
  5596. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5597. * @param stride the stride (optional)
  5598. * @param instanced whether the buffer is instanced (optional)
  5599. * @param offset the offset of the data (optional)
  5600. * @param size the number of components (optional)
  5601. * @param type the type of the component (optional)
  5602. * @param normalized whether the data contains normalized data (optional)
  5603. * @param useBytes set to true if stride and offset are in bytes (optional)
  5604. */
  5605. 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);
  5606. /** @hidden */
  5607. _rebuild(): void;
  5608. /**
  5609. * Returns the kind of the VertexBuffer (string)
  5610. * @returns a string
  5611. */
  5612. getKind(): string;
  5613. /**
  5614. * Gets a boolean indicating if the VertexBuffer is updatable?
  5615. * @returns true if the buffer is updatable
  5616. */
  5617. isUpdatable(): boolean;
  5618. /**
  5619. * Gets current buffer's data
  5620. * @returns a DataArray or null
  5621. */
  5622. getData(): Nullable<DataArray>;
  5623. /**
  5624. * Gets underlying native buffer
  5625. * @returns underlying native buffer
  5626. */
  5627. getBuffer(): Nullable<WebGLBuffer>;
  5628. /**
  5629. * Gets the stride in float32 units (i.e. byte stride / 4).
  5630. * May not be an integer if the byte stride is not divisible by 4.
  5631. * DEPRECATED. Use byteStride instead.
  5632. * @returns the stride in float32 units
  5633. */
  5634. getStrideSize(): number;
  5635. /**
  5636. * Returns the offset as a multiple of the type byte length.
  5637. * DEPRECATED. Use byteOffset instead.
  5638. * @returns the offset in bytes
  5639. */
  5640. getOffset(): number;
  5641. /**
  5642. * Returns the number of components per vertex attribute (integer)
  5643. * @returns the size in float
  5644. */
  5645. getSize(): number;
  5646. /**
  5647. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5648. * @returns true if this buffer is instanced
  5649. */
  5650. getIsInstanced(): boolean;
  5651. /**
  5652. * Returns the instancing divisor, zero for non-instanced (integer).
  5653. * @returns a number
  5654. */
  5655. getInstanceDivisor(): number;
  5656. /**
  5657. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5658. * @param data defines the data to store
  5659. */
  5660. create(data?: DataArray): void;
  5661. /**
  5662. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5663. * This function will create a new buffer if the current one is not updatable
  5664. * @param data defines the data to store
  5665. */
  5666. update(data: DataArray): void;
  5667. /**
  5668. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5669. * Returns the directly updated WebGLBuffer.
  5670. * @param data the new data
  5671. * @param offset the new offset
  5672. * @param useBytes set to true if the offset is in bytes
  5673. */
  5674. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5675. /**
  5676. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5677. */
  5678. dispose(): void;
  5679. /**
  5680. * Enumerates each value of this vertex buffer as numbers.
  5681. * @param count the number of values to enumerate
  5682. * @param callback the callback function called for each value
  5683. */
  5684. forEach(count: number, callback: (value: number, index: number) => void): void;
  5685. /**
  5686. * Positions
  5687. */
  5688. static readonly PositionKind: string;
  5689. /**
  5690. * Normals
  5691. */
  5692. static readonly NormalKind: string;
  5693. /**
  5694. * Tangents
  5695. */
  5696. static readonly TangentKind: string;
  5697. /**
  5698. * Texture coordinates
  5699. */
  5700. static readonly UVKind: string;
  5701. /**
  5702. * Texture coordinates 2
  5703. */
  5704. static readonly UV2Kind: string;
  5705. /**
  5706. * Texture coordinates 3
  5707. */
  5708. static readonly UV3Kind: string;
  5709. /**
  5710. * Texture coordinates 4
  5711. */
  5712. static readonly UV4Kind: string;
  5713. /**
  5714. * Texture coordinates 5
  5715. */
  5716. static readonly UV5Kind: string;
  5717. /**
  5718. * Texture coordinates 6
  5719. */
  5720. static readonly UV6Kind: string;
  5721. /**
  5722. * Colors
  5723. */
  5724. static readonly ColorKind: string;
  5725. /**
  5726. * Matrix indices (for bones)
  5727. */
  5728. static readonly MatricesIndicesKind: string;
  5729. /**
  5730. * Matrix weights (for bones)
  5731. */
  5732. static readonly MatricesWeightsKind: string;
  5733. /**
  5734. * Additional matrix indices (for bones)
  5735. */
  5736. static readonly MatricesIndicesExtraKind: string;
  5737. /**
  5738. * Additional matrix weights (for bones)
  5739. */
  5740. static readonly MatricesWeightsExtraKind: string;
  5741. /**
  5742. * Deduces the stride given a kind.
  5743. * @param kind The kind string to deduce
  5744. * @returns The deduced stride
  5745. */
  5746. static DeduceStride(kind: string): number;
  5747. /**
  5748. * Gets the byte length of the given type.
  5749. * @param type the type
  5750. * @returns the number of bytes
  5751. */
  5752. static GetTypeByteLength(type: number): number;
  5753. /**
  5754. * Enumerates each value of the given parameters as numbers.
  5755. * @param data the data to enumerate
  5756. * @param byteOffset the byte offset of the data
  5757. * @param byteStride the byte stride of the data
  5758. * @param componentCount the number of components per element
  5759. * @param componentType the type of the component
  5760. * @param count the total number of components
  5761. * @param normalized whether the data is normalized
  5762. * @param callback the callback function called for each value
  5763. */
  5764. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5765. private static _GetFloatValue;
  5766. }
  5767. }
  5768. declare module BABYLON {
  5769. /**
  5770. * Class representing spherical polynomial coefficients to the 3rd degree
  5771. */
  5772. export class SphericalPolynomial {
  5773. /**
  5774. * The x coefficients of the spherical polynomial
  5775. */
  5776. x: Vector3;
  5777. /**
  5778. * The y coefficients of the spherical polynomial
  5779. */
  5780. y: Vector3;
  5781. /**
  5782. * The z coefficients of the spherical polynomial
  5783. */
  5784. z: Vector3;
  5785. /**
  5786. * The xx coefficients of the spherical polynomial
  5787. */
  5788. xx: Vector3;
  5789. /**
  5790. * The yy coefficients of the spherical polynomial
  5791. */
  5792. yy: Vector3;
  5793. /**
  5794. * The zz coefficients of the spherical polynomial
  5795. */
  5796. zz: Vector3;
  5797. /**
  5798. * The xy coefficients of the spherical polynomial
  5799. */
  5800. xy: Vector3;
  5801. /**
  5802. * The yz coefficients of the spherical polynomial
  5803. */
  5804. yz: Vector3;
  5805. /**
  5806. * The zx coefficients of the spherical polynomial
  5807. */
  5808. zx: Vector3;
  5809. /**
  5810. * Adds an ambient color to the spherical polynomial
  5811. * @param color the color to add
  5812. */
  5813. addAmbient(color: Color3): void;
  5814. /**
  5815. * Scales the spherical polynomial by the given amount
  5816. * @param scale the amount to scale
  5817. */
  5818. scale(scale: number): void;
  5819. /**
  5820. * Gets the spherical polynomial from harmonics
  5821. * @param harmonics the spherical harmonics
  5822. * @returns the spherical polynomial
  5823. */
  5824. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5825. /**
  5826. * Constructs a spherical polynomial from an array.
  5827. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5831. }
  5832. /**
  5833. * Class representing spherical harmonics coefficients to the 3rd degree
  5834. */
  5835. export class SphericalHarmonics {
  5836. /**
  5837. * The l0,0 coefficients of the spherical harmonics
  5838. */
  5839. l00: Vector3;
  5840. /**
  5841. * The l1,-1 coefficients of the spherical harmonics
  5842. */
  5843. l1_1: Vector3;
  5844. /**
  5845. * The l1,0 coefficients of the spherical harmonics
  5846. */
  5847. l10: Vector3;
  5848. /**
  5849. * The l1,1 coefficients of the spherical harmonics
  5850. */
  5851. l11: Vector3;
  5852. /**
  5853. * The l2,-2 coefficients of the spherical harmonics
  5854. */
  5855. l2_2: Vector3;
  5856. /**
  5857. * The l2,-1 coefficients of the spherical harmonics
  5858. */
  5859. l2_1: Vector3;
  5860. /**
  5861. * The l2,0 coefficients of the spherical harmonics
  5862. */
  5863. l20: Vector3;
  5864. /**
  5865. * The l2,1 coefficients of the spherical harmonics
  5866. */
  5867. l21: Vector3;
  5868. /**
  5869. * The l2,2 coefficients of the spherical harmonics
  5870. */
  5871. lL22: Vector3;
  5872. /**
  5873. * Adds a light to the spherical harmonics
  5874. * @param direction the direction of the light
  5875. * @param color the color of the light
  5876. * @param deltaSolidAngle the delta solid angle of the light
  5877. */
  5878. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5879. /**
  5880. * Scales the spherical harmonics by the given amount
  5881. * @param scale the amount to scale
  5882. */
  5883. scale(scale: number): void;
  5884. /**
  5885. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5886. *
  5887. * ```
  5888. * E_lm = A_l * L_lm
  5889. * ```
  5890. *
  5891. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5892. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5893. * the scaling factors are given in equation 9.
  5894. */
  5895. convertIncidentRadianceToIrradiance(): void;
  5896. /**
  5897. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5898. *
  5899. * ```
  5900. * L = (1/pi) * E * rho
  5901. * ```
  5902. *
  5903. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5904. */
  5905. convertIrradianceToLambertianRadiance(): void;
  5906. /**
  5907. * Gets the spherical harmonics from polynomial
  5908. * @param polynomial the spherical polynomial
  5909. * @returns the spherical harmonics
  5910. */
  5911. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5912. /**
  5913. * Constructs a spherical harmonics from an array.
  5914. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5918. }
  5919. }
  5920. declare module BABYLON {
  5921. /**
  5922. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5923. */
  5924. export interface CubeMapInfo {
  5925. /**
  5926. * The pixel array for the front face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. front: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the back face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. back: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the left face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. left: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the right face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. right: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The pixel array for the up face.
  5947. * This is stored in format, left to right, up to down format.
  5948. */
  5949. up: Nullable<ArrayBufferView>;
  5950. /**
  5951. * The pixel array for the down face.
  5952. * This is stored in format, left to right, up to down format.
  5953. */
  5954. down: Nullable<ArrayBufferView>;
  5955. /**
  5956. * The size of the cubemap stored.
  5957. *
  5958. * Each faces will be size * size pixels.
  5959. */
  5960. size: number;
  5961. /**
  5962. * The format of the texture.
  5963. *
  5964. * RGBA, RGB.
  5965. */
  5966. format: number;
  5967. /**
  5968. * The type of the texture data.
  5969. *
  5970. * UNSIGNED_INT, FLOAT.
  5971. */
  5972. type: number;
  5973. /**
  5974. * Specifies whether the texture is in gamma space.
  5975. */
  5976. gammaSpace: boolean;
  5977. }
  5978. /**
  5979. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5980. */
  5981. export class PanoramaToCubeMapTools {
  5982. private static FACE_FRONT;
  5983. private static FACE_BACK;
  5984. private static FACE_RIGHT;
  5985. private static FACE_LEFT;
  5986. private static FACE_DOWN;
  5987. private static FACE_UP;
  5988. /**
  5989. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5990. *
  5991. * @param float32Array The source data.
  5992. * @param inputWidth The width of the input panorama.
  5993. * @param inputHeight The height of the input panorama.
  5994. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5995. * @return The cubemap data
  5996. */
  5997. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5998. private static CreateCubemapTexture;
  5999. private static CalcProjectionSpherical;
  6000. }
  6001. }
  6002. declare module BABYLON {
  6003. /**
  6004. * Helper class dealing with the extraction of spherical polynomial dataArray
  6005. * from a cube map.
  6006. */
  6007. export class CubeMapToSphericalPolynomialTools {
  6008. private static FileFaces;
  6009. /**
  6010. * Converts a texture to the according Spherical Polynomial data.
  6011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6012. *
  6013. * @param texture The texture to extract the information from.
  6014. * @return The Spherical Polynomial data.
  6015. */
  6016. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6017. /**
  6018. * Converts a cubemap to the according Spherical Polynomial data.
  6019. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6020. *
  6021. * @param cubeInfo The Cube map to extract the information from.
  6022. * @return The Spherical Polynomial data.
  6023. */
  6024. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6025. }
  6026. }
  6027. declare module BABYLON {
  6028. /**
  6029. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6030. * during the life time of the application.
  6031. */
  6032. export class EngineStore {
  6033. /** Gets the list of created engines */
  6034. static Instances: Engine[];
  6035. /**
  6036. * Gets the latest created engine
  6037. */
  6038. static readonly LastCreatedEngine: Nullable<Engine>;
  6039. /**
  6040. * Gets the latest created scene
  6041. */
  6042. static readonly LastCreatedScene: Nullable<Scene>;
  6043. }
  6044. }
  6045. declare module BABYLON {
  6046. /**
  6047. * Define options used to create a render target texture
  6048. */
  6049. export class RenderTargetCreationOptions {
  6050. /**
  6051. * Specifies is mipmaps must be generated
  6052. */
  6053. generateMipMaps?: boolean;
  6054. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6055. generateDepthBuffer?: boolean;
  6056. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6057. generateStencilBuffer?: boolean;
  6058. /** Defines texture type (int by default) */
  6059. type?: number;
  6060. /** Defines sampling mode (trilinear by default) */
  6061. samplingMode?: number;
  6062. /** Defines format (RGBA by default) */
  6063. format?: number;
  6064. }
  6065. }
  6066. declare module BABYLON {
  6067. /**
  6068. * @hidden
  6069. **/
  6070. export class _AlphaState {
  6071. private _isAlphaBlendDirty;
  6072. private _isBlendFunctionParametersDirty;
  6073. private _isBlendEquationParametersDirty;
  6074. private _isBlendConstantsDirty;
  6075. private _alphaBlend;
  6076. private _blendFunctionParameters;
  6077. private _blendEquationParameters;
  6078. private _blendConstants;
  6079. /**
  6080. * Initializes the state.
  6081. */
  6082. constructor();
  6083. readonly isDirty: boolean;
  6084. alphaBlend: boolean;
  6085. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6086. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6087. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6088. reset(): void;
  6089. apply(gl: WebGLRenderingContext): void;
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * @hidden
  6095. **/
  6096. export class _DepthCullingState {
  6097. private _isDepthTestDirty;
  6098. private _isDepthMaskDirty;
  6099. private _isDepthFuncDirty;
  6100. private _isCullFaceDirty;
  6101. private _isCullDirty;
  6102. private _isZOffsetDirty;
  6103. private _isFrontFaceDirty;
  6104. private _depthTest;
  6105. private _depthMask;
  6106. private _depthFunc;
  6107. private _cull;
  6108. private _cullFace;
  6109. private _zOffset;
  6110. private _frontFace;
  6111. /**
  6112. * Initializes the state.
  6113. */
  6114. constructor();
  6115. readonly isDirty: boolean;
  6116. zOffset: number;
  6117. cullFace: Nullable<number>;
  6118. cull: Nullable<boolean>;
  6119. depthFunc: Nullable<number>;
  6120. depthMask: boolean;
  6121. depthTest: boolean;
  6122. frontFace: Nullable<number>;
  6123. reset(): void;
  6124. apply(gl: WebGLRenderingContext): void;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * @hidden
  6130. **/
  6131. export class _StencilState {
  6132. /** 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 */
  6133. static readonly ALWAYS: number;
  6134. /** Passed to stencilOperation to specify that stencil value must be kept */
  6135. static readonly KEEP: number;
  6136. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6137. static readonly REPLACE: number;
  6138. private _isStencilTestDirty;
  6139. private _isStencilMaskDirty;
  6140. private _isStencilFuncDirty;
  6141. private _isStencilOpDirty;
  6142. private _stencilTest;
  6143. private _stencilMask;
  6144. private _stencilFunc;
  6145. private _stencilFuncRef;
  6146. private _stencilFuncMask;
  6147. private _stencilOpStencilFail;
  6148. private _stencilOpDepthFail;
  6149. private _stencilOpStencilDepthPass;
  6150. readonly isDirty: boolean;
  6151. stencilFunc: number;
  6152. stencilFuncRef: number;
  6153. stencilFuncMask: number;
  6154. stencilOpStencilFail: number;
  6155. stencilOpDepthFail: number;
  6156. stencilOpStencilDepthPass: number;
  6157. stencilMask: number;
  6158. stencilTest: boolean;
  6159. constructor();
  6160. reset(): void;
  6161. apply(gl: WebGLRenderingContext): void;
  6162. }
  6163. }
  6164. declare module BABYLON {
  6165. /**
  6166. * @hidden
  6167. **/
  6168. export class _TimeToken {
  6169. _startTimeQuery: Nullable<WebGLQuery>;
  6170. _endTimeQuery: Nullable<WebGLQuery>;
  6171. _timeElapsedQuery: Nullable<WebGLQuery>;
  6172. _timeElapsedQueryEnded: boolean;
  6173. }
  6174. }
  6175. declare module BABYLON {
  6176. /**
  6177. * Class used to store data associated with WebGL texture data for the engine
  6178. * This class should not be used directly
  6179. */
  6180. export class InternalTexture {
  6181. /** hidden */
  6182. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6183. /**
  6184. * The source of the texture data is unknown
  6185. */
  6186. static DATASOURCE_UNKNOWN: number;
  6187. /**
  6188. * Texture data comes from an URL
  6189. */
  6190. static DATASOURCE_URL: number;
  6191. /**
  6192. * Texture data is only used for temporary storage
  6193. */
  6194. static DATASOURCE_TEMP: number;
  6195. /**
  6196. * Texture data comes from raw data (ArrayBuffer)
  6197. */
  6198. static DATASOURCE_RAW: number;
  6199. /**
  6200. * Texture content is dynamic (video or dynamic texture)
  6201. */
  6202. static DATASOURCE_DYNAMIC: number;
  6203. /**
  6204. * Texture content is generated by rendering to it
  6205. */
  6206. static DATASOURCE_RENDERTARGET: number;
  6207. /**
  6208. * Texture content is part of a multi render target process
  6209. */
  6210. static DATASOURCE_MULTIRENDERTARGET: number;
  6211. /**
  6212. * Texture data comes from a cube data file
  6213. */
  6214. static DATASOURCE_CUBE: number;
  6215. /**
  6216. * Texture data comes from a raw cube data
  6217. */
  6218. static DATASOURCE_CUBERAW: number;
  6219. /**
  6220. * Texture data come from a prefiltered cube data file
  6221. */
  6222. static DATASOURCE_CUBEPREFILTERED: number;
  6223. /**
  6224. * Texture content is raw 3D data
  6225. */
  6226. static DATASOURCE_RAW3D: number;
  6227. /**
  6228. * Texture content is a depth texture
  6229. */
  6230. static DATASOURCE_DEPTHTEXTURE: number;
  6231. /**
  6232. * Texture data comes from a raw cube data encoded with RGBD
  6233. */
  6234. static DATASOURCE_CUBERAW_RGBD: number;
  6235. /**
  6236. * Defines if the texture is ready
  6237. */
  6238. isReady: boolean;
  6239. /**
  6240. * Defines if the texture is a cube texture
  6241. */
  6242. isCube: boolean;
  6243. /**
  6244. * Defines if the texture contains 3D data
  6245. */
  6246. is3D: boolean;
  6247. /**
  6248. * Defines if the texture contains multiview data
  6249. */
  6250. isMultiview: boolean;
  6251. /**
  6252. * Gets the URL used to load this texture
  6253. */
  6254. url: string;
  6255. /**
  6256. * Gets the sampling mode of the texture
  6257. */
  6258. samplingMode: number;
  6259. /**
  6260. * Gets a boolean indicating if the texture needs mipmaps generation
  6261. */
  6262. generateMipMaps: boolean;
  6263. /**
  6264. * Gets the number of samples used by the texture (WebGL2+ only)
  6265. */
  6266. samples: number;
  6267. /**
  6268. * Gets the type of the texture (int, float...)
  6269. */
  6270. type: number;
  6271. /**
  6272. * Gets the format of the texture (RGB, RGBA...)
  6273. */
  6274. format: number;
  6275. /**
  6276. * Observable called when the texture is loaded
  6277. */
  6278. onLoadedObservable: Observable<InternalTexture>;
  6279. /**
  6280. * Gets the width of the texture
  6281. */
  6282. width: number;
  6283. /**
  6284. * Gets the height of the texture
  6285. */
  6286. height: number;
  6287. /**
  6288. * Gets the depth of the texture
  6289. */
  6290. depth: number;
  6291. /**
  6292. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6293. */
  6294. baseWidth: number;
  6295. /**
  6296. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6297. */
  6298. baseHeight: number;
  6299. /**
  6300. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6301. */
  6302. baseDepth: number;
  6303. /**
  6304. * Gets a boolean indicating if the texture is inverted on Y axis
  6305. */
  6306. invertY: boolean;
  6307. /** @hidden */
  6308. _invertVScale: boolean;
  6309. /** @hidden */
  6310. _associatedChannel: number;
  6311. /** @hidden */
  6312. _dataSource: number;
  6313. /** @hidden */
  6314. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6315. /** @hidden */
  6316. _bufferView: Nullable<ArrayBufferView>;
  6317. /** @hidden */
  6318. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6319. /** @hidden */
  6320. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6321. /** @hidden */
  6322. _size: number;
  6323. /** @hidden */
  6324. _extension: string;
  6325. /** @hidden */
  6326. _files: Nullable<string[]>;
  6327. /** @hidden */
  6328. _workingCanvas: Nullable<HTMLCanvasElement>;
  6329. /** @hidden */
  6330. _workingContext: Nullable<CanvasRenderingContext2D>;
  6331. /** @hidden */
  6332. _framebuffer: Nullable<WebGLFramebuffer>;
  6333. /** @hidden */
  6334. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6335. /** @hidden */
  6336. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6337. /** @hidden */
  6338. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6339. /** @hidden */
  6340. _attachments: Nullable<number[]>;
  6341. /** @hidden */
  6342. _cachedCoordinatesMode: Nullable<number>;
  6343. /** @hidden */
  6344. _cachedWrapU: Nullable<number>;
  6345. /** @hidden */
  6346. _cachedWrapV: Nullable<number>;
  6347. /** @hidden */
  6348. _cachedWrapR: Nullable<number>;
  6349. /** @hidden */
  6350. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6351. /** @hidden */
  6352. _isDisabled: boolean;
  6353. /** @hidden */
  6354. _compression: Nullable<string>;
  6355. /** @hidden */
  6356. _generateStencilBuffer: boolean;
  6357. /** @hidden */
  6358. _generateDepthBuffer: boolean;
  6359. /** @hidden */
  6360. _comparisonFunction: number;
  6361. /** @hidden */
  6362. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6363. /** @hidden */
  6364. _lodGenerationScale: number;
  6365. /** @hidden */
  6366. _lodGenerationOffset: number;
  6367. /** @hidden */
  6368. _colorTextureArray: Nullable<WebGLTexture>;
  6369. /** @hidden */
  6370. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6371. /** @hidden */
  6372. _lodTextureHigh: Nullable<BaseTexture>;
  6373. /** @hidden */
  6374. _lodTextureMid: Nullable<BaseTexture>;
  6375. /** @hidden */
  6376. _lodTextureLow: Nullable<BaseTexture>;
  6377. /** @hidden */
  6378. _isRGBD: boolean;
  6379. /** @hidden */
  6380. _webGLTexture: Nullable<WebGLTexture>;
  6381. /** @hidden */
  6382. _references: number;
  6383. private _engine;
  6384. /**
  6385. * Gets the Engine the texture belongs to.
  6386. * @returns The babylon engine
  6387. */
  6388. getEngine(): Engine;
  6389. /**
  6390. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6391. */
  6392. readonly dataSource: number;
  6393. /**
  6394. * Creates a new InternalTexture
  6395. * @param engine defines the engine to use
  6396. * @param dataSource defines the type of data that will be used
  6397. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6398. */
  6399. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6400. /**
  6401. * Increments the number of references (ie. the number of Texture that point to it)
  6402. */
  6403. incrementReferences(): void;
  6404. /**
  6405. * Change the size of the texture (not the size of the content)
  6406. * @param width defines the new width
  6407. * @param height defines the new height
  6408. * @param depth defines the new depth (1 by default)
  6409. */
  6410. updateSize(width: int, height: int, depth?: int): void;
  6411. /** @hidden */
  6412. _rebuild(): void;
  6413. /** @hidden */
  6414. _swapAndDie(target: InternalTexture): void;
  6415. /**
  6416. * Dispose the current allocated resources
  6417. */
  6418. dispose(): void;
  6419. }
  6420. }
  6421. declare module BABYLON {
  6422. /**
  6423. * This represents the main contract an easing function should follow.
  6424. * Easing functions are used throughout the animation system.
  6425. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6426. */
  6427. export interface IEasingFunction {
  6428. /**
  6429. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6430. * of the easing function.
  6431. * The link below provides some of the most common examples of easing functions.
  6432. * @see https://easings.net/
  6433. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6434. * @returns the corresponding value on the curve defined by the easing function
  6435. */
  6436. ease(gradient: number): number;
  6437. }
  6438. /**
  6439. * Base class used for every default easing function.
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class EasingFunction implements IEasingFunction {
  6443. /**
  6444. * Interpolation follows the mathematical formula associated with the easing function.
  6445. */
  6446. static readonly EASINGMODE_EASEIN: number;
  6447. /**
  6448. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6449. */
  6450. static readonly EASINGMODE_EASEOUT: number;
  6451. /**
  6452. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6453. */
  6454. static readonly EASINGMODE_EASEINOUT: number;
  6455. private _easingMode;
  6456. /**
  6457. * Sets the easing mode of the current function.
  6458. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6459. */
  6460. setEasingMode(easingMode: number): void;
  6461. /**
  6462. * Gets the current easing mode.
  6463. * @returns the easing mode
  6464. */
  6465. getEasingMode(): number;
  6466. /**
  6467. * @hidden
  6468. */
  6469. easeInCore(gradient: number): number;
  6470. /**
  6471. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6472. * of the easing function.
  6473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6474. * @returns the corresponding value on the curve defined by the easing function
  6475. */
  6476. ease(gradient: number): number;
  6477. }
  6478. /**
  6479. * Easing function with a circle shape (see link below).
  6480. * @see https://easings.net/#easeInCirc
  6481. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6482. */
  6483. export class CircleEase extends EasingFunction implements IEasingFunction {
  6484. /** @hidden */
  6485. easeInCore(gradient: number): number;
  6486. }
  6487. /**
  6488. * Easing function with a ease back shape (see link below).
  6489. * @see https://easings.net/#easeInBack
  6490. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6491. */
  6492. export class BackEase extends EasingFunction implements IEasingFunction {
  6493. /** Defines the amplitude of the function */
  6494. amplitude: number;
  6495. /**
  6496. * Instantiates a back ease easing
  6497. * @see https://easings.net/#easeInBack
  6498. * @param amplitude Defines the amplitude of the function
  6499. */
  6500. constructor(
  6501. /** Defines the amplitude of the function */
  6502. amplitude?: number);
  6503. /** @hidden */
  6504. easeInCore(gradient: number): number;
  6505. }
  6506. /**
  6507. * Easing function with a bouncing shape (see link below).
  6508. * @see https://easings.net/#easeInBounce
  6509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6510. */
  6511. export class BounceEase extends EasingFunction implements IEasingFunction {
  6512. /** Defines the number of bounces */
  6513. bounces: number;
  6514. /** Defines the amplitude of the bounce */
  6515. bounciness: number;
  6516. /**
  6517. * Instantiates a bounce easing
  6518. * @see https://easings.net/#easeInBounce
  6519. * @param bounces Defines the number of bounces
  6520. * @param bounciness Defines the amplitude of the bounce
  6521. */
  6522. constructor(
  6523. /** Defines the number of bounces */
  6524. bounces?: number,
  6525. /** Defines the amplitude of the bounce */
  6526. bounciness?: number);
  6527. /** @hidden */
  6528. easeInCore(gradient: number): number;
  6529. }
  6530. /**
  6531. * Easing function with a power of 3 shape (see link below).
  6532. * @see https://easings.net/#easeInCubic
  6533. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6534. */
  6535. export class CubicEase extends EasingFunction implements IEasingFunction {
  6536. /** @hidden */
  6537. easeInCore(gradient: number): number;
  6538. }
  6539. /**
  6540. * Easing function with an elastic shape (see link below).
  6541. * @see https://easings.net/#easeInElastic
  6542. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6543. */
  6544. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6545. /** Defines the number of oscillations*/
  6546. oscillations: number;
  6547. /** Defines the amplitude of the oscillations*/
  6548. springiness: number;
  6549. /**
  6550. * Instantiates an elastic easing function
  6551. * @see https://easings.net/#easeInElastic
  6552. * @param oscillations Defines the number of oscillations
  6553. * @param springiness Defines the amplitude of the oscillations
  6554. */
  6555. constructor(
  6556. /** Defines the number of oscillations*/
  6557. oscillations?: number,
  6558. /** Defines the amplitude of the oscillations*/
  6559. springiness?: number);
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with an exponential shape (see link below).
  6565. * @see https://easings.net/#easeInExpo
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the exponent of the function */
  6570. exponent: number;
  6571. /**
  6572. * Instantiates an exponential easing function
  6573. * @see https://easings.net/#easeInExpo
  6574. * @param exponent Defines the exponent of the function
  6575. */
  6576. constructor(
  6577. /** Defines the exponent of the function */
  6578. exponent?: number);
  6579. /** @hidden */
  6580. easeInCore(gradient: number): number;
  6581. }
  6582. /**
  6583. * Easing function with a power shape (see link below).
  6584. * @see https://easings.net/#easeInQuad
  6585. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6586. */
  6587. export class PowerEase extends EasingFunction implements IEasingFunction {
  6588. /** Defines the power of the function */
  6589. power: number;
  6590. /**
  6591. * Instantiates an power base easing function
  6592. * @see https://easings.net/#easeInQuad
  6593. * @param power Defines the power of the function
  6594. */
  6595. constructor(
  6596. /** Defines the power of the function */
  6597. power?: number);
  6598. /** @hidden */
  6599. easeInCore(gradient: number): number;
  6600. }
  6601. /**
  6602. * Easing function with a power of 2 shape (see link below).
  6603. * @see https://easings.net/#easeInQuad
  6604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6605. */
  6606. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6607. /** @hidden */
  6608. easeInCore(gradient: number): number;
  6609. }
  6610. /**
  6611. * Easing function with a power of 4 shape (see link below).
  6612. * @see https://easings.net/#easeInQuart
  6613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6614. */
  6615. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6616. /** @hidden */
  6617. easeInCore(gradient: number): number;
  6618. }
  6619. /**
  6620. * Easing function with a power of 5 shape (see link below).
  6621. * @see https://easings.net/#easeInQuint
  6622. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6623. */
  6624. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6625. /** @hidden */
  6626. easeInCore(gradient: number): number;
  6627. }
  6628. /**
  6629. * Easing function with a sin shape (see link below).
  6630. * @see https://easings.net/#easeInSine
  6631. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6632. */
  6633. export class SineEase extends EasingFunction implements IEasingFunction {
  6634. /** @hidden */
  6635. easeInCore(gradient: number): number;
  6636. }
  6637. /**
  6638. * Easing function with a bezier shape (see link below).
  6639. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6640. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6641. */
  6642. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6643. /** Defines the x component of the start tangent in the bezier curve */
  6644. x1: number;
  6645. /** Defines the y component of the start tangent in the bezier curve */
  6646. y1: number;
  6647. /** Defines the x component of the end tangent in the bezier curve */
  6648. x2: number;
  6649. /** Defines the y component of the end tangent in the bezier curve */
  6650. y2: number;
  6651. /**
  6652. * Instantiates a bezier function
  6653. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6654. * @param x1 Defines the x component of the start tangent in the bezier curve
  6655. * @param y1 Defines the y component of the start tangent in the bezier curve
  6656. * @param x2 Defines the x component of the end tangent in the bezier curve
  6657. * @param y2 Defines the y component of the end tangent in the bezier curve
  6658. */
  6659. constructor(
  6660. /** Defines the x component of the start tangent in the bezier curve */
  6661. x1?: number,
  6662. /** Defines the y component of the start tangent in the bezier curve */
  6663. y1?: number,
  6664. /** Defines the x component of the end tangent in the bezier curve */
  6665. x2?: number,
  6666. /** Defines the y component of the end tangent in the bezier curve */
  6667. y2?: number);
  6668. /** @hidden */
  6669. easeInCore(gradient: number): number;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Defines an interface which represents an animation key frame
  6675. */
  6676. export interface IAnimationKey {
  6677. /**
  6678. * Frame of the key frame
  6679. */
  6680. frame: number;
  6681. /**
  6682. * Value at the specifies key frame
  6683. */
  6684. value: any;
  6685. /**
  6686. * The input tangent for the cubic hermite spline
  6687. */
  6688. inTangent?: any;
  6689. /**
  6690. * The output tangent for the cubic hermite spline
  6691. */
  6692. outTangent?: any;
  6693. /**
  6694. * The animation interpolation type
  6695. */
  6696. interpolation?: AnimationKeyInterpolation;
  6697. }
  6698. /**
  6699. * Enum for the animation key frame interpolation type
  6700. */
  6701. export enum AnimationKeyInterpolation {
  6702. /**
  6703. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6704. */
  6705. STEP = 1
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. /**
  6710. * Represents the range of an animation
  6711. */
  6712. export class AnimationRange {
  6713. /**The name of the animation range**/
  6714. name: string;
  6715. /**The starting frame of the animation */
  6716. from: number;
  6717. /**The ending frame of the animation*/
  6718. to: number;
  6719. /**
  6720. * Initializes the range of an animation
  6721. * @param name The name of the animation range
  6722. * @param from The starting frame of the animation
  6723. * @param to The ending frame of the animation
  6724. */
  6725. constructor(
  6726. /**The name of the animation range**/
  6727. name: string,
  6728. /**The starting frame of the animation */
  6729. from: number,
  6730. /**The ending frame of the animation*/
  6731. to: number);
  6732. /**
  6733. * Makes a copy of the animation range
  6734. * @returns A copy of the animation range
  6735. */
  6736. clone(): AnimationRange;
  6737. }
  6738. }
  6739. declare module BABYLON {
  6740. /**
  6741. * Composed of a frame, and an action function
  6742. */
  6743. export class AnimationEvent {
  6744. /** The frame for which the event is triggered **/
  6745. frame: number;
  6746. /** The event to perform when triggered **/
  6747. action: (currentFrame: number) => void;
  6748. /** Specifies if the event should be triggered only once**/
  6749. onlyOnce?: boolean | undefined;
  6750. /**
  6751. * Specifies if the animation event is done
  6752. */
  6753. isDone: boolean;
  6754. /**
  6755. * Initializes the animation event
  6756. * @param frame The frame for which the event is triggered
  6757. * @param action The event to perform when triggered
  6758. * @param onlyOnce Specifies if the event should be triggered only once
  6759. */
  6760. constructor(
  6761. /** The frame for which the event is triggered **/
  6762. frame: number,
  6763. /** The event to perform when triggered **/
  6764. action: (currentFrame: number) => void,
  6765. /** Specifies if the event should be triggered only once**/
  6766. onlyOnce?: boolean | undefined);
  6767. /** @hidden */
  6768. _clone(): AnimationEvent;
  6769. }
  6770. }
  6771. declare module BABYLON {
  6772. /**
  6773. * Interface used to define a behavior
  6774. */
  6775. export interface Behavior<T> {
  6776. /** gets or sets behavior's name */
  6777. name: string;
  6778. /**
  6779. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6780. */
  6781. init(): void;
  6782. /**
  6783. * Called when the behavior is attached to a target
  6784. * @param target defines the target where the behavior is attached to
  6785. */
  6786. attach(target: T): void;
  6787. /**
  6788. * Called when the behavior is detached from its target
  6789. */
  6790. detach(): void;
  6791. }
  6792. /**
  6793. * Interface implemented by classes supporting behaviors
  6794. */
  6795. export interface IBehaviorAware<T> {
  6796. /**
  6797. * Attach a behavior
  6798. * @param behavior defines the behavior to attach
  6799. * @returns the current host
  6800. */
  6801. addBehavior(behavior: Behavior<T>): T;
  6802. /**
  6803. * Remove a behavior from the current object
  6804. * @param behavior defines the behavior to detach
  6805. * @returns the current host
  6806. */
  6807. removeBehavior(behavior: Behavior<T>): T;
  6808. /**
  6809. * Gets a behavior using its name to search
  6810. * @param name defines the name to search
  6811. * @returns the behavior or null if not found
  6812. */
  6813. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6814. }
  6815. }
  6816. declare module BABYLON {
  6817. /**
  6818. * @hidden
  6819. */
  6820. export class IntersectionInfo {
  6821. bu: Nullable<number>;
  6822. bv: Nullable<number>;
  6823. distance: number;
  6824. faceId: number;
  6825. subMeshId: number;
  6826. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6827. }
  6828. }
  6829. declare module BABYLON {
  6830. /**
  6831. * Class used to store bounding sphere information
  6832. */
  6833. export class BoundingSphere {
  6834. /**
  6835. * Gets the center of the bounding sphere in local space
  6836. */
  6837. readonly center: Vector3;
  6838. /**
  6839. * Radius of the bounding sphere in local space
  6840. */
  6841. radius: number;
  6842. /**
  6843. * Gets the center of the bounding sphere in world space
  6844. */
  6845. readonly centerWorld: Vector3;
  6846. /**
  6847. * Radius of the bounding sphere in world space
  6848. */
  6849. radiusWorld: number;
  6850. /**
  6851. * Gets the minimum vector in local space
  6852. */
  6853. readonly minimum: Vector3;
  6854. /**
  6855. * Gets the maximum vector in local space
  6856. */
  6857. readonly maximum: Vector3;
  6858. private _worldMatrix;
  6859. private static readonly TmpVector3;
  6860. /**
  6861. * Creates a new bounding sphere
  6862. * @param min defines the minimum vector (in local space)
  6863. * @param max defines the maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6867. /**
  6868. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6869. * @param min defines the new minimum vector (in local space)
  6870. * @param max defines the new maximum vector (in local space)
  6871. * @param worldMatrix defines the new world matrix
  6872. */
  6873. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Scale the current bounding sphere by applying a scale factor
  6876. * @param factor defines the scale factor to apply
  6877. * @returns the current bounding box
  6878. */
  6879. scale(factor: number): BoundingSphere;
  6880. /**
  6881. * Gets the world matrix of the bounding box
  6882. * @returns a matrix
  6883. */
  6884. getWorldMatrix(): DeepImmutable<Matrix>;
  6885. /** @hidden */
  6886. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6887. /**
  6888. * Tests if the bounding sphere is intersecting the frustum planes
  6889. * @param frustumPlanes defines the frustum planes to test
  6890. * @returns true if there is an intersection
  6891. */
  6892. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6893. /**
  6894. * Tests if the bounding sphere center is in between the frustum planes.
  6895. * Used for optimistic fast inclusion.
  6896. * @param frustumPlanes defines the frustum planes to test
  6897. * @returns true if the sphere center is in between the frustum planes
  6898. */
  6899. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6900. /**
  6901. * Tests if a point is inside the bounding sphere
  6902. * @param point defines the point to test
  6903. * @returns true if the point is inside the bounding sphere
  6904. */
  6905. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6906. /**
  6907. * Checks if two sphere intersct
  6908. * @param sphere0 sphere 0
  6909. * @param sphere1 sphere 1
  6910. * @returns true if the speres intersect
  6911. */
  6912. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6913. }
  6914. }
  6915. declare module BABYLON {
  6916. /**
  6917. * Class used to store bounding box information
  6918. */
  6919. export class BoundingBox implements ICullable {
  6920. /**
  6921. * Gets the 8 vectors representing the bounding box in local space
  6922. */
  6923. readonly vectors: Vector3[];
  6924. /**
  6925. * Gets the center of the bounding box in local space
  6926. */
  6927. readonly center: Vector3;
  6928. /**
  6929. * Gets the center of the bounding box in world space
  6930. */
  6931. readonly centerWorld: Vector3;
  6932. /**
  6933. * Gets the extend size in local space
  6934. */
  6935. readonly extendSize: Vector3;
  6936. /**
  6937. * Gets the extend size in world space
  6938. */
  6939. readonly extendSizeWorld: Vector3;
  6940. /**
  6941. * Gets the OBB (object bounding box) directions
  6942. */
  6943. readonly directions: Vector3[];
  6944. /**
  6945. * Gets the 8 vectors representing the bounding box in world space
  6946. */
  6947. readonly vectorsWorld: Vector3[];
  6948. /**
  6949. * Gets the minimum vector in world space
  6950. */
  6951. readonly minimumWorld: Vector3;
  6952. /**
  6953. * Gets the maximum vector in world space
  6954. */
  6955. readonly maximumWorld: Vector3;
  6956. /**
  6957. * Gets the minimum vector in local space
  6958. */
  6959. readonly minimum: Vector3;
  6960. /**
  6961. * Gets the maximum vector in local space
  6962. */
  6963. readonly maximum: Vector3;
  6964. private _worldMatrix;
  6965. private static readonly TmpVector3;
  6966. /**
  6967. * @hidden
  6968. */
  6969. _tag: number;
  6970. /**
  6971. * Creates a new bounding box
  6972. * @param min defines the minimum vector (in local space)
  6973. * @param max defines the maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Scale the current bounding box by applying a scale factor
  6986. * @param factor defines the scale factor to apply
  6987. * @returns the current bounding box
  6988. */
  6989. scale(factor: number): BoundingBox;
  6990. /**
  6991. * Gets the world matrix of the bounding box
  6992. * @returns a matrix
  6993. */
  6994. getWorldMatrix(): DeepImmutable<Matrix>;
  6995. /** @hidden */
  6996. _update(world: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * Tests if the bounding box is intersecting the frustum planes
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @returns true if there is an intersection
  7001. */
  7002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if the bounding box is entirely inside the frustum planes
  7005. * @param frustumPlanes defines the frustum planes to test
  7006. * @returns true if there is an inclusion
  7007. */
  7008. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7009. /**
  7010. * Tests if a point is inside the bounding box
  7011. * @param point defines the point to test
  7012. * @returns true if the point is inside the bounding box
  7013. */
  7014. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7015. /**
  7016. * Tests if the bounding box intersects with a bounding sphere
  7017. * @param sphere defines the sphere to test
  7018. * @returns true if there is an intersection
  7019. */
  7020. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7021. /**
  7022. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7023. * @param min defines the min vector to use
  7024. * @param max defines the max vector to use
  7025. * @returns true if there is an intersection
  7026. */
  7027. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7028. /**
  7029. * Tests if two bounding boxes are intersections
  7030. * @param box0 defines the first box to test
  7031. * @param box1 defines the second box to test
  7032. * @returns true if there is an intersection
  7033. */
  7034. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7035. /**
  7036. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7037. * @param minPoint defines the minimum vector of the bounding box
  7038. * @param maxPoint defines the maximum vector of the bounding box
  7039. * @param sphereCenter defines the sphere center
  7040. * @param sphereRadius defines the sphere radius
  7041. * @returns true if there is an intersection
  7042. */
  7043. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7044. /**
  7045. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7046. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @return true if there is an inclusion
  7049. */
  7050. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. /**
  7052. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7053. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7054. * @param frustumPlanes defines the frustum planes to test
  7055. * @return true if there is an intersection
  7056. */
  7057. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7058. }
  7059. }
  7060. declare module BABYLON {
  7061. /** @hidden */
  7062. export class Collider {
  7063. /** Define if a collision was found */
  7064. collisionFound: boolean;
  7065. /**
  7066. * Define last intersection point in local space
  7067. */
  7068. intersectionPoint: Vector3;
  7069. /**
  7070. * Define last collided mesh
  7071. */
  7072. collidedMesh: Nullable<AbstractMesh>;
  7073. private _collisionPoint;
  7074. private _planeIntersectionPoint;
  7075. private _tempVector;
  7076. private _tempVector2;
  7077. private _tempVector3;
  7078. private _tempVector4;
  7079. private _edge;
  7080. private _baseToVertex;
  7081. private _destinationPoint;
  7082. private _slidePlaneNormal;
  7083. private _displacementVector;
  7084. /** @hidden */
  7085. _radius: Vector3;
  7086. /** @hidden */
  7087. _retry: number;
  7088. private _velocity;
  7089. private _basePoint;
  7090. private _epsilon;
  7091. /** @hidden */
  7092. _velocityWorldLength: number;
  7093. /** @hidden */
  7094. _basePointWorld: Vector3;
  7095. private _velocityWorld;
  7096. private _normalizedVelocity;
  7097. /** @hidden */
  7098. _initialVelocity: Vector3;
  7099. /** @hidden */
  7100. _initialPosition: Vector3;
  7101. private _nearestDistance;
  7102. private _collisionMask;
  7103. collisionMask: number;
  7104. /**
  7105. * Gets the plane normal used to compute the sliding response (in local space)
  7106. */
  7107. readonly slidePlaneNormal: Vector3;
  7108. /** @hidden */
  7109. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7110. /** @hidden */
  7111. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7112. /** @hidden */
  7113. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7114. /** @hidden */
  7115. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7116. /** @hidden */
  7117. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7118. /** @hidden */
  7119. _getResponse(pos: Vector3, vel: Vector3): void;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Interface for cullable objects
  7125. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7126. */
  7127. export interface ICullable {
  7128. /**
  7129. * Checks if the object or part of the object is in the frustum
  7130. * @param frustumPlanes Camera near/planes
  7131. * @returns true if the object is in frustum otherwise false
  7132. */
  7133. isInFrustum(frustumPlanes: Plane[]): boolean;
  7134. /**
  7135. * Checks if a cullable object (mesh...) is in the camera frustum
  7136. * Unlike isInFrustum this cheks the full bounding box
  7137. * @param frustumPlanes Camera near/planes
  7138. * @returns true if the object is in frustum otherwise false
  7139. */
  7140. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7141. }
  7142. /**
  7143. * Info for a bounding data of a mesh
  7144. */
  7145. export class BoundingInfo implements ICullable {
  7146. /**
  7147. * Bounding box for the mesh
  7148. */
  7149. readonly boundingBox: BoundingBox;
  7150. /**
  7151. * Bounding sphere for the mesh
  7152. */
  7153. readonly boundingSphere: BoundingSphere;
  7154. private _isLocked;
  7155. private static readonly TmpVector3;
  7156. /**
  7157. * Constructs bounding info
  7158. * @param minimum min vector of the bounding box/sphere
  7159. * @param maximum max vector of the bounding box/sphere
  7160. * @param worldMatrix defines the new world matrix
  7161. */
  7162. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7163. /**
  7164. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7165. * @param min defines the new minimum vector (in local space)
  7166. * @param max defines the new maximum vector (in local space)
  7167. * @param worldMatrix defines the new world matrix
  7168. */
  7169. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7170. /**
  7171. * min vector of the bounding box/sphere
  7172. */
  7173. readonly minimum: Vector3;
  7174. /**
  7175. * max vector of the bounding box/sphere
  7176. */
  7177. readonly maximum: Vector3;
  7178. /**
  7179. * If the info is locked and won't be updated to avoid perf overhead
  7180. */
  7181. isLocked: boolean;
  7182. /**
  7183. * Updates the bounding sphere and box
  7184. * @param world world matrix to be used to update
  7185. */
  7186. update(world: DeepImmutable<Matrix>): void;
  7187. /**
  7188. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7189. * @param center New center of the bounding info
  7190. * @param extend New extend of the bounding info
  7191. * @returns the current bounding info
  7192. */
  7193. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7194. /**
  7195. * Scale the current bounding info by applying a scale factor
  7196. * @param factor defines the scale factor to apply
  7197. * @returns the current bounding info
  7198. */
  7199. scale(factor: number): BoundingInfo;
  7200. /**
  7201. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7202. * @param frustumPlanes defines the frustum to test
  7203. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7204. * @returns true if the bounding info is in the frustum planes
  7205. */
  7206. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7207. /**
  7208. * Gets the world distance between the min and max points of the bounding box
  7209. */
  7210. readonly diagonalLength: number;
  7211. /**
  7212. * Checks if a cullable object (mesh...) is in the camera frustum
  7213. * Unlike isInFrustum this cheks the full bounding box
  7214. * @param frustumPlanes Camera near/planes
  7215. * @returns true if the object is in frustum otherwise false
  7216. */
  7217. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7218. /** @hidden */
  7219. _checkCollision(collider: Collider): boolean;
  7220. /**
  7221. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7222. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7223. * @param point the point to check intersection with
  7224. * @returns if the point intersects
  7225. */
  7226. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7227. /**
  7228. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7229. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7230. * @param boundingInfo the bounding info to check intersection with
  7231. * @param precise if the intersection should be done using OBB
  7232. * @returns if the bounding info intersects
  7233. */
  7234. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7235. }
  7236. }
  7237. declare module BABYLON {
  7238. /**
  7239. * Defines an array and its length.
  7240. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7241. */
  7242. export interface ISmartArrayLike<T> {
  7243. /**
  7244. * The data of the array.
  7245. */
  7246. data: Array<T>;
  7247. /**
  7248. * The active length of the array.
  7249. */
  7250. length: number;
  7251. }
  7252. /**
  7253. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7254. */
  7255. export class SmartArray<T> implements ISmartArrayLike<T> {
  7256. /**
  7257. * The full set of data from the array.
  7258. */
  7259. data: Array<T>;
  7260. /**
  7261. * The active length of the array.
  7262. */
  7263. length: number;
  7264. protected _id: number;
  7265. /**
  7266. * Instantiates a Smart Array.
  7267. * @param capacity defines the default capacity of the array.
  7268. */
  7269. constructor(capacity: number);
  7270. /**
  7271. * Pushes a value at the end of the active data.
  7272. * @param value defines the object to push in the array.
  7273. */
  7274. push(value: T): void;
  7275. /**
  7276. * Iterates over the active data and apply the lambda to them.
  7277. * @param func defines the action to apply on each value.
  7278. */
  7279. forEach(func: (content: T) => void): void;
  7280. /**
  7281. * Sorts the full sets of data.
  7282. * @param compareFn defines the comparison function to apply.
  7283. */
  7284. sort(compareFn: (a: T, b: T) => number): void;
  7285. /**
  7286. * Resets the active data to an empty array.
  7287. */
  7288. reset(): void;
  7289. /**
  7290. * Releases all the data from the array as well as the array.
  7291. */
  7292. dispose(): void;
  7293. /**
  7294. * Concats the active data with a given array.
  7295. * @param array defines the data to concatenate with.
  7296. */
  7297. concat(array: any): void;
  7298. /**
  7299. * Returns the position of a value in the active data.
  7300. * @param value defines the value to find the index for
  7301. * @returns the index if found in the active data otherwise -1
  7302. */
  7303. indexOf(value: T): number;
  7304. /**
  7305. * Returns whether an element is part of the active data.
  7306. * @param value defines the value to look for
  7307. * @returns true if found in the active data otherwise false
  7308. */
  7309. contains(value: T): boolean;
  7310. private static _GlobalId;
  7311. }
  7312. /**
  7313. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7314. * The data in this array can only be present once
  7315. */
  7316. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7317. private _duplicateId;
  7318. /**
  7319. * Pushes a value at the end of the active data.
  7320. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7321. * @param value defines the object to push in the array.
  7322. */
  7323. push(value: T): void;
  7324. /**
  7325. * Pushes a value at the end of the active data.
  7326. * If the data is already present, it won t be added again
  7327. * @param value defines the object to push in the array.
  7328. * @returns true if added false if it was already present
  7329. */
  7330. pushNoDuplicate(value: T): boolean;
  7331. /**
  7332. * Resets the active data to an empty array.
  7333. */
  7334. reset(): void;
  7335. /**
  7336. * Concats the active data with a given array.
  7337. * This ensures no dupplicate will be present in the result.
  7338. * @param array defines the data to concatenate with.
  7339. */
  7340. concatWithNoDuplicate(array: any): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7346. * separate meshes. This can be use to improve performances.
  7347. * @see http://doc.babylonjs.com/how_to/multi_materials
  7348. */
  7349. export class MultiMaterial extends Material {
  7350. private _subMaterials;
  7351. /**
  7352. * Gets or Sets the list of Materials used within the multi material.
  7353. * They need to be ordered according to the submeshes order in the associated mesh
  7354. */
  7355. subMaterials: Nullable<Material>[];
  7356. /**
  7357. * Function used to align with Node.getChildren()
  7358. * @returns the list of Materials used within the multi material
  7359. */
  7360. getChildren(): Nullable<Material>[];
  7361. /**
  7362. * Instantiates a new Multi Material
  7363. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7364. * separate meshes. This can be use to improve performances.
  7365. * @see http://doc.babylonjs.com/how_to/multi_materials
  7366. * @param name Define the name in the scene
  7367. * @param scene Define the scene the material belongs to
  7368. */
  7369. constructor(name: string, scene: Scene);
  7370. private _hookArray;
  7371. /**
  7372. * Get one of the submaterial by its index in the submaterials array
  7373. * @param index The index to look the sub material at
  7374. * @returns The Material if the index has been defined
  7375. */
  7376. getSubMaterial(index: number): Nullable<Material>;
  7377. /**
  7378. * Get the list of active textures for the whole sub materials list.
  7379. * @returns All the textures that will be used during the rendering
  7380. */
  7381. getActiveTextures(): BaseTexture[];
  7382. /**
  7383. * Gets the current class name of the material e.g. "MultiMaterial"
  7384. * Mainly use in serialization.
  7385. * @returns the class name
  7386. */
  7387. getClassName(): string;
  7388. /**
  7389. * Checks if the material is ready to render the requested sub mesh
  7390. * @param mesh Define the mesh the submesh belongs to
  7391. * @param subMesh Define the sub mesh to look readyness for
  7392. * @param useInstances Define whether or not the material is used with instances
  7393. * @returns true if ready, otherwise false
  7394. */
  7395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7396. /**
  7397. * Clones the current material and its related sub materials
  7398. * @param name Define the name of the newly cloned material
  7399. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7400. * @returns the cloned material
  7401. */
  7402. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7403. /**
  7404. * Serializes the materials into a JSON representation.
  7405. * @returns the JSON representation
  7406. */
  7407. serialize(): any;
  7408. /**
  7409. * Dispose the material and release its associated resources
  7410. * @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)
  7411. * @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)
  7412. * @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)
  7413. */
  7414. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7415. /**
  7416. * Creates a MultiMaterial from parsed MultiMaterial data.
  7417. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7418. * @param scene defines the hosting scene
  7419. * @returns a new MultiMaterial
  7420. */
  7421. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7422. }
  7423. }
  7424. declare module BABYLON {
  7425. /**
  7426. * Class used to represent data loading progression
  7427. */
  7428. export class SceneLoaderFlags {
  7429. private static _ForceFullSceneLoadingForIncremental;
  7430. private static _ShowLoadingScreen;
  7431. private static _CleanBoneMatrixWeights;
  7432. private static _loggingLevel;
  7433. /**
  7434. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7435. */
  7436. static ForceFullSceneLoadingForIncremental: boolean;
  7437. /**
  7438. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7439. */
  7440. static ShowLoadingScreen: boolean;
  7441. /**
  7442. * Defines the current logging level (while loading the scene)
  7443. * @ignorenaming
  7444. */
  7445. static loggingLevel: number;
  7446. /**
  7447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7448. */
  7449. static CleanBoneMatrixWeights: boolean;
  7450. }
  7451. }
  7452. declare module BABYLON {
  7453. /**
  7454. * 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.
  7455. * @see https://doc.babylonjs.com/how_to/transformnode
  7456. */
  7457. export class TransformNode extends Node {
  7458. /**
  7459. * Object will not rotate to face the camera
  7460. */
  7461. static BILLBOARDMODE_NONE: number;
  7462. /**
  7463. * Object will rotate to face the camera but only on the x axis
  7464. */
  7465. static BILLBOARDMODE_X: number;
  7466. /**
  7467. * Object will rotate to face the camera but only on the y axis
  7468. */
  7469. static BILLBOARDMODE_Y: number;
  7470. /**
  7471. * Object will rotate to face the camera but only on the z axis
  7472. */
  7473. static BILLBOARDMODE_Z: number;
  7474. /**
  7475. * Object will rotate to face the camera
  7476. */
  7477. static BILLBOARDMODE_ALL: number;
  7478. private _forward;
  7479. private _forwardInverted;
  7480. private _up;
  7481. private _right;
  7482. private _rightInverted;
  7483. private _position;
  7484. private _rotation;
  7485. private _rotationQuaternion;
  7486. protected _scaling: Vector3;
  7487. protected _isDirty: boolean;
  7488. private _transformToBoneReferal;
  7489. private _billboardMode;
  7490. /**
  7491. * Gets or sets the billboard mode. Default is 0.
  7492. *
  7493. * | Value | Type | Description |
  7494. * | --- | --- | --- |
  7495. * | 0 | BILLBOARDMODE_NONE | |
  7496. * | 1 | BILLBOARDMODE_X | |
  7497. * | 2 | BILLBOARDMODE_Y | |
  7498. * | 4 | BILLBOARDMODE_Z | |
  7499. * | 7 | BILLBOARDMODE_ALL | |
  7500. *
  7501. */
  7502. billboardMode: number;
  7503. private _preserveParentRotationForBillboard;
  7504. /**
  7505. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7506. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7507. */
  7508. preserveParentRotationForBillboard: boolean;
  7509. /**
  7510. * 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
  7511. */
  7512. scalingDeterminant: number;
  7513. private _infiniteDistance;
  7514. /**
  7515. * Gets or sets the distance of the object to max, often used by skybox
  7516. */
  7517. infiniteDistance: boolean;
  7518. /**
  7519. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7520. * By default the system will update normals to compensate
  7521. */
  7522. ignoreNonUniformScaling: boolean;
  7523. /**
  7524. * 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
  7525. */
  7526. reIntegrateRotationIntoRotationQuaternion: boolean;
  7527. /** @hidden */
  7528. _poseMatrix: Nullable<Matrix>;
  7529. /** @hidden */
  7530. _localMatrix: Matrix;
  7531. private _usePivotMatrix;
  7532. private _absolutePosition;
  7533. private _pivotMatrix;
  7534. private _pivotMatrixInverse;
  7535. protected _postMultiplyPivotMatrix: boolean;
  7536. protected _isWorldMatrixFrozen: boolean;
  7537. /** @hidden */
  7538. _indexInSceneTransformNodesArray: number;
  7539. /**
  7540. * An event triggered after the world matrix is updated
  7541. */
  7542. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7543. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7544. /**
  7545. * Gets a string identifying the name of the class
  7546. * @returns "TransformNode" string
  7547. */
  7548. getClassName(): string;
  7549. /**
  7550. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7551. */
  7552. position: Vector3;
  7553. /**
  7554. * 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)).
  7555. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7556. */
  7557. rotation: Vector3;
  7558. /**
  7559. * 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)).
  7560. */
  7561. scaling: Vector3;
  7562. /**
  7563. * 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).
  7564. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7565. */
  7566. rotationQuaternion: Nullable<Quaternion>;
  7567. /**
  7568. * The forward direction of that transform in world space.
  7569. */
  7570. readonly forward: Vector3;
  7571. /**
  7572. * The up direction of that transform in world space.
  7573. */
  7574. readonly up: Vector3;
  7575. /**
  7576. * The right direction of that transform in world space.
  7577. */
  7578. readonly right: Vector3;
  7579. /**
  7580. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7581. * @param matrix the matrix to copy the pose from
  7582. * @returns this TransformNode.
  7583. */
  7584. updatePoseMatrix(matrix: Matrix): TransformNode;
  7585. /**
  7586. * Returns the mesh Pose matrix.
  7587. * @returns the pose matrix
  7588. */
  7589. getPoseMatrix(): Matrix;
  7590. /** @hidden */
  7591. _isSynchronized(): boolean;
  7592. /** @hidden */
  7593. _initCache(): void;
  7594. /**
  7595. * Flag the transform node as dirty (Forcing it to update everything)
  7596. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7597. * @returns this transform node
  7598. */
  7599. markAsDirty(property: string): TransformNode;
  7600. /**
  7601. * Returns the current mesh absolute position.
  7602. * Returns a Vector3.
  7603. */
  7604. readonly absolutePosition: Vector3;
  7605. /**
  7606. * Sets a new matrix to apply before all other transformation
  7607. * @param matrix defines the transform matrix
  7608. * @returns the current TransformNode
  7609. */
  7610. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7611. /**
  7612. * Sets a new pivot matrix to the current node
  7613. * @param matrix defines the new pivot matrix to use
  7614. * @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
  7615. * @returns the current TransformNode
  7616. */
  7617. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7618. /**
  7619. * Returns the mesh pivot matrix.
  7620. * Default : Identity.
  7621. * @returns the matrix
  7622. */
  7623. getPivotMatrix(): Matrix;
  7624. /**
  7625. * Prevents the World matrix to be computed any longer.
  7626. * @returns the TransformNode.
  7627. */
  7628. freezeWorldMatrix(): TransformNode;
  7629. /**
  7630. * Allows back the World matrix computation.
  7631. * @returns the TransformNode.
  7632. */
  7633. unfreezeWorldMatrix(): this;
  7634. /**
  7635. * True if the World matrix has been frozen.
  7636. */
  7637. readonly isWorldMatrixFrozen: boolean;
  7638. /**
  7639. * Retuns the mesh absolute position in the World.
  7640. * @returns a Vector3.
  7641. */
  7642. getAbsolutePosition(): Vector3;
  7643. /**
  7644. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7645. * @param absolutePosition the absolute position to set
  7646. * @returns the TransformNode.
  7647. */
  7648. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7649. /**
  7650. * Sets the mesh position in its local space.
  7651. * @param vector3 the position to set in localspace
  7652. * @returns the TransformNode.
  7653. */
  7654. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7655. /**
  7656. * Returns the mesh position in the local space from the current World matrix values.
  7657. * @returns a new Vector3.
  7658. */
  7659. getPositionExpressedInLocalSpace(): Vector3;
  7660. /**
  7661. * Translates the mesh along the passed Vector3 in its local space.
  7662. * @param vector3 the distance to translate in localspace
  7663. * @returns the TransformNode.
  7664. */
  7665. locallyTranslate(vector3: Vector3): TransformNode;
  7666. private static _lookAtVectorCache;
  7667. /**
  7668. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7669. * @param targetPoint the position (must be in same space as current mesh) to look at
  7670. * @param yawCor optional yaw (y-axis) correction in radians
  7671. * @param pitchCor optional pitch (x-axis) correction in radians
  7672. * @param rollCor optional roll (z-axis) correction in radians
  7673. * @param space the choosen space of the target
  7674. * @returns the TransformNode.
  7675. */
  7676. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7677. /**
  7678. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7679. * This Vector3 is expressed in the World space.
  7680. * @param localAxis axis to rotate
  7681. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7682. */
  7683. getDirection(localAxis: Vector3): Vector3;
  7684. /**
  7685. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7686. * localAxis is expressed in the mesh local space.
  7687. * result is computed in the Wordl space from the mesh World matrix.
  7688. * @param localAxis axis to rotate
  7689. * @param result the resulting transformnode
  7690. * @returns this TransformNode.
  7691. */
  7692. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7693. /**
  7694. * Sets this transform node rotation to the given local axis.
  7695. * @param localAxis the axis in local space
  7696. * @param yawCor optional yaw (y-axis) correction in radians
  7697. * @param pitchCor optional pitch (x-axis) correction in radians
  7698. * @param rollCor optional roll (z-axis) correction in radians
  7699. * @returns this TransformNode
  7700. */
  7701. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7702. /**
  7703. * Sets a new pivot point to the current node
  7704. * @param point defines the new pivot point to use
  7705. * @param space defines if the point is in world or local space (local by default)
  7706. * @returns the current TransformNode
  7707. */
  7708. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7709. /**
  7710. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7711. * @returns the pivot point
  7712. */
  7713. getPivotPoint(): Vector3;
  7714. /**
  7715. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7716. * @param result the vector3 to store the result
  7717. * @returns this TransformNode.
  7718. */
  7719. getPivotPointToRef(result: Vector3): TransformNode;
  7720. /**
  7721. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7722. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7723. */
  7724. getAbsolutePivotPoint(): Vector3;
  7725. /**
  7726. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7727. * @param result vector3 to store the result
  7728. * @returns this TransformNode.
  7729. */
  7730. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7731. /**
  7732. * Defines the passed node as the parent of the current node.
  7733. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7734. * @see https://doc.babylonjs.com/how_to/parenting
  7735. * @param node the node ot set as the parent
  7736. * @returns this TransformNode.
  7737. */
  7738. setParent(node: Nullable<Node>): TransformNode;
  7739. private _nonUniformScaling;
  7740. /**
  7741. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7742. */
  7743. readonly nonUniformScaling: boolean;
  7744. /** @hidden */
  7745. _updateNonUniformScalingState(value: boolean): boolean;
  7746. /**
  7747. * Attach the current TransformNode to another TransformNode associated with a bone
  7748. * @param bone Bone affecting the TransformNode
  7749. * @param affectedTransformNode TransformNode associated with the bone
  7750. * @returns this object
  7751. */
  7752. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7753. /**
  7754. * Detach the transform node if its associated with a bone
  7755. * @returns this object
  7756. */
  7757. detachFromBone(): TransformNode;
  7758. private static _rotationAxisCache;
  7759. /**
  7760. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7761. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7762. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7763. * The passed axis is also normalized.
  7764. * @param axis the axis to rotate around
  7765. * @param amount the amount to rotate in radians
  7766. * @param space Space to rotate in (Default: local)
  7767. * @returns the TransformNode.
  7768. */
  7769. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7770. /**
  7771. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7772. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7773. * The passed axis is also normalized. .
  7774. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7775. * @param point the point to rotate around
  7776. * @param axis the axis to rotate around
  7777. * @param amount the amount to rotate in radians
  7778. * @returns the TransformNode
  7779. */
  7780. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7781. /**
  7782. * Translates the mesh along the axis vector for the passed distance in the given space.
  7783. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7784. * @param axis the axis to translate in
  7785. * @param distance the distance to translate
  7786. * @param space Space to rotate in (Default: local)
  7787. * @returns the TransformNode.
  7788. */
  7789. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7790. /**
  7791. * Adds a rotation step to the mesh current rotation.
  7792. * x, y, z are Euler angles expressed in radians.
  7793. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7794. * This means this rotation is made in the mesh local space only.
  7795. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7796. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7797. * ```javascript
  7798. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7799. * ```
  7800. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7801. * 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.
  7802. * @param x Rotation to add
  7803. * @param y Rotation to add
  7804. * @param z Rotation to add
  7805. * @returns the TransformNode.
  7806. */
  7807. addRotation(x: number, y: number, z: number): TransformNode;
  7808. /**
  7809. * @hidden
  7810. */
  7811. protected _getEffectiveParent(): Nullable<Node>;
  7812. /**
  7813. * Computes the world matrix of the node
  7814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7815. * @returns the world matrix
  7816. */
  7817. computeWorldMatrix(force?: boolean): Matrix;
  7818. protected _afterComputeWorldMatrix(): void;
  7819. /**
  7820. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7821. * @param func callback function to add
  7822. *
  7823. * @returns the TransformNode.
  7824. */
  7825. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7826. /**
  7827. * Removes a registered callback function.
  7828. * @param func callback function to remove
  7829. * @returns the TransformNode.
  7830. */
  7831. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7832. /**
  7833. * Gets the position of the current mesh in camera space
  7834. * @param camera defines the camera to use
  7835. * @returns a position
  7836. */
  7837. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7838. /**
  7839. * Returns the distance from the mesh to the active camera
  7840. * @param camera defines the camera to use
  7841. * @returns the distance
  7842. */
  7843. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7844. /**
  7845. * Clone the current transform node
  7846. * @param name Name of the new clone
  7847. * @param newParent New parent for the clone
  7848. * @param doNotCloneChildren Do not clone children hierarchy
  7849. * @returns the new transform node
  7850. */
  7851. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7852. /**
  7853. * Serializes the objects information.
  7854. * @param currentSerializationObject defines the object to serialize in
  7855. * @returns the serialized object
  7856. */
  7857. serialize(currentSerializationObject?: any): any;
  7858. /**
  7859. * Returns a new TransformNode object parsed from the source provided.
  7860. * @param parsedTransformNode is the source.
  7861. * @param scene the scne the object belongs to
  7862. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7863. * @returns a new TransformNode object parsed from the source provided.
  7864. */
  7865. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7866. /**
  7867. * Get all child-transformNodes of this node
  7868. * @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
  7869. * @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
  7870. * @returns an array of TransformNode
  7871. */
  7872. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7873. /**
  7874. * Releases resources associated with this transform node.
  7875. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7876. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7877. */
  7878. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class used to override all child animations of a given target
  7884. */
  7885. export class AnimationPropertiesOverride {
  7886. /**
  7887. * Gets or sets a value indicating if animation blending must be used
  7888. */
  7889. enableBlending: boolean;
  7890. /**
  7891. * Gets or sets the blending speed to use when enableBlending is true
  7892. */
  7893. blendingSpeed: number;
  7894. /**
  7895. * Gets or sets the default loop mode to use
  7896. */
  7897. loopMode: number;
  7898. }
  7899. }
  7900. declare module BABYLON {
  7901. /**
  7902. * Class used to store bone information
  7903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7904. */
  7905. export class Bone extends Node {
  7906. /**
  7907. * defines the bone name
  7908. */
  7909. name: string;
  7910. private static _tmpVecs;
  7911. private static _tmpQuat;
  7912. private static _tmpMats;
  7913. /**
  7914. * Gets the list of child bones
  7915. */
  7916. children: Bone[];
  7917. /** Gets the animations associated with this bone */
  7918. animations: Animation[];
  7919. /**
  7920. * Gets or sets bone length
  7921. */
  7922. length: number;
  7923. /**
  7924. * @hidden Internal only
  7925. * Set this value to map this bone to a different index in the transform matrices
  7926. * Set this value to -1 to exclude the bone from the transform matrices
  7927. */
  7928. _index: Nullable<number>;
  7929. private _skeleton;
  7930. private _localMatrix;
  7931. private _restPose;
  7932. private _baseMatrix;
  7933. private _absoluteTransform;
  7934. private _invertedAbsoluteTransform;
  7935. private _parent;
  7936. private _scalingDeterminant;
  7937. private _worldTransform;
  7938. private _localScaling;
  7939. private _localRotation;
  7940. private _localPosition;
  7941. private _needToDecompose;
  7942. private _needToCompose;
  7943. /** @hidden */
  7944. _linkedTransformNode: Nullable<TransformNode>;
  7945. /** @hidden */
  7946. /** @hidden */
  7947. _matrix: Matrix;
  7948. /**
  7949. * Create a new bone
  7950. * @param name defines the bone name
  7951. * @param skeleton defines the parent skeleton
  7952. * @param parentBone defines the parent (can be null if the bone is the root)
  7953. * @param localMatrix defines the local matrix
  7954. * @param restPose defines the rest pose matrix
  7955. * @param baseMatrix defines the base matrix
  7956. * @param index defines index of the bone in the hiearchy
  7957. */
  7958. constructor(
  7959. /**
  7960. * defines the bone name
  7961. */
  7962. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7963. /**
  7964. * Gets the current object class name.
  7965. * @return the class name
  7966. */
  7967. getClassName(): string;
  7968. /**
  7969. * Gets the parent skeleton
  7970. * @returns a skeleton
  7971. */
  7972. getSkeleton(): Skeleton;
  7973. /**
  7974. * Gets parent bone
  7975. * @returns a bone or null if the bone is the root of the bone hierarchy
  7976. */
  7977. getParent(): Nullable<Bone>;
  7978. /**
  7979. * Returns an array containing the root bones
  7980. * @returns an array containing the root bones
  7981. */
  7982. getChildren(): Array<Bone>;
  7983. /**
  7984. * Sets the parent bone
  7985. * @param parent defines the parent (can be null if the bone is the root)
  7986. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7987. */
  7988. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7989. /**
  7990. * Gets the local matrix
  7991. * @returns a matrix
  7992. */
  7993. getLocalMatrix(): Matrix;
  7994. /**
  7995. * Gets the base matrix (initial matrix which remains unchanged)
  7996. * @returns a matrix
  7997. */
  7998. getBaseMatrix(): Matrix;
  7999. /**
  8000. * Gets the rest pose matrix
  8001. * @returns a matrix
  8002. */
  8003. getRestPose(): Matrix;
  8004. /**
  8005. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8006. */
  8007. getWorldMatrix(): Matrix;
  8008. /**
  8009. * Sets the local matrix to rest pose matrix
  8010. */
  8011. returnToRest(): void;
  8012. /**
  8013. * Gets the inverse of the absolute transform matrix.
  8014. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8015. * @returns a matrix
  8016. */
  8017. getInvertedAbsoluteTransform(): Matrix;
  8018. /**
  8019. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8020. * @returns a matrix
  8021. */
  8022. getAbsoluteTransform(): Matrix;
  8023. /**
  8024. * Links with the given transform node.
  8025. * The local matrix of this bone is copied from the transform node every frame.
  8026. * @param transformNode defines the transform node to link to
  8027. */
  8028. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8029. /** Gets or sets current position (in local space) */
  8030. position: Vector3;
  8031. /** Gets or sets current rotation (in local space) */
  8032. rotation: Vector3;
  8033. /** Gets or sets current rotation quaternion (in local space) */
  8034. rotationQuaternion: Quaternion;
  8035. /** Gets or sets current scaling (in local space) */
  8036. scaling: Vector3;
  8037. /**
  8038. * Gets the animation properties override
  8039. */
  8040. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8041. private _decompose;
  8042. private _compose;
  8043. /**
  8044. * Update the base and local matrices
  8045. * @param matrix defines the new base or local matrix
  8046. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8047. * @param updateLocalMatrix defines if the local matrix should be updated
  8048. */
  8049. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8050. /** @hidden */
  8051. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8052. /**
  8053. * Flag the bone as dirty (Forcing it to update everything)
  8054. */
  8055. markAsDirty(): void;
  8056. private _markAsDirtyAndCompose;
  8057. private _markAsDirtyAndDecompose;
  8058. /**
  8059. * Translate the bone in local or world space
  8060. * @param vec The amount to translate the bone
  8061. * @param space The space that the translation is in
  8062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8063. */
  8064. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8065. /**
  8066. * Set the postion of the bone in local or world space
  8067. * @param position The position to set the bone
  8068. * @param space The space that the position is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the absolute position of the bone (world space)
  8074. * @param position The position to set the bone
  8075. * @param mesh The mesh that this bone is attached to
  8076. */
  8077. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Scale the bone on the x, y and z axes (in local space)
  8080. * @param x The amount to scale the bone on the x axis
  8081. * @param y The amount to scale the bone on the y axis
  8082. * @param z The amount to scale the bone on the z axis
  8083. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8084. */
  8085. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8086. /**
  8087. * Set the bone scaling in local space
  8088. * @param scale defines the scaling vector
  8089. */
  8090. setScale(scale: Vector3): void;
  8091. /**
  8092. * Gets the current scaling in local space
  8093. * @returns the current scaling vector
  8094. */
  8095. getScale(): Vector3;
  8096. /**
  8097. * Gets the current scaling in local space and stores it in a target vector
  8098. * @param result defines the target vector
  8099. */
  8100. getScaleToRef(result: Vector3): void;
  8101. /**
  8102. * Set the yaw, pitch, and roll of the bone in local or world space
  8103. * @param yaw The rotation of the bone on the y axis
  8104. * @param pitch The rotation of the bone on the x axis
  8105. * @param roll The rotation of the bone on the z axis
  8106. * @param space The space that the axes of rotation are in
  8107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8108. */
  8109. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8110. /**
  8111. * Add a rotation to the bone on an axis in local or world space
  8112. * @param axis The axis to rotate the bone on
  8113. * @param amount The amount to rotate the bone
  8114. * @param space The space that the axis is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. */
  8117. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8118. /**
  8119. * Set the rotation of the bone to a particular axis angle in local or world space
  8120. * @param axis The axis to rotate the bone on
  8121. * @param angle The angle that the bone should be rotated to
  8122. * @param space The space that the axis is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8126. /**
  8127. * Set the euler rotation of the bone in local of world space
  8128. * @param rotation The euler rotation that the bone should be set to
  8129. * @param space The space that the rotation is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the quaternion rotation of the bone in local of world space
  8135. * @param quat The quaternion rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the rotation matrix of the bone in local of world space
  8142. * @param rotMat The rotation matrix that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8147. private _rotateWithMatrix;
  8148. private _getNegativeRotationToRef;
  8149. /**
  8150. * Get the position of the bone in local or world space
  8151. * @param space The space that the returned position is in
  8152. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8153. * @returns The position of the bone
  8154. */
  8155. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8156. /**
  8157. * Copy the position of the bone to a vector3 in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @param result The vector3 to copy the position to
  8161. */
  8162. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8163. /**
  8164. * Get the absolute position of the bone (world space)
  8165. * @param mesh The mesh that this bone is attached to
  8166. * @returns The absolute position of the bone
  8167. */
  8168. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8169. /**
  8170. * Copy the absolute position of the bone (world space) to the result param
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @param result The vector3 to copy the absolute position to
  8173. */
  8174. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8175. /**
  8176. * Compute the absolute transforms of this bone and its children
  8177. */
  8178. computeAbsoluteTransforms(): void;
  8179. /**
  8180. * Get the world direction from an axis that is in the local space of the bone
  8181. * @param localAxis The local direction that is used to compute the world direction
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @returns The world direction
  8184. */
  8185. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8186. /**
  8187. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @param result The vector3 that the world direction will be copied to
  8191. */
  8192. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8193. /**
  8194. * Get the euler rotation of the bone in local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @returns The euler rotation
  8198. */
  8199. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8200. /**
  8201. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @param result The vector3 that the rotation should be copied to
  8205. */
  8206. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8207. /**
  8208. * Get the quaternion rotation of the bone in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @returns The quaternion rotation
  8212. */
  8213. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8214. /**
  8215. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @param result The quaternion that the rotation should be copied to
  8219. */
  8220. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8221. /**
  8222. * Get the rotation matrix of the bone in local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @returns The rotation matrix
  8226. */
  8227. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8228. /**
  8229. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @param result The quaternion that the rotation should be copied to
  8233. */
  8234. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8235. /**
  8236. * Get the world position of a point that is in the local space of the bone
  8237. * @param position The local position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @returns The world position
  8240. */
  8241. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @param result The vector3 that the world position should be copied to
  8247. */
  8248. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8249. /**
  8250. * Get the local position of a point that is in world space
  8251. * @param position The world position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @returns The local position
  8254. */
  8255. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8256. /**
  8257. * Get the local position of a point that is in world space and copy it to the result param
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @param result The vector3 that the local position should be copied to
  8261. */
  8262. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8263. }
  8264. }
  8265. declare module BABYLON {
  8266. /**
  8267. * Enum that determines the text-wrapping mode to use.
  8268. */
  8269. export enum InspectableType {
  8270. /**
  8271. * Checkbox for booleans
  8272. */
  8273. Checkbox = 0,
  8274. /**
  8275. * Sliders for numbers
  8276. */
  8277. Slider = 1,
  8278. /**
  8279. * Vector3
  8280. */
  8281. Vector3 = 2,
  8282. /**
  8283. * Quaternions
  8284. */
  8285. Quaternion = 3,
  8286. /**
  8287. * Color3
  8288. */
  8289. Color3 = 4
  8290. }
  8291. /**
  8292. * Interface used to define custom inspectable properties.
  8293. * This interface is used by the inspector to display custom property grids
  8294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8295. */
  8296. export interface IInspectable {
  8297. /**
  8298. * Gets the label to display
  8299. */
  8300. label: string;
  8301. /**
  8302. * Gets the name of the property to edit
  8303. */
  8304. propertyName: string;
  8305. /**
  8306. * Gets the type of the editor to use
  8307. */
  8308. type: InspectableType;
  8309. /**
  8310. * Gets the minimum value of the property when using in "slider" mode
  8311. */
  8312. min?: number;
  8313. /**
  8314. * Gets the maximum value of the property when using in "slider" mode
  8315. */
  8316. max?: number;
  8317. /**
  8318. * Gets the setp to use when using in "slider" mode
  8319. */
  8320. step?: number;
  8321. }
  8322. }
  8323. declare module BABYLON {
  8324. /**
  8325. * Class for creating a cube texture
  8326. */
  8327. export class CubeTexture extends BaseTexture {
  8328. private _delayedOnLoad;
  8329. /**
  8330. * The url of the texture
  8331. */
  8332. url: string;
  8333. /**
  8334. * Gets or sets the center of the bounding box associated with the cube texture.
  8335. * It must define where the camera used to render the texture was set
  8336. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8337. */
  8338. boundingBoxPosition: Vector3;
  8339. private _boundingBoxSize;
  8340. /**
  8341. * Gets or sets the size of the bounding box associated with the cube texture
  8342. * When defined, the cubemap will switch to local mode
  8343. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8344. * @example https://www.babylonjs-playground.com/#RNASML
  8345. */
  8346. /**
  8347. * Returns the bounding box size
  8348. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8349. */
  8350. boundingBoxSize: Vector3;
  8351. protected _rotationY: number;
  8352. /**
  8353. * Sets texture matrix rotation angle around Y axis in radians.
  8354. */
  8355. /**
  8356. * Gets texture matrix rotation angle around Y axis radians.
  8357. */
  8358. rotationY: number;
  8359. /**
  8360. * Are mip maps generated for this texture or not.
  8361. */
  8362. readonly noMipmap: boolean;
  8363. private _noMipmap;
  8364. private _files;
  8365. private _extensions;
  8366. private _textureMatrix;
  8367. private _format;
  8368. private _createPolynomials;
  8369. /** @hidden */
  8370. _prefiltered: boolean;
  8371. /**
  8372. * Creates a cube texture from an array of image urls
  8373. * @param files defines an array of image urls
  8374. * @param scene defines the hosting scene
  8375. * @param noMipmap specifies if mip maps are not used
  8376. * @returns a cube texture
  8377. */
  8378. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8379. /**
  8380. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8381. * @param url defines the url of the prefiltered texture
  8382. * @param scene defines the scene the texture is attached to
  8383. * @param forcedExtension defines the extension of the file if different from the url
  8384. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8385. * @return the prefiltered texture
  8386. */
  8387. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8388. /**
  8389. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8390. * as prefiltered data.
  8391. * @param rootUrl defines the url of the texture or the root name of the six images
  8392. * @param scene defines the scene the texture is attached to
  8393. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8394. * @param noMipmap defines if mipmaps should be created or not
  8395. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8396. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8397. * @param onError defines a callback triggered in case of error during load
  8398. * @param format defines the internal format to use for the texture once loaded
  8399. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8400. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8401. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8402. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8403. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8404. * @return the cube texture
  8405. */
  8406. 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);
  8407. /**
  8408. * Get the current class name of the texture useful for serialization or dynamic coding.
  8409. * @returns "CubeTexture"
  8410. */
  8411. getClassName(): string;
  8412. /**
  8413. * Update the url (and optional buffer) of this texture if url was null during construction.
  8414. * @param url the url of the texture
  8415. * @param forcedExtension defines the extension to use
  8416. * @param onLoad callback called when the texture is loaded (defaults to null)
  8417. */
  8418. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8419. /**
  8420. * Delays loading of the cube texture
  8421. * @param forcedExtension defines the extension to use
  8422. */
  8423. delayLoad(forcedExtension?: string): void;
  8424. /**
  8425. * Returns the reflection texture matrix
  8426. * @returns the reflection texture matrix
  8427. */
  8428. getReflectionTextureMatrix(): Matrix;
  8429. /**
  8430. * Sets the reflection texture matrix
  8431. * @param value Reflection texture matrix
  8432. */
  8433. setReflectionTextureMatrix(value: Matrix): void;
  8434. /**
  8435. * Parses text to create a cube texture
  8436. * @param parsedTexture define the serialized text to read from
  8437. * @param scene defines the hosting scene
  8438. * @param rootUrl defines the root url of the cube texture
  8439. * @returns a cube texture
  8440. */
  8441. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8442. /**
  8443. * Makes a clone, or deep copy, of the cube texture
  8444. * @returns a new cube texture
  8445. */
  8446. clone(): CubeTexture;
  8447. }
  8448. }
  8449. declare module BABYLON {
  8450. /** @hidden */
  8451. export var postprocessVertexShader: {
  8452. name: string;
  8453. shader: string;
  8454. };
  8455. }
  8456. declare module BABYLON {
  8457. /**
  8458. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8459. * This is the base of the follow, arc rotate cameras and Free camera
  8460. * @see http://doc.babylonjs.com/features/cameras
  8461. */
  8462. export class TargetCamera extends Camera {
  8463. private static _RigCamTransformMatrix;
  8464. private static _TargetTransformMatrix;
  8465. private static _TargetFocalPoint;
  8466. /**
  8467. * Define the current direction the camera is moving to
  8468. */
  8469. cameraDirection: Vector3;
  8470. /**
  8471. * Define the current rotation the camera is rotating to
  8472. */
  8473. cameraRotation: Vector2;
  8474. /**
  8475. * When set, the up vector of the camera will be updated by the rotation of the camera
  8476. */
  8477. updateUpVectorFromRotation: boolean;
  8478. private _tmpQuaternion;
  8479. /**
  8480. * Define the current rotation of the camera
  8481. */
  8482. rotation: Vector3;
  8483. /**
  8484. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8485. */
  8486. rotationQuaternion: Quaternion;
  8487. /**
  8488. * Define the current speed of the camera
  8489. */
  8490. speed: number;
  8491. /**
  8492. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8493. * around all axis.
  8494. */
  8495. noRotationConstraint: boolean;
  8496. /**
  8497. * Define the current target of the camera as an object or a position.
  8498. */
  8499. lockedTarget: any;
  8500. /** @hidden */
  8501. _currentTarget: Vector3;
  8502. /** @hidden */
  8503. _initialFocalDistance: number;
  8504. /** @hidden */
  8505. _viewMatrix: Matrix;
  8506. /** @hidden */
  8507. _camMatrix: Matrix;
  8508. /** @hidden */
  8509. _cameraTransformMatrix: Matrix;
  8510. /** @hidden */
  8511. _cameraRotationMatrix: Matrix;
  8512. /** @hidden */
  8513. _referencePoint: Vector3;
  8514. /** @hidden */
  8515. _transformedReferencePoint: Vector3;
  8516. protected _globalCurrentTarget: Vector3;
  8517. protected _globalCurrentUpVector: Vector3;
  8518. /** @hidden */
  8519. _reset: () => void;
  8520. private _defaultUp;
  8521. /**
  8522. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8523. * This is the base of the follow, arc rotate cameras and Free camera
  8524. * @see http://doc.babylonjs.com/features/cameras
  8525. * @param name Defines the name of the camera in the scene
  8526. * @param position Defines the start position of the camera in the scene
  8527. * @param scene Defines the scene the camera belongs to
  8528. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8529. */
  8530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8531. /**
  8532. * Gets the position in front of the camera at a given distance.
  8533. * @param distance The distance from the camera we want the position to be
  8534. * @returns the position
  8535. */
  8536. getFrontPosition(distance: number): Vector3;
  8537. /** @hidden */
  8538. _getLockedTargetPosition(): Nullable<Vector3>;
  8539. private _storedPosition;
  8540. private _storedRotation;
  8541. private _storedRotationQuaternion;
  8542. /**
  8543. * Store current camera state of the camera (fov, position, rotation, etc..)
  8544. * @returns the camera
  8545. */
  8546. storeState(): Camera;
  8547. /**
  8548. * Restored camera state. You must call storeState() first
  8549. * @returns whether it was successful or not
  8550. * @hidden
  8551. */
  8552. _restoreStateValues(): boolean;
  8553. /** @hidden */
  8554. _initCache(): void;
  8555. /** @hidden */
  8556. _updateCache(ignoreParentClass?: boolean): void;
  8557. /** @hidden */
  8558. _isSynchronizedViewMatrix(): boolean;
  8559. /** @hidden */
  8560. _computeLocalCameraSpeed(): number;
  8561. /**
  8562. * Defines the target the camera should look at.
  8563. * This will automatically adapt alpha beta and radius to fit within the new target.
  8564. * @param target Defines the new target as a Vector or a mesh
  8565. */
  8566. setTarget(target: Vector3): void;
  8567. /**
  8568. * Return the current target position of the camera. This value is expressed in local space.
  8569. * @returns the target position
  8570. */
  8571. getTarget(): Vector3;
  8572. /** @hidden */
  8573. _decideIfNeedsToMove(): boolean;
  8574. /** @hidden */
  8575. _updatePosition(): void;
  8576. /** @hidden */
  8577. _checkInputs(): void;
  8578. protected _updateCameraRotationMatrix(): void;
  8579. /**
  8580. * 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)
  8581. * @returns the current camera
  8582. */
  8583. private _rotateUpVectorWithCameraRotationMatrix;
  8584. private _cachedRotationZ;
  8585. private _cachedQuaternionRotationZ;
  8586. /** @hidden */
  8587. _getViewMatrix(): Matrix;
  8588. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8589. /**
  8590. * @hidden
  8591. */
  8592. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8593. /**
  8594. * @hidden
  8595. */
  8596. _updateRigCameras(): void;
  8597. private _getRigCamPositionAndTarget;
  8598. /**
  8599. * Gets the current object class name.
  8600. * @return the class name
  8601. */
  8602. getClassName(): string;
  8603. }
  8604. }
  8605. declare module BABYLON {
  8606. /**
  8607. * @ignore
  8608. * This is a list of all the different input types that are available in the application.
  8609. * Fo instance: ArcRotateCameraGamepadInput...
  8610. */
  8611. export var CameraInputTypes: {};
  8612. /**
  8613. * This is the contract to implement in order to create a new input class.
  8614. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8615. */
  8616. export interface ICameraInput<TCamera extends Camera> {
  8617. /**
  8618. * Defines the camera the input is attached to.
  8619. */
  8620. camera: Nullable<TCamera>;
  8621. /**
  8622. * Gets the class name of the current intput.
  8623. * @returns the class name
  8624. */
  8625. getClassName(): string;
  8626. /**
  8627. * Get the friendly name associated with the input class.
  8628. * @returns the input friendly name
  8629. */
  8630. getSimpleName(): string;
  8631. /**
  8632. * Attach the input controls to a specific dom element to get the input from.
  8633. * @param element Defines the element the controls should be listened from
  8634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8635. */
  8636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8637. /**
  8638. * Detach the current controls from the specified dom element.
  8639. * @param element Defines the element to stop listening the inputs from
  8640. */
  8641. detachControl(element: Nullable<HTMLElement>): void;
  8642. /**
  8643. * Update the current camera state depending on the inputs that have been used this frame.
  8644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8645. */
  8646. checkInputs?: () => void;
  8647. }
  8648. /**
  8649. * Represents a map of input types to input instance or input index to input instance.
  8650. */
  8651. export interface CameraInputsMap<TCamera extends Camera> {
  8652. /**
  8653. * Accessor to the input by input type.
  8654. */
  8655. [name: string]: ICameraInput<TCamera>;
  8656. /**
  8657. * Accessor to the input by input index.
  8658. */
  8659. [idx: number]: ICameraInput<TCamera>;
  8660. }
  8661. /**
  8662. * This represents the input manager used within a camera.
  8663. * It helps dealing with all the different kind of input attached to a camera.
  8664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8665. */
  8666. export class CameraInputsManager<TCamera extends Camera> {
  8667. /**
  8668. * Defines the list of inputs attahed to the camera.
  8669. */
  8670. attached: CameraInputsMap<TCamera>;
  8671. /**
  8672. * Defines the dom element the camera is collecting inputs from.
  8673. * This is null if the controls have not been attached.
  8674. */
  8675. attachedElement: Nullable<HTMLElement>;
  8676. /**
  8677. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8678. */
  8679. noPreventDefault: boolean;
  8680. /**
  8681. * Defined the camera the input manager belongs to.
  8682. */
  8683. camera: TCamera;
  8684. /**
  8685. * Update the current camera state depending on the inputs that have been used this frame.
  8686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8687. */
  8688. checkInputs: () => void;
  8689. /**
  8690. * Instantiate a new Camera Input Manager.
  8691. * @param camera Defines the camera the input manager blongs to
  8692. */
  8693. constructor(camera: TCamera);
  8694. /**
  8695. * Add an input method to a camera
  8696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8697. * @param input camera input method
  8698. */
  8699. add(input: ICameraInput<TCamera>): void;
  8700. /**
  8701. * Remove a specific input method from a camera
  8702. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8703. * @param inputToRemove camera input method
  8704. */
  8705. remove(inputToRemove: ICameraInput<TCamera>): void;
  8706. /**
  8707. * Remove a specific input type from a camera
  8708. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8709. * @param inputType the type of the input to remove
  8710. */
  8711. removeByType(inputType: string): void;
  8712. private _addCheckInputs;
  8713. /**
  8714. * Attach the input controls to the currently attached dom element to listen the events from.
  8715. * @param input Defines the input to attach
  8716. */
  8717. attachInput(input: ICameraInput<TCamera>): void;
  8718. /**
  8719. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8720. * @param element Defines the dom element to collect the events from
  8721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8722. */
  8723. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8724. /**
  8725. * Detach the current manager inputs controls from a specific dom element.
  8726. * @param element Defines the dom element to collect the events from
  8727. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8728. */
  8729. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8730. /**
  8731. * Rebuild the dynamic inputCheck function from the current list of
  8732. * defined inputs in the manager.
  8733. */
  8734. rebuildInputCheck(): void;
  8735. /**
  8736. * Remove all attached input methods from a camera
  8737. */
  8738. clear(): void;
  8739. /**
  8740. * Serialize the current input manager attached to a camera.
  8741. * This ensures than once parsed,
  8742. * the input associated to the camera will be identical to the current ones
  8743. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8744. */
  8745. serialize(serializedCamera: any): void;
  8746. /**
  8747. * Parses an input manager serialized JSON to restore the previous list of inputs
  8748. * and states associated to a camera.
  8749. * @param parsedCamera Defines the JSON to parse
  8750. */
  8751. parse(parsedCamera: any): void;
  8752. }
  8753. }
  8754. declare module BABYLON {
  8755. /**
  8756. * Gather the list of keyboard event types as constants.
  8757. */
  8758. export class KeyboardEventTypes {
  8759. /**
  8760. * The keydown event is fired when a key becomes active (pressed).
  8761. */
  8762. static readonly KEYDOWN: number;
  8763. /**
  8764. * The keyup event is fired when a key has been released.
  8765. */
  8766. static readonly KEYUP: number;
  8767. }
  8768. /**
  8769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8770. */
  8771. export class KeyboardInfo {
  8772. /**
  8773. * Defines the type of event (KeyboardEventTypes)
  8774. */
  8775. type: number;
  8776. /**
  8777. * Defines the related dom event
  8778. */
  8779. event: KeyboardEvent;
  8780. /**
  8781. * Instantiates a new keyboard info.
  8782. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8783. * @param type Defines the type of event (KeyboardEventTypes)
  8784. * @param event Defines the related dom event
  8785. */
  8786. constructor(
  8787. /**
  8788. * Defines the type of event (KeyboardEventTypes)
  8789. */
  8790. type: number,
  8791. /**
  8792. * Defines the related dom event
  8793. */
  8794. event: KeyboardEvent);
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8798. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8799. */
  8800. export class KeyboardInfoPre extends KeyboardInfo {
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number;
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent;
  8809. /**
  8810. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8811. */
  8812. skipOnPointerObservable: boolean;
  8813. /**
  8814. * Instantiates a new keyboard pre info.
  8815. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. }
  8830. declare module BABYLON {
  8831. /**
  8832. * Manage the keyboard inputs to control the movement of a free camera.
  8833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8834. */
  8835. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8836. /**
  8837. * Defines the camera the input is attached to.
  8838. */
  8839. camera: FreeCamera;
  8840. /**
  8841. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8842. */
  8843. keysUp: number[];
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8846. */
  8847. keysDown: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8850. */
  8851. keysLeft: number[];
  8852. /**
  8853. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8854. */
  8855. keysRight: number[];
  8856. private _keys;
  8857. private _onCanvasBlurObserver;
  8858. private _onKeyboardObserver;
  8859. private _engine;
  8860. private _scene;
  8861. /**
  8862. * Attach the input controls to a specific dom element to get the input from.
  8863. * @param element Defines the element the controls should be listened from
  8864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8865. */
  8866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8867. /**
  8868. * Detach the current controls from the specified dom element.
  8869. * @param element Defines the element to stop listening the inputs from
  8870. */
  8871. detachControl(element: Nullable<HTMLElement>): void;
  8872. /**
  8873. * Update the current camera state depending on the inputs that have been used this frame.
  8874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8875. */
  8876. checkInputs(): void;
  8877. /**
  8878. * Gets the class name of the current intput.
  8879. * @returns the class name
  8880. */
  8881. getClassName(): string;
  8882. /** @hidden */
  8883. _onLostFocus(): void;
  8884. /**
  8885. * Get the friendly name associated with the input class.
  8886. * @returns the input friendly name
  8887. */
  8888. getSimpleName(): string;
  8889. }
  8890. }
  8891. declare module BABYLON {
  8892. /**
  8893. * Interface describing all the common properties and methods a shadow light needs to implement.
  8894. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8895. * as well as binding the different shadow properties to the effects.
  8896. */
  8897. export interface IShadowLight extends Light {
  8898. /**
  8899. * The light id in the scene (used in scene.findLighById for instance)
  8900. */
  8901. id: string;
  8902. /**
  8903. * The position the shdow will be casted from.
  8904. */
  8905. position: Vector3;
  8906. /**
  8907. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8908. */
  8909. direction: Vector3;
  8910. /**
  8911. * The transformed position. Position of the light in world space taking parenting in account.
  8912. */
  8913. transformedPosition: Vector3;
  8914. /**
  8915. * The transformed direction. Direction of the light in world space taking parenting in account.
  8916. */
  8917. transformedDirection: Vector3;
  8918. /**
  8919. * The friendly name of the light in the scene.
  8920. */
  8921. name: string;
  8922. /**
  8923. * Defines the shadow projection clipping minimum z value.
  8924. */
  8925. shadowMinZ: number;
  8926. /**
  8927. * Defines the shadow projection clipping maximum z value.
  8928. */
  8929. shadowMaxZ: number;
  8930. /**
  8931. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8932. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8933. */
  8934. computeTransformedInformation(): boolean;
  8935. /**
  8936. * Gets the scene the light belongs to.
  8937. * @returns The scene
  8938. */
  8939. getScene(): Scene;
  8940. /**
  8941. * Callback defining a custom Projection Matrix Builder.
  8942. * This can be used to override the default projection matrix computation.
  8943. */
  8944. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8945. /**
  8946. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8947. * @param matrix The materix to updated with the projection information
  8948. * @param viewMatrix The transform matrix of the light
  8949. * @param renderList The list of mesh to render in the map
  8950. * @returns The current light
  8951. */
  8952. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8953. /**
  8954. * Gets the current depth scale used in ESM.
  8955. * @returns The scale
  8956. */
  8957. getDepthScale(): number;
  8958. /**
  8959. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8960. * @returns true if a cube texture needs to be use
  8961. */
  8962. needCube(): boolean;
  8963. /**
  8964. * Detects if the projection matrix requires to be recomputed this frame.
  8965. * @returns true if it requires to be recomputed otherwise, false.
  8966. */
  8967. needProjectionMatrixCompute(): boolean;
  8968. /**
  8969. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8970. */
  8971. forceProjectionMatrixCompute(): void;
  8972. /**
  8973. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8974. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8975. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8976. */
  8977. getShadowDirection(faceIndex?: number): Vector3;
  8978. /**
  8979. * Gets the minZ used for shadow according to both the scene and the light.
  8980. * @param activeCamera The camera we are returning the min for
  8981. * @returns the depth min z
  8982. */
  8983. getDepthMinZ(activeCamera: Camera): number;
  8984. /**
  8985. * Gets the maxZ used for shadow according to both the scene and the light.
  8986. * @param activeCamera The camera we are returning the max for
  8987. * @returns the depth max z
  8988. */
  8989. getDepthMaxZ(activeCamera: Camera): number;
  8990. }
  8991. /**
  8992. * Base implementation IShadowLight
  8993. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8994. */
  8995. export abstract class ShadowLight extends Light implements IShadowLight {
  8996. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8997. protected _position: Vector3;
  8998. protected _setPosition(value: Vector3): void;
  8999. /**
  9000. * Sets the position the shadow will be casted from. Also use as the light position for both
  9001. * point and spot lights.
  9002. */
  9003. /**
  9004. * Sets the position the shadow will be casted from. Also use as the light position for both
  9005. * point and spot lights.
  9006. */
  9007. position: Vector3;
  9008. protected _direction: Vector3;
  9009. protected _setDirection(value: Vector3): void;
  9010. /**
  9011. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9012. * Also use as the light direction on spot and directional lights.
  9013. */
  9014. /**
  9015. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9016. * Also use as the light direction on spot and directional lights.
  9017. */
  9018. direction: Vector3;
  9019. private _shadowMinZ;
  9020. /**
  9021. * Gets the shadow projection clipping minimum z value.
  9022. */
  9023. /**
  9024. * Sets the shadow projection clipping minimum z value.
  9025. */
  9026. shadowMinZ: number;
  9027. private _shadowMaxZ;
  9028. /**
  9029. * Sets the shadow projection clipping maximum z value.
  9030. */
  9031. /**
  9032. * Gets the shadow projection clipping maximum z value.
  9033. */
  9034. shadowMaxZ: number;
  9035. /**
  9036. * Callback defining a custom Projection Matrix Builder.
  9037. * This can be used to override the default projection matrix computation.
  9038. */
  9039. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9040. /**
  9041. * The transformed position. Position of the light in world space taking parenting in account.
  9042. */
  9043. transformedPosition: Vector3;
  9044. /**
  9045. * The transformed direction. Direction of the light in world space taking parenting in account.
  9046. */
  9047. transformedDirection: Vector3;
  9048. private _needProjectionMatrixCompute;
  9049. /**
  9050. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9051. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9052. */
  9053. computeTransformedInformation(): boolean;
  9054. /**
  9055. * Return the depth scale used for the shadow map.
  9056. * @returns the depth scale.
  9057. */
  9058. getDepthScale(): number;
  9059. /**
  9060. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9063. */
  9064. getShadowDirection(faceIndex?: number): Vector3;
  9065. /**
  9066. * Returns the ShadowLight absolute position in the World.
  9067. * @returns the position vector in world space
  9068. */
  9069. getAbsolutePosition(): Vector3;
  9070. /**
  9071. * Sets the ShadowLight direction toward the passed target.
  9072. * @param target The point to target in local space
  9073. * @returns the updated ShadowLight direction
  9074. */
  9075. setDirectionToTarget(target: Vector3): Vector3;
  9076. /**
  9077. * Returns the light rotation in euler definition.
  9078. * @returns the x y z rotation in local space.
  9079. */
  9080. getRotation(): Vector3;
  9081. /**
  9082. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9083. * @returns true if a cube texture needs to be use
  9084. */
  9085. needCube(): boolean;
  9086. /**
  9087. * Detects if the projection matrix requires to be recomputed this frame.
  9088. * @returns true if it requires to be recomputed otherwise, false.
  9089. */
  9090. needProjectionMatrixCompute(): boolean;
  9091. /**
  9092. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9093. */
  9094. forceProjectionMatrixCompute(): void;
  9095. /** @hidden */
  9096. _initCache(): void;
  9097. /** @hidden */
  9098. _isSynchronized(): boolean;
  9099. /**
  9100. * Computes the world matrix of the node
  9101. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9102. * @returns the world matrix
  9103. */
  9104. computeWorldMatrix(force?: boolean): Matrix;
  9105. /**
  9106. * Gets the minZ used for shadow according to both the scene and the light.
  9107. * @param activeCamera The camera we are returning the min for
  9108. * @returns the depth min z
  9109. */
  9110. getDepthMinZ(activeCamera: Camera): number;
  9111. /**
  9112. * Gets the maxZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the max for
  9114. * @returns the depth max z
  9115. */
  9116. getDepthMaxZ(activeCamera: Camera): number;
  9117. /**
  9118. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9119. * @param matrix The materix to updated with the projection information
  9120. * @param viewMatrix The transform matrix of the light
  9121. * @param renderList The list of mesh to render in the map
  9122. * @returns The current light
  9123. */
  9124. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9125. }
  9126. }
  9127. declare module BABYLON {
  9128. /**
  9129. * "Static Class" containing the most commonly used helper while dealing with material for
  9130. * rendering purpose.
  9131. *
  9132. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9133. *
  9134. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9135. */
  9136. export class MaterialHelper {
  9137. /**
  9138. * Bind the current view position to an effect.
  9139. * @param effect The effect to be bound
  9140. * @param scene The scene the eyes position is used from
  9141. */
  9142. static BindEyePosition(effect: Effect, scene: Scene): void;
  9143. /**
  9144. * Helps preparing the defines values about the UVs in used in the effect.
  9145. * UVs are shared as much as we can accross channels in the shaders.
  9146. * @param texture The texture we are preparing the UVs for
  9147. * @param defines The defines to update
  9148. * @param key The channel key "diffuse", "specular"... used in the shader
  9149. */
  9150. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9151. /**
  9152. * Binds a texture matrix value to its corrsponding uniform
  9153. * @param texture The texture to bind the matrix for
  9154. * @param uniformBuffer The uniform buffer receivin the data
  9155. * @param key The channel key "diffuse", "specular"... used in the shader
  9156. */
  9157. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9158. /**
  9159. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9160. * @param mesh defines the current mesh
  9161. * @param scene defines the current scene
  9162. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9163. * @param pointsCloud defines if point cloud rendering has to be turned on
  9164. * @param fogEnabled defines if fog has to be turned on
  9165. * @param alphaTest defines if alpha testing has to be turned on
  9166. * @param defines defines the current list of defines
  9167. */
  9168. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9169. /**
  9170. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9171. * @param scene defines the current scene
  9172. * @param engine defines the current engine
  9173. * @param defines specifies the list of active defines
  9174. * @param useInstances defines if instances have to be turned on
  9175. * @param useClipPlane defines if clip plane have to be turned on
  9176. */
  9177. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9178. /**
  9179. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9180. * @param mesh The mesh containing the geometry data we will draw
  9181. * @param defines The defines to update
  9182. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9183. * @param useBones Precise whether bones should be used or not (override mesh info)
  9184. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9185. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9186. * @returns false if defines are considered not dirty and have not been checked
  9187. */
  9188. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9189. /**
  9190. * Prepares the defines related to multiview
  9191. * @param scene The scene we are intending to draw
  9192. * @param defines The defines to update
  9193. */
  9194. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param defines The defines to update
  9200. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9201. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9202. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9203. * @returns true if normals will be required for the rest of the effect
  9204. */
  9205. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9206. /**
  9207. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9208. * that won t be acctive due to defines being turned off.
  9209. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9210. * @param samplersList The samplers list
  9211. * @param defines The defines helping in the list generation
  9212. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9213. */
  9214. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9215. /**
  9216. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9217. * @param defines The defines to update while falling back
  9218. * @param fallbacks The authorized effect fallbacks
  9219. * @param maxSimultaneousLights The maximum number of lights allowed
  9220. * @param rank the current rank of the Effect
  9221. * @returns The newly affected rank
  9222. */
  9223. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9224. /**
  9225. * Prepares the list of attributes required for morph targets according to the effect defines.
  9226. * @param attribs The current list of supported attribs
  9227. * @param mesh The mesh to prepare the morph targets attributes for
  9228. * @param defines The current Defines of the effect
  9229. */
  9230. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9231. /**
  9232. * Prepares the list of attributes required for bones according to the effect defines.
  9233. * @param attribs The current list of supported attribs
  9234. * @param mesh The mesh to prepare the bones attributes for
  9235. * @param defines The current Defines of the effect
  9236. * @param fallbacks The current efffect fallback strategy
  9237. */
  9238. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9239. /**
  9240. * Prepares the list of attributes required for instances according to the effect defines.
  9241. * @param attribs The current list of supported attribs
  9242. * @param defines The current Defines of the effect
  9243. */
  9244. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9245. /**
  9246. * Binds the light shadow information to the effect for the given mesh.
  9247. * @param light The light containing the generator
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param lightIndex The light index in the effect used to render the mesh
  9251. * @param effect The effect we are binding the data to
  9252. */
  9253. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9254. /**
  9255. * Binds the light information to the effect.
  9256. * @param light The light containing the generator
  9257. * @param effect The effect we are binding the data to
  9258. * @param lightIndex The light index in the effect used to render
  9259. */
  9260. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9261. /**
  9262. * Binds the lights information from the scene to the effect for the given mesh.
  9263. * @param scene The scene the lights belongs to
  9264. * @param mesh The mesh we are binding the information to render
  9265. * @param effect The effect we are binding the data to
  9266. * @param defines The generated defines for the effect
  9267. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9268. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9269. */
  9270. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9271. private static _tempFogColor;
  9272. /**
  9273. * Binds the fog information from the scene to the effect for the given mesh.
  9274. * @param scene The scene the lights belongs to
  9275. * @param mesh The mesh we are binding the information to render
  9276. * @param effect The effect we are binding the data to
  9277. * @param linearSpace Defines if the fog effect is applied in linear space
  9278. */
  9279. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9280. /**
  9281. * Binds the bones information from the mesh to the effect.
  9282. * @param mesh The mesh we are binding the information to render
  9283. * @param effect The effect we are binding the data to
  9284. */
  9285. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9286. /**
  9287. * Binds the morph targets information from the mesh to the effect.
  9288. * @param abstractMesh The mesh we are binding the information to render
  9289. * @param effect The effect we are binding the data to
  9290. */
  9291. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9292. /**
  9293. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9294. * @param defines The generated defines used in the effect
  9295. * @param effect The effect we are binding the data to
  9296. * @param scene The scene we are willing to render with logarithmic scale for
  9297. */
  9298. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9299. /**
  9300. * Binds the clip plane information from the scene to the effect.
  9301. * @param scene The scene the clip plane information are extracted from
  9302. * @param effect The effect we are binding the data to
  9303. */
  9304. static BindClipPlane(effect: Effect, scene: Scene): void;
  9305. }
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var kernelBlurVaryingDeclaration: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var kernelBlurFragment: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var kernelBlurFragment2: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var kernelBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var kernelBlurVertex: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var kernelBlurVertexShader: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /**
  9351. * The Blur Post Process which blurs an image based on a kernel and direction.
  9352. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9353. */
  9354. export class BlurPostProcess extends PostProcess {
  9355. /** The direction in which to blur the image. */
  9356. direction: Vector2;
  9357. private blockCompilation;
  9358. protected _kernel: number;
  9359. protected _idealKernel: number;
  9360. protected _packedFloat: boolean;
  9361. private _staticDefines;
  9362. /**
  9363. * Sets the length in pixels of the blur sample region
  9364. */
  9365. /**
  9366. * Gets the length in pixels of the blur sample region
  9367. */
  9368. kernel: number;
  9369. /**
  9370. * Sets wether or not the blur needs to unpack/repack floats
  9371. */
  9372. /**
  9373. * Gets wether or not the blur is unpacking/repacking floats
  9374. */
  9375. packedFloat: boolean;
  9376. /**
  9377. * Creates a new instance BlurPostProcess
  9378. * @param name The name of the effect.
  9379. * @param direction The direction in which to blur the image.
  9380. * @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.
  9381. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9382. * @param camera The camera to apply the render pass to.
  9383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9384. * @param engine The engine which the post process will be applied. (default: current engine)
  9385. * @param reusable If the post process can be reused on the same frame. (default: false)
  9386. * @param textureType Type of textures used when performing the post process. (default: 0)
  9387. * @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)
  9388. */
  9389. constructor(name: string,
  9390. /** The direction in which to blur the image. */
  9391. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9392. /**
  9393. * Updates the effect with the current post process compile time values and recompiles the shader.
  9394. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9395. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9396. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9397. * @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
  9398. * @param onCompiled Called when the shader has been compiled.
  9399. * @param onError Called if there is an error when compiling a shader.
  9400. */
  9401. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9402. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9403. /**
  9404. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9405. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9406. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9407. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9408. * The gaps between physical kernels are compensated for in the weighting of the samples
  9409. * @param idealKernel Ideal blur kernel.
  9410. * @return Nearest best kernel.
  9411. */
  9412. protected _nearestBestKernel(idealKernel: number): number;
  9413. /**
  9414. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9415. * @param x The point on the Gaussian distribution to sample.
  9416. * @return the value of the Gaussian function at x.
  9417. */
  9418. protected _gaussianWeight(x: number): number;
  9419. /**
  9420. * Generates a string that can be used as a floating point number in GLSL.
  9421. * @param x Value to print.
  9422. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9423. * @return GLSL float string.
  9424. */
  9425. protected _glslFloat(x: number, decimalFigures?: number): string;
  9426. }
  9427. }
  9428. declare module BABYLON {
  9429. /** @hidden */
  9430. export var shadowMapPixelShader: {
  9431. name: string;
  9432. shader: string;
  9433. };
  9434. }
  9435. declare module BABYLON {
  9436. /** @hidden */
  9437. export var bonesDeclaration: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module BABYLON {
  9443. /** @hidden */
  9444. export var morphTargetsVertexGlobalDeclaration: {
  9445. name: string;
  9446. shader: string;
  9447. };
  9448. }
  9449. declare module BABYLON {
  9450. /** @hidden */
  9451. export var morphTargetsVertexDeclaration: {
  9452. name: string;
  9453. shader: string;
  9454. };
  9455. }
  9456. declare module BABYLON {
  9457. /** @hidden */
  9458. export var instancesDeclaration: {
  9459. name: string;
  9460. shader: string;
  9461. };
  9462. }
  9463. declare module BABYLON {
  9464. /** @hidden */
  9465. export var helperFunctions: {
  9466. name: string;
  9467. shader: string;
  9468. };
  9469. }
  9470. declare module BABYLON {
  9471. /** @hidden */
  9472. export var morphTargetsVertex: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module BABYLON {
  9478. /** @hidden */
  9479. export var instancesVertex: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var bonesVertex: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var shadowMapVertexShader: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var depthBoxBlurPixelShader: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /**
  9507. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9508. */
  9509. export interface ICustomShaderOptions {
  9510. /**
  9511. * Gets or sets the custom shader name to use
  9512. */
  9513. shaderName: string;
  9514. /**
  9515. * The list of attribute names used in the shader
  9516. */
  9517. attributes?: string[];
  9518. /**
  9519. * The list of unifrom names used in the shader
  9520. */
  9521. uniforms?: string[];
  9522. /**
  9523. * The list of sampler names used in the shader
  9524. */
  9525. samplers?: string[];
  9526. /**
  9527. * The list of defines used in the shader
  9528. */
  9529. defines?: string[];
  9530. }
  9531. /**
  9532. * Interface to implement to create a shadow generator compatible with BJS.
  9533. */
  9534. export interface IShadowGenerator {
  9535. /**
  9536. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9537. * @returns The render target texture if present otherwise, null
  9538. */
  9539. getShadowMap(): Nullable<RenderTargetTexture>;
  9540. /**
  9541. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9542. * @returns The render target texture if the shadow map is present otherwise, null
  9543. */
  9544. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9545. /**
  9546. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9547. * @param subMesh The submesh we want to render in the shadow map
  9548. * @param useInstances Defines wether will draw in the map using instances
  9549. * @returns true if ready otherwise, false
  9550. */
  9551. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9552. /**
  9553. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9554. * @param defines Defines of the material we want to update
  9555. * @param lightIndex Index of the light in the enabled light list of the material
  9556. */
  9557. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9558. /**
  9559. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9560. * defined in the generator but impacting the effect).
  9561. * It implies the unifroms available on the materials are the standard BJS ones.
  9562. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9563. * @param effect The effect we are binfing the information for
  9564. */
  9565. bindShadowLight(lightIndex: string, effect: Effect): void;
  9566. /**
  9567. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9568. * (eq to shadow prjection matrix * light transform matrix)
  9569. * @returns The transform matrix used to create the shadow map
  9570. */
  9571. getTransformMatrix(): Matrix;
  9572. /**
  9573. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9574. * Cube and 2D textures for instance.
  9575. */
  9576. recreateShadowMap(): void;
  9577. /**
  9578. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9579. * @param onCompiled Callback triggered at the and of the effects compilation
  9580. * @param options Sets of optional options forcing the compilation with different modes
  9581. */
  9582. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9583. useInstances: boolean;
  9584. }>): void;
  9585. /**
  9586. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9587. * @param options Sets of optional options forcing the compilation with different modes
  9588. * @returns A promise that resolves when the compilation completes
  9589. */
  9590. forceCompilationAsync(options?: Partial<{
  9591. useInstances: boolean;
  9592. }>): Promise<void>;
  9593. /**
  9594. * Serializes the shadow generator setup to a json object.
  9595. * @returns The serialized JSON object
  9596. */
  9597. serialize(): any;
  9598. /**
  9599. * Disposes the Shadow map and related Textures and effects.
  9600. */
  9601. dispose(): void;
  9602. }
  9603. /**
  9604. * Default implementation IShadowGenerator.
  9605. * This is the main object responsible of generating shadows in the framework.
  9606. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9607. */
  9608. export class ShadowGenerator implements IShadowGenerator {
  9609. /**
  9610. * Shadow generator mode None: no filtering applied.
  9611. */
  9612. static readonly FILTER_NONE: number;
  9613. /**
  9614. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9615. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9616. */
  9617. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9618. /**
  9619. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9620. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9621. */
  9622. static readonly FILTER_POISSONSAMPLING: number;
  9623. /**
  9624. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9625. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9626. */
  9627. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9628. /**
  9629. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9630. * edge artifacts on steep falloff.
  9631. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9632. */
  9633. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9634. /**
  9635. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9636. * edge artifacts on steep falloff.
  9637. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9638. */
  9639. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9640. /**
  9641. * Shadow generator mode PCF: Percentage Closer Filtering
  9642. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9643. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9644. */
  9645. static readonly FILTER_PCF: number;
  9646. /**
  9647. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9648. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9649. * Contact Hardening
  9650. */
  9651. static readonly FILTER_PCSS: number;
  9652. /**
  9653. * Reserved for PCF and PCSS
  9654. * Highest Quality.
  9655. *
  9656. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9657. *
  9658. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9659. */
  9660. static readonly QUALITY_HIGH: number;
  9661. /**
  9662. * Reserved for PCF and PCSS
  9663. * Good tradeoff for quality/perf cross devices
  9664. *
  9665. * Execute PCF on a 3*3 kernel.
  9666. *
  9667. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9668. */
  9669. static readonly QUALITY_MEDIUM: number;
  9670. /**
  9671. * Reserved for PCF and PCSS
  9672. * The lowest quality but the fastest.
  9673. *
  9674. * Execute PCF on a 1*1 kernel.
  9675. *
  9676. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9677. */
  9678. static readonly QUALITY_LOW: number;
  9679. /** Gets or sets the custom shader name to use */
  9680. customShaderOptions: ICustomShaderOptions;
  9681. /**
  9682. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9683. */
  9684. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9685. /**
  9686. * Observable triggered before a mesh is rendered in the shadow map.
  9687. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9688. */
  9689. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9690. private _bias;
  9691. /**
  9692. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9693. */
  9694. /**
  9695. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9696. */
  9697. bias: number;
  9698. private _normalBias;
  9699. /**
  9700. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9701. */
  9702. /**
  9703. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9704. */
  9705. normalBias: number;
  9706. private _blurBoxOffset;
  9707. /**
  9708. * Gets the blur box offset: offset applied during the blur pass.
  9709. * Only useful if useKernelBlur = false
  9710. */
  9711. /**
  9712. * Sets the blur box offset: offset applied during the blur pass.
  9713. * Only useful if useKernelBlur = false
  9714. */
  9715. blurBoxOffset: number;
  9716. private _blurScale;
  9717. /**
  9718. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9719. * 2 means half of the size.
  9720. */
  9721. /**
  9722. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9723. * 2 means half of the size.
  9724. */
  9725. blurScale: number;
  9726. private _blurKernel;
  9727. /**
  9728. * Gets the blur kernel: kernel size of the blur pass.
  9729. * Only useful if useKernelBlur = true
  9730. */
  9731. /**
  9732. * Sets the blur kernel: kernel size of the blur pass.
  9733. * Only useful if useKernelBlur = true
  9734. */
  9735. blurKernel: number;
  9736. private _useKernelBlur;
  9737. /**
  9738. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9739. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9740. */
  9741. /**
  9742. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9743. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9744. */
  9745. useKernelBlur: boolean;
  9746. private _depthScale;
  9747. /**
  9748. * Gets the depth scale used in ESM mode.
  9749. */
  9750. /**
  9751. * Sets the depth scale used in ESM mode.
  9752. * This can override the scale stored on the light.
  9753. */
  9754. depthScale: number;
  9755. private _filter;
  9756. /**
  9757. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9758. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9759. */
  9760. /**
  9761. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9762. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9763. */
  9764. filter: number;
  9765. /**
  9766. * Gets if the current filter is set to Poisson Sampling.
  9767. */
  9768. /**
  9769. * Sets the current filter to Poisson Sampling.
  9770. */
  9771. usePoissonSampling: boolean;
  9772. /**
  9773. * Gets if the current filter is set to ESM.
  9774. */
  9775. /**
  9776. * Sets the current filter is to ESM.
  9777. */
  9778. useExponentialShadowMap: boolean;
  9779. /**
  9780. * Gets if the current filter is set to filtered ESM.
  9781. */
  9782. /**
  9783. * Gets if the current filter is set to filtered ESM.
  9784. */
  9785. useBlurExponentialShadowMap: boolean;
  9786. /**
  9787. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9788. * exponential to prevent steep falloff artifacts).
  9789. */
  9790. /**
  9791. * Sets the current filter to "close ESM" (using the inverse of the
  9792. * exponential to prevent steep falloff artifacts).
  9793. */
  9794. useCloseExponentialShadowMap: boolean;
  9795. /**
  9796. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9797. * exponential to prevent steep falloff artifacts).
  9798. */
  9799. /**
  9800. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9801. * exponential to prevent steep falloff artifacts).
  9802. */
  9803. useBlurCloseExponentialShadowMap: boolean;
  9804. /**
  9805. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9806. */
  9807. /**
  9808. * Sets the current filter to "PCF" (percentage closer filtering).
  9809. */
  9810. usePercentageCloserFiltering: boolean;
  9811. private _filteringQuality;
  9812. /**
  9813. * Gets the PCF or PCSS Quality.
  9814. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9815. */
  9816. /**
  9817. * Sets the PCF or PCSS Quality.
  9818. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9819. */
  9820. filteringQuality: number;
  9821. /**
  9822. * Gets if the current filter is set to "PCSS" (contact hardening).
  9823. */
  9824. /**
  9825. * Sets the current filter to "PCSS" (contact hardening).
  9826. */
  9827. useContactHardeningShadow: boolean;
  9828. private _contactHardeningLightSizeUVRatio;
  9829. /**
  9830. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9831. * Using a ratio helps keeping shape stability independently of the map size.
  9832. *
  9833. * It does not account for the light projection as it was having too much
  9834. * instability during the light setup or during light position changes.
  9835. *
  9836. * Only valid if useContactHardeningShadow is true.
  9837. */
  9838. /**
  9839. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9840. * Using a ratio helps keeping shape stability independently of the map size.
  9841. *
  9842. * It does not account for the light projection as it was having too much
  9843. * instability during the light setup or during light position changes.
  9844. *
  9845. * Only valid if useContactHardeningShadow is true.
  9846. */
  9847. contactHardeningLightSizeUVRatio: number;
  9848. private _darkness;
  9849. /**
  9850. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9851. * 0 means strongest and 1 would means no shadow.
  9852. * @returns the darkness.
  9853. */
  9854. getDarkness(): number;
  9855. /**
  9856. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9857. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9858. * @returns the shadow generator allowing fluent coding.
  9859. */
  9860. setDarkness(darkness: number): ShadowGenerator;
  9861. private _transparencyShadow;
  9862. /**
  9863. * Sets the ability to have transparent shadow (boolean).
  9864. * @param transparent True if transparent else False
  9865. * @returns the shadow generator allowing fluent coding
  9866. */
  9867. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9868. private _shadowMap;
  9869. private _shadowMap2;
  9870. /**
  9871. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9872. * @returns The render target texture if present otherwise, null
  9873. */
  9874. getShadowMap(): Nullable<RenderTargetTexture>;
  9875. /**
  9876. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9877. * @returns The render target texture if the shadow map is present otherwise, null
  9878. */
  9879. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9880. /**
  9881. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9882. * @param mesh Mesh to add
  9883. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9884. * @returns the Shadow Generator itself
  9885. */
  9886. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9887. /**
  9888. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9889. * @param mesh Mesh to remove
  9890. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9891. * @returns the Shadow Generator itself
  9892. */
  9893. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9894. /**
  9895. * Controls the extent to which the shadows fade out at the edge of the frustum
  9896. * Used only by directionals and spots
  9897. */
  9898. frustumEdgeFalloff: number;
  9899. private _light;
  9900. /**
  9901. * Returns the associated light object.
  9902. * @returns the light generating the shadow
  9903. */
  9904. getLight(): IShadowLight;
  9905. /**
  9906. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9907. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9908. * It might on the other hand introduce peter panning.
  9909. */
  9910. forceBackFacesOnly: boolean;
  9911. private _scene;
  9912. private _lightDirection;
  9913. private _effect;
  9914. private _viewMatrix;
  9915. private _projectionMatrix;
  9916. private _transformMatrix;
  9917. private _cachedPosition;
  9918. private _cachedDirection;
  9919. private _cachedDefines;
  9920. private _currentRenderID;
  9921. private _boxBlurPostprocess;
  9922. private _kernelBlurXPostprocess;
  9923. private _kernelBlurYPostprocess;
  9924. private _blurPostProcesses;
  9925. private _mapSize;
  9926. private _currentFaceIndex;
  9927. private _currentFaceIndexCache;
  9928. private _textureType;
  9929. private _defaultTextureMatrix;
  9930. /** @hidden */
  9931. static _SceneComponentInitialization: (scene: Scene) => void;
  9932. /**
  9933. * Creates a ShadowGenerator object.
  9934. * A ShadowGenerator is the required tool to use the shadows.
  9935. * Each light casting shadows needs to use its own ShadowGenerator.
  9936. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9937. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9938. * @param light The light object generating the shadows.
  9939. * @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.
  9940. */
  9941. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9942. private _initializeGenerator;
  9943. private _initializeShadowMap;
  9944. private _initializeBlurRTTAndPostProcesses;
  9945. private _renderForShadowMap;
  9946. private _renderSubMeshForShadowMap;
  9947. private _applyFilterValues;
  9948. /**
  9949. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9950. * @param onCompiled Callback triggered at the and of the effects compilation
  9951. * @param options Sets of optional options forcing the compilation with different modes
  9952. */
  9953. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9954. useInstances: boolean;
  9955. }>): void;
  9956. /**
  9957. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9958. * @param options Sets of optional options forcing the compilation with different modes
  9959. * @returns A promise that resolves when the compilation completes
  9960. */
  9961. forceCompilationAsync(options?: Partial<{
  9962. useInstances: boolean;
  9963. }>): Promise<void>;
  9964. /**
  9965. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9966. * @param subMesh The submesh we want to render in the shadow map
  9967. * @param useInstances Defines wether will draw in the map using instances
  9968. * @returns true if ready otherwise, false
  9969. */
  9970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9971. /**
  9972. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9973. * @param defines Defines of the material we want to update
  9974. * @param lightIndex Index of the light in the enabled light list of the material
  9975. */
  9976. prepareDefines(defines: any, lightIndex: number): void;
  9977. /**
  9978. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9979. * defined in the generator but impacting the effect).
  9980. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9981. * @param effect The effect we are binfing the information for
  9982. */
  9983. bindShadowLight(lightIndex: string, effect: Effect): void;
  9984. /**
  9985. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9986. * (eq to shadow prjection matrix * light transform matrix)
  9987. * @returns The transform matrix used to create the shadow map
  9988. */
  9989. getTransformMatrix(): Matrix;
  9990. /**
  9991. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9992. * Cube and 2D textures for instance.
  9993. */
  9994. recreateShadowMap(): void;
  9995. private _disposeBlurPostProcesses;
  9996. private _disposeRTTandPostProcesses;
  9997. /**
  9998. * Disposes the ShadowGenerator.
  9999. * Returns nothing.
  10000. */
  10001. dispose(): void;
  10002. /**
  10003. * Serializes the shadow generator setup to a json object.
  10004. * @returns The serialized JSON object
  10005. */
  10006. serialize(): any;
  10007. /**
  10008. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10009. * @param parsedShadowGenerator The JSON object to parse
  10010. * @param scene The scene to create the shadow map for
  10011. * @returns The parsed shadow generator
  10012. */
  10013. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10014. }
  10015. }
  10016. declare module BABYLON {
  10017. /**
  10018. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10019. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10020. * 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.
  10021. */
  10022. export abstract class Light extends Node {
  10023. /**
  10024. * Falloff Default: light is falling off following the material specification:
  10025. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10026. */
  10027. static readonly FALLOFF_DEFAULT: number;
  10028. /**
  10029. * Falloff Physical: light is falling off following the inverse squared distance law.
  10030. */
  10031. static readonly FALLOFF_PHYSICAL: number;
  10032. /**
  10033. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10034. * to enhance interoperability with other engines.
  10035. */
  10036. static readonly FALLOFF_GLTF: number;
  10037. /**
  10038. * Falloff Standard: light is falling off like in the standard material
  10039. * to enhance interoperability with other materials.
  10040. */
  10041. static readonly FALLOFF_STANDARD: number;
  10042. /**
  10043. * If every light affecting the material is in this lightmapMode,
  10044. * material.lightmapTexture adds or multiplies
  10045. * (depends on material.useLightmapAsShadowmap)
  10046. * after every other light calculations.
  10047. */
  10048. static readonly LIGHTMAP_DEFAULT: number;
  10049. /**
  10050. * material.lightmapTexture as only diffuse lighting from this light
  10051. * adds only specular lighting from this light
  10052. * adds dynamic shadows
  10053. */
  10054. static readonly LIGHTMAP_SPECULAR: number;
  10055. /**
  10056. * material.lightmapTexture as only lighting
  10057. * no light calculation from this light
  10058. * only adds dynamic shadows from this light
  10059. */
  10060. static readonly LIGHTMAP_SHADOWSONLY: number;
  10061. /**
  10062. * Each light type uses the default quantity according to its type:
  10063. * point/spot lights use luminous intensity
  10064. * directional lights use illuminance
  10065. */
  10066. static readonly INTENSITYMODE_AUTOMATIC: number;
  10067. /**
  10068. * lumen (lm)
  10069. */
  10070. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10071. /**
  10072. * candela (lm/sr)
  10073. */
  10074. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10075. /**
  10076. * lux (lm/m^2)
  10077. */
  10078. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10079. /**
  10080. * nit (cd/m^2)
  10081. */
  10082. static readonly INTENSITYMODE_LUMINANCE: number;
  10083. /**
  10084. * Light type const id of the point light.
  10085. */
  10086. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10087. /**
  10088. * Light type const id of the directional light.
  10089. */
  10090. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10091. /**
  10092. * Light type const id of the spot light.
  10093. */
  10094. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10095. /**
  10096. * Light type const id of the hemispheric light.
  10097. */
  10098. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10099. /**
  10100. * Diffuse gives the basic color to an object.
  10101. */
  10102. diffuse: Color3;
  10103. /**
  10104. * Specular produces a highlight color on an object.
  10105. * Note: This is note affecting PBR materials.
  10106. */
  10107. specular: Color3;
  10108. /**
  10109. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10110. * falling off base on range or angle.
  10111. * This can be set to any values in Light.FALLOFF_x.
  10112. *
  10113. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10114. * other types of materials.
  10115. */
  10116. falloffType: number;
  10117. /**
  10118. * Strength of the light.
  10119. * Note: By default it is define in the framework own unit.
  10120. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10121. */
  10122. intensity: number;
  10123. private _range;
  10124. protected _inverseSquaredRange: number;
  10125. /**
  10126. * Defines how far from the source the light is impacting in scene units.
  10127. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10128. */
  10129. /**
  10130. * Defines how far from the source the light is impacting in scene units.
  10131. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10132. */
  10133. range: number;
  10134. /**
  10135. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10136. * of light.
  10137. */
  10138. private _photometricScale;
  10139. private _intensityMode;
  10140. /**
  10141. * Gets the photometric scale used to interpret the intensity.
  10142. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10143. */
  10144. /**
  10145. * Sets the photometric scale used to interpret the intensity.
  10146. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10147. */
  10148. intensityMode: number;
  10149. private _radius;
  10150. /**
  10151. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10152. */
  10153. /**
  10154. * sets the light radius used by PBR Materials to simulate soft area lights.
  10155. */
  10156. radius: number;
  10157. private _renderPriority;
  10158. /**
  10159. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10160. * exceeding the number allowed of the materials.
  10161. */
  10162. renderPriority: number;
  10163. private _shadowEnabled;
  10164. /**
  10165. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10166. * the current shadow generator.
  10167. */
  10168. /**
  10169. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10170. * the current shadow generator.
  10171. */
  10172. shadowEnabled: boolean;
  10173. private _includedOnlyMeshes;
  10174. /**
  10175. * Gets the only meshes impacted by this light.
  10176. */
  10177. /**
  10178. * Sets the only meshes impacted by this light.
  10179. */
  10180. includedOnlyMeshes: AbstractMesh[];
  10181. private _excludedMeshes;
  10182. /**
  10183. * Gets the meshes not impacted by this light.
  10184. */
  10185. /**
  10186. * Sets the meshes not impacted by this light.
  10187. */
  10188. excludedMeshes: AbstractMesh[];
  10189. private _excludeWithLayerMask;
  10190. /**
  10191. * Gets the layer id use to find what meshes are not impacted by the light.
  10192. * Inactive if 0
  10193. */
  10194. /**
  10195. * Sets the layer id use to find what meshes are not impacted by the light.
  10196. * Inactive if 0
  10197. */
  10198. excludeWithLayerMask: number;
  10199. private _includeOnlyWithLayerMask;
  10200. /**
  10201. * Gets the layer id use to find what meshes are impacted by the light.
  10202. * Inactive if 0
  10203. */
  10204. /**
  10205. * Sets the layer id use to find what meshes are impacted by the light.
  10206. * Inactive if 0
  10207. */
  10208. includeOnlyWithLayerMask: number;
  10209. private _lightmapMode;
  10210. /**
  10211. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10212. */
  10213. /**
  10214. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10215. */
  10216. lightmapMode: number;
  10217. /**
  10218. * Shadow generator associted to the light.
  10219. * @hidden Internal use only.
  10220. */
  10221. _shadowGenerator: Nullable<IShadowGenerator>;
  10222. /**
  10223. * @hidden Internal use only.
  10224. */
  10225. _excludedMeshesIds: string[];
  10226. /**
  10227. * @hidden Internal use only.
  10228. */
  10229. _includedOnlyMeshesIds: string[];
  10230. /**
  10231. * The current light unifom buffer.
  10232. * @hidden Internal use only.
  10233. */
  10234. _uniformBuffer: UniformBuffer;
  10235. /**
  10236. * Creates a Light object in the scene.
  10237. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10238. * @param name The firendly name of the light
  10239. * @param scene The scene the light belongs too
  10240. */
  10241. constructor(name: string, scene: Scene);
  10242. protected abstract _buildUniformLayout(): void;
  10243. /**
  10244. * Sets the passed Effect "effect" with the Light information.
  10245. * @param effect The effect to update
  10246. * @param lightIndex The index of the light in the effect to update
  10247. * @returns The light
  10248. */
  10249. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10250. /**
  10251. * Returns the string "Light".
  10252. * @returns the class name
  10253. */
  10254. getClassName(): string;
  10255. /** @hidden */
  10256. readonly _isLight: boolean;
  10257. /**
  10258. * Converts the light information to a readable string for debug purpose.
  10259. * @param fullDetails Supports for multiple levels of logging within scene loading
  10260. * @returns the human readable light info
  10261. */
  10262. toString(fullDetails?: boolean): string;
  10263. /** @hidden */
  10264. protected _syncParentEnabledState(): void;
  10265. /**
  10266. * Set the enabled state of this node.
  10267. * @param value - the new enabled state
  10268. */
  10269. setEnabled(value: boolean): void;
  10270. /**
  10271. * Returns the Light associated shadow generator if any.
  10272. * @return the associated shadow generator.
  10273. */
  10274. getShadowGenerator(): Nullable<IShadowGenerator>;
  10275. /**
  10276. * Returns a Vector3, the absolute light position in the World.
  10277. * @returns the world space position of the light
  10278. */
  10279. getAbsolutePosition(): Vector3;
  10280. /**
  10281. * Specifies if the light will affect the passed mesh.
  10282. * @param mesh The mesh to test against the light
  10283. * @return true the mesh is affected otherwise, false.
  10284. */
  10285. canAffectMesh(mesh: AbstractMesh): boolean;
  10286. /**
  10287. * Sort function to order lights for rendering.
  10288. * @param a First Light object to compare to second.
  10289. * @param b Second Light object to compare first.
  10290. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10291. */
  10292. static CompareLightsPriority(a: Light, b: Light): number;
  10293. /**
  10294. * Releases resources associated with this node.
  10295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10297. */
  10298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10299. /**
  10300. * Returns the light type ID (integer).
  10301. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10302. */
  10303. getTypeID(): number;
  10304. /**
  10305. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10306. * @returns the scaled intensity in intensity mode unit
  10307. */
  10308. getScaledIntensity(): number;
  10309. /**
  10310. * Returns a new Light object, named "name", from the current one.
  10311. * @param name The name of the cloned light
  10312. * @returns the new created light
  10313. */
  10314. clone(name: string): Nullable<Light>;
  10315. /**
  10316. * Serializes the current light into a Serialization object.
  10317. * @returns the serialized object.
  10318. */
  10319. serialize(): any;
  10320. /**
  10321. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10322. * This new light is named "name" and added to the passed scene.
  10323. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10324. * @param name The friendly name of the light
  10325. * @param scene The scene the new light will belong to
  10326. * @returns the constructor function
  10327. */
  10328. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10329. /**
  10330. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10331. * @param parsedLight The JSON representation of the light
  10332. * @param scene The scene to create the parsed light in
  10333. * @returns the created light after parsing
  10334. */
  10335. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10336. private _hookArrayForExcluded;
  10337. private _hookArrayForIncludedOnly;
  10338. private _resyncMeshes;
  10339. /**
  10340. * Forces the meshes to update their light related information in their rendering used effects
  10341. * @hidden Internal Use Only
  10342. */
  10343. _markMeshesAsLightDirty(): void;
  10344. /**
  10345. * Recomputes the cached photometric scale if needed.
  10346. */
  10347. private _computePhotometricScale;
  10348. /**
  10349. * Returns the Photometric Scale according to the light type and intensity mode.
  10350. */
  10351. private _getPhotometricScale;
  10352. /**
  10353. * Reorder the light in the scene according to their defined priority.
  10354. * @hidden Internal Use Only
  10355. */
  10356. _reorderLightsInScene(): void;
  10357. /**
  10358. * Prepares the list of defines specific to the light type.
  10359. * @param defines the list of defines
  10360. * @param lightIndex defines the index of the light for the effect
  10361. */
  10362. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10363. }
  10364. }
  10365. declare module BABYLON {
  10366. /**
  10367. * Interface used to define Action
  10368. */
  10369. export interface IAction {
  10370. /**
  10371. * Trigger for the action
  10372. */
  10373. trigger: number;
  10374. /** Options of the trigger */
  10375. triggerOptions: any;
  10376. /**
  10377. * Gets the trigger parameters
  10378. * @returns the trigger parameters
  10379. */
  10380. getTriggerParameter(): any;
  10381. /**
  10382. * Internal only - executes current action event
  10383. * @hidden
  10384. */
  10385. _executeCurrent(evt?: ActionEvent): void;
  10386. /**
  10387. * Serialize placeholder for child classes
  10388. * @param parent of child
  10389. * @returns the serialized object
  10390. */
  10391. serialize(parent: any): any;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _prepare(): void;
  10397. /**
  10398. * Internal only - manager for action
  10399. * @hidden
  10400. */
  10401. _actionManager: AbstractActionManager;
  10402. }
  10403. /**
  10404. * The action to be carried out following a trigger
  10405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10406. */
  10407. export class Action implements IAction {
  10408. /** the trigger, with or without parameters, for the action */
  10409. triggerOptions: any;
  10410. /**
  10411. * Trigger for the action
  10412. */
  10413. trigger: number;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. private _nextActiveAction;
  10420. private _child;
  10421. private _condition?;
  10422. private _triggerParameter;
  10423. /**
  10424. * An event triggered prior to action being executed.
  10425. */
  10426. onBeforeExecuteObservable: Observable<Action>;
  10427. /**
  10428. * Creates a new Action
  10429. * @param triggerOptions the trigger, with or without parameters, for the action
  10430. * @param condition an optional determinant of action
  10431. */
  10432. constructor(
  10433. /** the trigger, with or without parameters, for the action */
  10434. triggerOptions: any, condition?: Condition);
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. _prepare(): void;
  10440. /**
  10441. * Gets the trigger parameters
  10442. * @returns the trigger parameters
  10443. */
  10444. getTriggerParameter(): any;
  10445. /**
  10446. * Internal only - executes current action event
  10447. * @hidden
  10448. */
  10449. _executeCurrent(evt?: ActionEvent): void;
  10450. /**
  10451. * Execute placeholder for child classes
  10452. * @param evt optional action event
  10453. */
  10454. execute(evt?: ActionEvent): void;
  10455. /**
  10456. * Skips to next active action
  10457. */
  10458. skipToNextActiveAction(): void;
  10459. /**
  10460. * Adds action to chain of actions, may be a DoNothingAction
  10461. * @param action defines the next action to execute
  10462. * @returns The action passed in
  10463. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10464. */
  10465. then(action: Action): Action;
  10466. /**
  10467. * Internal only
  10468. * @hidden
  10469. */
  10470. _getProperty(propertyPath: string): string;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _getEffectiveTarget(target: any, propertyPath: string): any;
  10476. /**
  10477. * Serialize placeholder for child classes
  10478. * @param parent of child
  10479. * @returns the serialized object
  10480. */
  10481. serialize(parent: any): any;
  10482. /**
  10483. * Internal only called by serialize
  10484. * @hidden
  10485. */
  10486. protected _serialize(serializedAction: any, parent?: any): any;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. static _SerializeValueAsString: (value: any) => string;
  10492. /**
  10493. * Internal only
  10494. * @hidden
  10495. */
  10496. static _GetTargetProperty: (target: Scene | Node) => {
  10497. name: string;
  10498. targetType: string;
  10499. value: string;
  10500. };
  10501. }
  10502. }
  10503. declare module BABYLON {
  10504. /**
  10505. * A Condition applied to an Action
  10506. */
  10507. export class Condition {
  10508. /**
  10509. * Internal only - manager for action
  10510. * @hidden
  10511. */
  10512. _actionManager: ActionManager;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _evaluationId: number;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. _currentResult: boolean;
  10523. /**
  10524. * Creates a new Condition
  10525. * @param actionManager the manager of the action the condition is applied to
  10526. */
  10527. constructor(actionManager: ActionManager);
  10528. /**
  10529. * Check if the current condition is valid
  10530. * @returns a boolean
  10531. */
  10532. isValid(): boolean;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getProperty(propertyPath: string): string;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. _getEffectiveTarget(target: any, propertyPath: string): any;
  10543. /**
  10544. * Serialize placeholder for child classes
  10545. * @returns the serialized object
  10546. */
  10547. serialize(): any;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. protected _serialize(serializedCondition: any): any;
  10553. }
  10554. /**
  10555. * Defines specific conditional operators as extensions of Condition
  10556. */
  10557. export class ValueCondition extends Condition {
  10558. /** path to specify the property of the target the conditional operator uses */
  10559. propertyPath: string;
  10560. /** the value compared by the conditional operator against the current value of the property */
  10561. value: any;
  10562. /** the conditional operator, default ValueCondition.IsEqual */
  10563. operator: number;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsEqual;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsDifferent;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsGreater;
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. private static _IsLesser;
  10584. /**
  10585. * returns the number for IsEqual
  10586. */
  10587. static readonly IsEqual: number;
  10588. /**
  10589. * Returns the number for IsDifferent
  10590. */
  10591. static readonly IsDifferent: number;
  10592. /**
  10593. * Returns the number for IsGreater
  10594. */
  10595. static readonly IsGreater: number;
  10596. /**
  10597. * Returns the number for IsLesser
  10598. */
  10599. static readonly IsLesser: number;
  10600. /**
  10601. * Internal only The action manager for the condition
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _target;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _effectiveTarget;
  10615. /**
  10616. * Internal only
  10617. * @hidden
  10618. */
  10619. private _property;
  10620. /**
  10621. * Creates a new ValueCondition
  10622. * @param actionManager manager for the action the condition applies to
  10623. * @param target for the action
  10624. * @param propertyPath path to specify the property of the target the conditional operator uses
  10625. * @param value the value compared by the conditional operator against the current value of the property
  10626. * @param operator the conditional operator, default ValueCondition.IsEqual
  10627. */
  10628. constructor(actionManager: ActionManager, target: any,
  10629. /** path to specify the property of the target the conditional operator uses */
  10630. propertyPath: string,
  10631. /** the value compared by the conditional operator against the current value of the property */
  10632. value: any,
  10633. /** the conditional operator, default ValueCondition.IsEqual */
  10634. operator?: number);
  10635. /**
  10636. * Compares the given value with the property value for the specified conditional operator
  10637. * @returns the result of the comparison
  10638. */
  10639. isValid(): boolean;
  10640. /**
  10641. * Serialize the ValueCondition into a JSON compatible object
  10642. * @returns serialization object
  10643. */
  10644. serialize(): any;
  10645. /**
  10646. * Gets the name of the conditional operator for the ValueCondition
  10647. * @param operator the conditional operator
  10648. * @returns the name
  10649. */
  10650. static GetOperatorName(operator: number): string;
  10651. }
  10652. /**
  10653. * Defines a predicate condition as an extension of Condition
  10654. */
  10655. export class PredicateCondition extends Condition {
  10656. /** defines the predicate function used to validate the condition */
  10657. predicate: () => boolean;
  10658. /**
  10659. * Internal only - manager for action
  10660. * @hidden
  10661. */
  10662. _actionManager: ActionManager;
  10663. /**
  10664. * Creates a new PredicateCondition
  10665. * @param actionManager manager for the action the condition applies to
  10666. * @param predicate defines the predicate function used to validate the condition
  10667. */
  10668. constructor(actionManager: ActionManager,
  10669. /** defines the predicate function used to validate the condition */
  10670. predicate: () => boolean);
  10671. /**
  10672. * @returns the validity of the predicate condition
  10673. */
  10674. isValid(): boolean;
  10675. }
  10676. /**
  10677. * Defines a state condition as an extension of Condition
  10678. */
  10679. export class StateCondition extends Condition {
  10680. /** Value to compare with target state */
  10681. value: string;
  10682. /**
  10683. * Internal only - manager for action
  10684. * @hidden
  10685. */
  10686. _actionManager: ActionManager;
  10687. /**
  10688. * Internal only
  10689. * @hidden
  10690. */
  10691. private _target;
  10692. /**
  10693. * Creates a new StateCondition
  10694. * @param actionManager manager for the action the condition applies to
  10695. * @param target of the condition
  10696. * @param value to compare with target state
  10697. */
  10698. constructor(actionManager: ActionManager, target: any,
  10699. /** Value to compare with target state */
  10700. value: string);
  10701. /**
  10702. * Gets a boolean indicating if the current condition is met
  10703. * @returns the validity of the state
  10704. */
  10705. isValid(): boolean;
  10706. /**
  10707. * Serialize the StateCondition into a JSON compatible object
  10708. * @returns serialization object
  10709. */
  10710. serialize(): any;
  10711. }
  10712. }
  10713. declare module BABYLON {
  10714. /**
  10715. * This defines an action responsible to toggle a boolean once triggered.
  10716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10717. */
  10718. export class SwitchBooleanAction extends Action {
  10719. /**
  10720. * The path to the boolean property in the target object
  10721. */
  10722. propertyPath: string;
  10723. private _target;
  10724. private _effectiveTarget;
  10725. private _property;
  10726. /**
  10727. * Instantiate the action
  10728. * @param triggerOptions defines the trigger options
  10729. * @param target defines the object containing the boolean
  10730. * @param propertyPath defines the path to the boolean property in the target object
  10731. * @param condition defines the trigger related conditions
  10732. */
  10733. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10734. /** @hidden */
  10735. _prepare(): void;
  10736. /**
  10737. * Execute the action toggle the boolean value.
  10738. */
  10739. execute(): void;
  10740. /**
  10741. * Serializes the actions and its related information.
  10742. * @param parent defines the object to serialize in
  10743. * @returns the serialized object
  10744. */
  10745. serialize(parent: any): any;
  10746. }
  10747. /**
  10748. * This defines an action responsible to set a the state field of the target
  10749. * to a desired value once triggered.
  10750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10751. */
  10752. export class SetStateAction extends Action {
  10753. /**
  10754. * The value to store in the state field.
  10755. */
  10756. value: string;
  10757. private _target;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param target defines the object containing the state property
  10762. * @param value defines the value to store in the state field
  10763. * @param condition defines the trigger related conditions
  10764. */
  10765. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10766. /**
  10767. * Execute the action and store the value on the target state property.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set a property of the target
  10779. * to a desired value once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class SetValueAction extends Action {
  10783. /**
  10784. * The path of the property to set in the target.
  10785. */
  10786. propertyPath: string;
  10787. /**
  10788. * The value to set in the property
  10789. */
  10790. value: any;
  10791. private _target;
  10792. private _effectiveTarget;
  10793. private _property;
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param target defines the object containing the property
  10798. * @param propertyPath defines the path of the property to set in the target
  10799. * @param value defines the value to set in the property
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10803. /** @hidden */
  10804. _prepare(): void;
  10805. /**
  10806. * Execute the action and set the targetted property to the desired value.
  10807. */
  10808. execute(): void;
  10809. /**
  10810. * Serializes the actions and its related information.
  10811. * @param parent defines the object to serialize in
  10812. * @returns the serialized object
  10813. */
  10814. serialize(parent: any): any;
  10815. }
  10816. /**
  10817. * This defines an action responsible to increment the target value
  10818. * to a desired value once triggered.
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10820. */
  10821. export class IncrementValueAction extends Action {
  10822. /**
  10823. * The path of the property to increment in the target.
  10824. */
  10825. propertyPath: string;
  10826. /**
  10827. * The value we should increment the property by.
  10828. */
  10829. value: any;
  10830. private _target;
  10831. private _effectiveTarget;
  10832. private _property;
  10833. /**
  10834. * Instantiate the action
  10835. * @param triggerOptions defines the trigger options
  10836. * @param target defines the object containing the property
  10837. * @param propertyPath defines the path of the property to increment in the target
  10838. * @param value defines the value value we should increment the property by
  10839. * @param condition defines the trigger related conditions
  10840. */
  10841. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10842. /** @hidden */
  10843. _prepare(): void;
  10844. /**
  10845. * Execute the action and increment the target of the value amount.
  10846. */
  10847. execute(): void;
  10848. /**
  10849. * Serializes the actions and its related information.
  10850. * @param parent defines the object to serialize in
  10851. * @returns the serialized object
  10852. */
  10853. serialize(parent: any): any;
  10854. }
  10855. /**
  10856. * This defines an action responsible to start an animation once triggered.
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10858. */
  10859. export class PlayAnimationAction extends Action {
  10860. /**
  10861. * Where the animation should start (animation frame)
  10862. */
  10863. from: number;
  10864. /**
  10865. * Where the animation should stop (animation frame)
  10866. */
  10867. to: number;
  10868. /**
  10869. * Define if the animation should loop or stop after the first play.
  10870. */
  10871. loop?: boolean;
  10872. private _target;
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param target defines the target animation or animation name
  10877. * @param from defines from where the animation should start (animation frame)
  10878. * @param end defines where the animation should stop (animation frame)
  10879. * @param loop defines if the animation should loop or stop after the first play
  10880. * @param condition defines the trigger related conditions
  10881. */
  10882. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10883. /** @hidden */
  10884. _prepare(): void;
  10885. /**
  10886. * Execute the action and play the animation.
  10887. */
  10888. execute(): void;
  10889. /**
  10890. * Serializes the actions and its related information.
  10891. * @param parent defines the object to serialize in
  10892. * @returns the serialized object
  10893. */
  10894. serialize(parent: any): any;
  10895. }
  10896. /**
  10897. * This defines an action responsible to stop an animation once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class StopAnimationAction extends Action {
  10901. private _target;
  10902. /**
  10903. * Instantiate the action
  10904. * @param triggerOptions defines the trigger options
  10905. * @param target defines the target animation or animation name
  10906. * @param condition defines the trigger related conditions
  10907. */
  10908. constructor(triggerOptions: any, target: any, condition?: Condition);
  10909. /** @hidden */
  10910. _prepare(): void;
  10911. /**
  10912. * Execute the action and stop the animation.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible that does nothing once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class DoNothingAction extends Action {
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param condition defines the trigger related conditions
  10931. */
  10932. constructor(triggerOptions?: any, condition?: Condition);
  10933. /**
  10934. * Execute the action and do nothing.
  10935. */
  10936. execute(): void;
  10937. /**
  10938. * Serializes the actions and its related information.
  10939. * @param parent defines the object to serialize in
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. }
  10944. /**
  10945. * This defines an action responsible to trigger several actions once triggered.
  10946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10947. */
  10948. export class CombineAction extends Action {
  10949. /**
  10950. * The list of aggregated animations to run.
  10951. */
  10952. children: Action[];
  10953. /**
  10954. * Instantiate the action
  10955. * @param triggerOptions defines the trigger options
  10956. * @param children defines the list of aggregated animations to run
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10960. /** @hidden */
  10961. _prepare(): void;
  10962. /**
  10963. * Execute the action and executes all the aggregated actions.
  10964. */
  10965. execute(evt: ActionEvent): void;
  10966. /**
  10967. * Serializes the actions and its related information.
  10968. * @param parent defines the object to serialize in
  10969. * @returns the serialized object
  10970. */
  10971. serialize(parent: any): any;
  10972. }
  10973. /**
  10974. * This defines an action responsible to run code (external event) once triggered.
  10975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10976. */
  10977. export class ExecuteCodeAction extends Action {
  10978. /**
  10979. * The callback function to run.
  10980. */
  10981. func: (evt: ActionEvent) => void;
  10982. /**
  10983. * Instantiate the action
  10984. * @param triggerOptions defines the trigger options
  10985. * @param func defines the callback function to run
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10989. /**
  10990. * Execute the action and run the attached code.
  10991. */
  10992. execute(evt: ActionEvent): void;
  10993. }
  10994. /**
  10995. * This defines an action responsible to set the parent property of the target once triggered.
  10996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10997. */
  10998. export class SetParentAction extends Action {
  10999. private _parent;
  11000. private _target;
  11001. /**
  11002. * Instantiate the action
  11003. * @param triggerOptions defines the trigger options
  11004. * @param target defines the target containing the parent property
  11005. * @param parent defines from where the animation should start (animation frame)
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11009. /** @hidden */
  11010. _prepare(): void;
  11011. /**
  11012. * Execute the action and set the parent property.
  11013. */
  11014. execute(): void;
  11015. /**
  11016. * Serializes the actions and its related information.
  11017. * @param parent defines the object to serialize in
  11018. * @returns the serialized object
  11019. */
  11020. serialize(parent: any): any;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /**
  11025. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11026. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class ActionManager extends AbstractActionManager {
  11030. /**
  11031. * Nothing
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11033. */
  11034. static readonly NothingTrigger: number;
  11035. /**
  11036. * On pick
  11037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11038. */
  11039. static readonly OnPickTrigger: number;
  11040. /**
  11041. * On left pick
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11043. */
  11044. static readonly OnLeftPickTrigger: number;
  11045. /**
  11046. * On right pick
  11047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11048. */
  11049. static readonly OnRightPickTrigger: number;
  11050. /**
  11051. * On center pick
  11052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11053. */
  11054. static readonly OnCenterPickTrigger: number;
  11055. /**
  11056. * On pick down
  11057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11058. */
  11059. static readonly OnPickDownTrigger: number;
  11060. /**
  11061. * On double pick
  11062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11063. */
  11064. static readonly OnDoublePickTrigger: number;
  11065. /**
  11066. * On pick up
  11067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11068. */
  11069. static readonly OnPickUpTrigger: number;
  11070. /**
  11071. * On pick out.
  11072. * This trigger will only be raised if you also declared a OnPickDown
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnPickOutTrigger: number;
  11076. /**
  11077. * On long press
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnLongPressTrigger: number;
  11081. /**
  11082. * On pointer over
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPointerOverTrigger: number;
  11086. /**
  11087. * On pointer out
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPointerOutTrigger: number;
  11091. /**
  11092. * On every frame
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnEveryFrameTrigger: number;
  11096. /**
  11097. * On intersection enter
  11098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11099. */
  11100. static readonly OnIntersectionEnterTrigger: number;
  11101. /**
  11102. * On intersection exit
  11103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11104. */
  11105. static readonly OnIntersectionExitTrigger: number;
  11106. /**
  11107. * On key down
  11108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11109. */
  11110. static readonly OnKeyDownTrigger: number;
  11111. /**
  11112. * On key up
  11113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11114. */
  11115. static readonly OnKeyUpTrigger: number;
  11116. private _scene;
  11117. /**
  11118. * Creates a new action manager
  11119. * @param scene defines the hosting scene
  11120. */
  11121. constructor(scene: Scene);
  11122. /**
  11123. * Releases all associated resources
  11124. */
  11125. dispose(): void;
  11126. /**
  11127. * Gets hosting scene
  11128. * @returns the hosting scene
  11129. */
  11130. getScene(): Scene;
  11131. /**
  11132. * Does this action manager handles actions of any of the given triggers
  11133. * @param triggers defines the triggers to be tested
  11134. * @return a boolean indicating whether one (or more) of the triggers is handled
  11135. */
  11136. hasSpecificTriggers(triggers: number[]): boolean;
  11137. /**
  11138. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11139. * speed.
  11140. * @param triggerA defines the trigger to be tested
  11141. * @param triggerB defines the trigger to be tested
  11142. * @return a boolean indicating whether one (or more) of the triggers is handled
  11143. */
  11144. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11145. /**
  11146. * Does this action manager handles actions of a given trigger
  11147. * @param trigger defines the trigger to be tested
  11148. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11149. * @return whether the trigger is handled
  11150. */
  11151. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11152. /**
  11153. * Does this action manager has pointer triggers
  11154. */
  11155. readonly hasPointerTriggers: boolean;
  11156. /**
  11157. * Does this action manager has pick triggers
  11158. */
  11159. readonly hasPickTriggers: boolean;
  11160. /**
  11161. * Registers an action to this action manager
  11162. * @param action defines the action to be registered
  11163. * @return the action amended (prepared) after registration
  11164. */
  11165. registerAction(action: IAction): Nullable<IAction>;
  11166. /**
  11167. * Unregisters an action to this action manager
  11168. * @param action defines the action to be unregistered
  11169. * @return a boolean indicating whether the action has been unregistered
  11170. */
  11171. unregisterAction(action: IAction): Boolean;
  11172. /**
  11173. * Process a specific trigger
  11174. * @param trigger defines the trigger to process
  11175. * @param evt defines the event details to be processed
  11176. */
  11177. processTrigger(trigger: number, evt?: IActionEvent): void;
  11178. /** @hidden */
  11179. _getEffectiveTarget(target: any, propertyPath: string): any;
  11180. /** @hidden */
  11181. _getProperty(propertyPath: string): string;
  11182. /**
  11183. * Serialize this manager to a JSON object
  11184. * @param name defines the property name to store this manager
  11185. * @returns a JSON representation of this manager
  11186. */
  11187. serialize(name: string): any;
  11188. /**
  11189. * Creates a new ActionManager from a JSON data
  11190. * @param parsedActions defines the JSON data to read from
  11191. * @param object defines the hosting mesh
  11192. * @param scene defines the hosting scene
  11193. */
  11194. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11195. /**
  11196. * Get a trigger name by index
  11197. * @param trigger defines the trigger index
  11198. * @returns a trigger name
  11199. */
  11200. static GetTriggerName(trigger: number): string;
  11201. }
  11202. }
  11203. declare module BABYLON {
  11204. /**
  11205. * Class representing a ray with position and direction
  11206. */
  11207. export class Ray {
  11208. /** origin point */
  11209. origin: Vector3;
  11210. /** direction */
  11211. direction: Vector3;
  11212. /** length of the ray */
  11213. length: number;
  11214. private static readonly TmpVector3;
  11215. private _tmpRay;
  11216. /**
  11217. * Creates a new ray
  11218. * @param origin origin point
  11219. * @param direction direction
  11220. * @param length length of the ray
  11221. */
  11222. constructor(
  11223. /** origin point */
  11224. origin: Vector3,
  11225. /** direction */
  11226. direction: Vector3,
  11227. /** length of the ray */
  11228. length?: number);
  11229. /**
  11230. * Checks if the ray intersects a box
  11231. * @param minimum bound of the box
  11232. * @param maximum bound of the box
  11233. * @param intersectionTreshold extra extend to be added to the box in all direction
  11234. * @returns if the box was hit
  11235. */
  11236. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11237. /**
  11238. * Checks if the ray intersects a box
  11239. * @param box the bounding box to check
  11240. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11241. * @returns if the box was hit
  11242. */
  11243. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11244. /**
  11245. * If the ray hits a sphere
  11246. * @param sphere the bounding sphere to check
  11247. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11248. * @returns true if it hits the sphere
  11249. */
  11250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11251. /**
  11252. * If the ray hits a triange
  11253. * @param vertex0 triangle vertex
  11254. * @param vertex1 triangle vertex
  11255. * @param vertex2 triangle vertex
  11256. * @returns intersection information if hit
  11257. */
  11258. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11259. /**
  11260. * Checks if ray intersects a plane
  11261. * @param plane the plane to check
  11262. * @returns the distance away it was hit
  11263. */
  11264. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11265. /**
  11266. * Checks if ray intersects a mesh
  11267. * @param mesh the mesh to check
  11268. * @param fastCheck if only the bounding box should checked
  11269. * @returns picking info of the intersecton
  11270. */
  11271. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11272. /**
  11273. * Checks if ray intersects a mesh
  11274. * @param meshes the meshes to check
  11275. * @param fastCheck if only the bounding box should checked
  11276. * @param results array to store result in
  11277. * @returns Array of picking infos
  11278. */
  11279. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11280. private _comparePickingInfo;
  11281. private static smallnum;
  11282. private static rayl;
  11283. /**
  11284. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11285. * @param sega the first point of the segment to test the intersection against
  11286. * @param segb the second point of the segment to test the intersection against
  11287. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11288. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11289. */
  11290. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11291. /**
  11292. * Update the ray from viewport position
  11293. * @param x position
  11294. * @param y y position
  11295. * @param viewportWidth viewport width
  11296. * @param viewportHeight viewport height
  11297. * @param world world matrix
  11298. * @param view view matrix
  11299. * @param projection projection matrix
  11300. * @returns this ray updated
  11301. */
  11302. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Creates a ray with origin and direction of 0,0,0
  11305. * @returns the new ray
  11306. */
  11307. static Zero(): Ray;
  11308. /**
  11309. * Creates a new ray from screen space and viewport
  11310. * @param x position
  11311. * @param y y position
  11312. * @param viewportWidth viewport width
  11313. * @param viewportHeight viewport height
  11314. * @param world world matrix
  11315. * @param view view matrix
  11316. * @param projection projection matrix
  11317. * @returns new ray
  11318. */
  11319. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11320. /**
  11321. * 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
  11322. * transformed to the given world matrix.
  11323. * @param origin The origin point
  11324. * @param end The end point
  11325. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11326. * @returns the new ray
  11327. */
  11328. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11329. /**
  11330. * Transforms a ray by a matrix
  11331. * @param ray ray to transform
  11332. * @param matrix matrix to apply
  11333. * @returns the resulting new ray
  11334. */
  11335. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11336. /**
  11337. * Transforms a ray by a matrix
  11338. * @param ray ray to transform
  11339. * @param matrix matrix to apply
  11340. * @param result ray to store result in
  11341. */
  11342. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11343. /**
  11344. * Unproject a ray from screen space to object space
  11345. * @param sourceX defines the screen space x coordinate to use
  11346. * @param sourceY defines the screen space y coordinate to use
  11347. * @param viewportWidth defines the current width of the viewport
  11348. * @param viewportHeight defines the current height of the viewport
  11349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11350. * @param view defines the view matrix to use
  11351. * @param projection defines the projection matrix to use
  11352. */
  11353. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11354. }
  11355. /**
  11356. * Type used to define predicate used to select faces when a mesh intersection is detected
  11357. */
  11358. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11359. interface Scene {
  11360. /** @hidden */
  11361. _tempPickingRay: Nullable<Ray>;
  11362. /** @hidden */
  11363. _cachedRayForTransform: Ray;
  11364. /** @hidden */
  11365. _pickWithRayInverseMatrix: Matrix;
  11366. /** @hidden */
  11367. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11368. /** @hidden */
  11369. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11370. }
  11371. }
  11372. declare module BABYLON {
  11373. /**
  11374. * Groups all the scene component constants in one place to ease maintenance.
  11375. * @hidden
  11376. */
  11377. export class SceneComponentConstants {
  11378. static readonly NAME_EFFECTLAYER: string;
  11379. static readonly NAME_LAYER: string;
  11380. static readonly NAME_LENSFLARESYSTEM: string;
  11381. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11382. static readonly NAME_PARTICLESYSTEM: string;
  11383. static readonly NAME_GAMEPAD: string;
  11384. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11385. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11386. static readonly NAME_DEPTHRENDERER: string;
  11387. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11388. static readonly NAME_SPRITE: string;
  11389. static readonly NAME_OUTLINERENDERER: string;
  11390. static readonly NAME_PROCEDURALTEXTURE: string;
  11391. static readonly NAME_SHADOWGENERATOR: string;
  11392. static readonly NAME_OCTREE: string;
  11393. static readonly NAME_PHYSICSENGINE: string;
  11394. static readonly NAME_AUDIO: string;
  11395. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11396. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11397. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11400. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11402. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11404. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11407. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11409. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11410. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11415. static readonly STEP_AFTERRENDER_AUDIO: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11421. static readonly STEP_POINTERMOVE_SPRITE: number;
  11422. static readonly STEP_POINTERDOWN_SPRITE: number;
  11423. static readonly STEP_POINTERUP_SPRITE: number;
  11424. }
  11425. /**
  11426. * This represents a scene component.
  11427. *
  11428. * This is used to decouple the dependency the scene is having on the different workloads like
  11429. * layers, post processes...
  11430. */
  11431. export interface ISceneComponent {
  11432. /**
  11433. * The name of the component. Each component must have a unique name.
  11434. */
  11435. name: string;
  11436. /**
  11437. * The scene the component belongs to.
  11438. */
  11439. scene: Scene;
  11440. /**
  11441. * Register the component to one instance of a scene.
  11442. */
  11443. register(): void;
  11444. /**
  11445. * Rebuilds the elements related to this component in case of
  11446. * context lost for instance.
  11447. */
  11448. rebuild(): void;
  11449. /**
  11450. * Disposes the component and the associated ressources.
  11451. */
  11452. dispose(): void;
  11453. }
  11454. /**
  11455. * This represents a SERIALIZABLE scene component.
  11456. *
  11457. * This extends Scene Component to add Serialization methods on top.
  11458. */
  11459. export interface ISceneSerializableComponent extends ISceneComponent {
  11460. /**
  11461. * Adds all the element from the container to the scene
  11462. * @param container the container holding the elements
  11463. */
  11464. addFromContainer(container: AbstractScene): void;
  11465. /**
  11466. * Removes all the elements in the container from the scene
  11467. * @param container contains the elements to remove
  11468. * @param dispose if the removed element should be disposed (default: false)
  11469. */
  11470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11471. /**
  11472. * Serializes the component data to the specified json object
  11473. * @param serializationObject The object to serialize to
  11474. */
  11475. serialize(serializationObject: any): void;
  11476. }
  11477. /**
  11478. * Strong typing of a Mesh related stage step action
  11479. */
  11480. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11481. /**
  11482. * Strong typing of a Evaluate Sub Mesh related stage step action
  11483. */
  11484. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11485. /**
  11486. * Strong typing of a Active Mesh related stage step action
  11487. */
  11488. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11489. /**
  11490. * Strong typing of a Camera related stage step action
  11491. */
  11492. export type CameraStageAction = (camera: Camera) => void;
  11493. /**
  11494. * Strong typing of a Camera Frame buffer related stage step action
  11495. */
  11496. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11497. /**
  11498. * Strong typing of a Render Target related stage step action
  11499. */
  11500. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11501. /**
  11502. * Strong typing of a RenderingGroup related stage step action
  11503. */
  11504. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11505. /**
  11506. * Strong typing of a Mesh Render related stage step action
  11507. */
  11508. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11509. /**
  11510. * Strong typing of a simple stage step action
  11511. */
  11512. export type SimpleStageAction = () => void;
  11513. /**
  11514. * Strong typing of a render target action.
  11515. */
  11516. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11517. /**
  11518. * Strong typing of a pointer move action.
  11519. */
  11520. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11521. /**
  11522. * Strong typing of a pointer up/down action.
  11523. */
  11524. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11525. /**
  11526. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11527. * @hidden
  11528. */
  11529. export class Stage<T extends Function> extends Array<{
  11530. index: number;
  11531. component: ISceneComponent;
  11532. action: T;
  11533. }> {
  11534. /**
  11535. * Hide ctor from the rest of the world.
  11536. * @param items The items to add.
  11537. */
  11538. private constructor();
  11539. /**
  11540. * Creates a new Stage.
  11541. * @returns A new instance of a Stage
  11542. */
  11543. static Create<T extends Function>(): Stage<T>;
  11544. /**
  11545. * Registers a step in an ordered way in the targeted stage.
  11546. * @param index Defines the position to register the step in
  11547. * @param component Defines the component attached to the step
  11548. * @param action Defines the action to launch during the step
  11549. */
  11550. registerStep(index: number, component: ISceneComponent, action: T): void;
  11551. /**
  11552. * Clears all the steps from the stage.
  11553. */
  11554. clear(): void;
  11555. }
  11556. }
  11557. declare module BABYLON {
  11558. interface Scene {
  11559. /** @hidden */
  11560. _pointerOverSprite: Nullable<Sprite>;
  11561. /** @hidden */
  11562. _pickedDownSprite: Nullable<Sprite>;
  11563. /** @hidden */
  11564. _tempSpritePickingRay: Nullable<Ray>;
  11565. /**
  11566. * All of the sprite managers added to this scene
  11567. * @see http://doc.babylonjs.com/babylon101/sprites
  11568. */
  11569. spriteManagers: Array<ISpriteManager>;
  11570. /**
  11571. * An event triggered when sprites rendering is about to start
  11572. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11573. */
  11574. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11575. /**
  11576. * An event triggered when sprites rendering is done
  11577. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11578. */
  11579. onAfterSpritesRenderingObservable: Observable<Scene>;
  11580. /** @hidden */
  11581. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11582. /** Launch a ray to try to pick a sprite in the scene
  11583. * @param x position on screen
  11584. * @param y position on screen
  11585. * @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
  11586. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11587. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11588. * @returns a PickingInfo
  11589. */
  11590. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11591. /** Use the given ray to pick a sprite in the scene
  11592. * @param ray The ray (in world space) to use to pick meshes
  11593. * @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
  11594. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11595. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11596. * @returns a PickingInfo
  11597. */
  11598. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11599. /**
  11600. * Force the sprite under the pointer
  11601. * @param sprite defines the sprite to use
  11602. */
  11603. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11604. /**
  11605. * Gets the sprite under the pointer
  11606. * @returns a Sprite or null if no sprite is under the pointer
  11607. */
  11608. getPointerOverSprite(): Nullable<Sprite>;
  11609. }
  11610. /**
  11611. * Defines the sprite scene component responsible to manage sprites
  11612. * in a given scene.
  11613. */
  11614. export class SpriteSceneComponent implements ISceneComponent {
  11615. /**
  11616. * The component name helpfull to identify the component in the list of scene components.
  11617. */
  11618. readonly name: string;
  11619. /**
  11620. * The scene the component belongs to.
  11621. */
  11622. scene: Scene;
  11623. /** @hidden */
  11624. private _spritePredicate;
  11625. /**
  11626. * Creates a new instance of the component for the given scene
  11627. * @param scene Defines the scene to register the component in
  11628. */
  11629. constructor(scene: Scene);
  11630. /**
  11631. * Registers the component in a given scene
  11632. */
  11633. register(): void;
  11634. /**
  11635. * Rebuilds the elements related to this component in case of
  11636. * context lost for instance.
  11637. */
  11638. rebuild(): void;
  11639. /**
  11640. * Disposes the component and the associated ressources.
  11641. */
  11642. dispose(): void;
  11643. private _pickSpriteButKeepRay;
  11644. private _pointerMove;
  11645. private _pointerDown;
  11646. private _pointerUp;
  11647. }
  11648. }
  11649. declare module BABYLON {
  11650. /** @hidden */
  11651. export var fogFragmentDeclaration: {
  11652. name: string;
  11653. shader: string;
  11654. };
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var fogFragment: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /** @hidden */
  11665. export var spritesPixelShader: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module BABYLON {
  11671. /** @hidden */
  11672. export var fogVertexDeclaration: {
  11673. name: string;
  11674. shader: string;
  11675. };
  11676. }
  11677. declare module BABYLON {
  11678. /** @hidden */
  11679. export var spritesVertexShader: {
  11680. name: string;
  11681. shader: string;
  11682. };
  11683. }
  11684. declare module BABYLON {
  11685. /**
  11686. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11687. */
  11688. export interface ISpriteManager extends IDisposable {
  11689. /**
  11690. * Restricts the camera to viewing objects with the same layerMask.
  11691. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11692. */
  11693. layerMask: number;
  11694. /**
  11695. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11696. */
  11697. isPickable: boolean;
  11698. /**
  11699. * Specifies the rendering group id for this mesh (0 by default)
  11700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11701. */
  11702. renderingGroupId: number;
  11703. /**
  11704. * Defines the list of sprites managed by the manager.
  11705. */
  11706. sprites: Array<Sprite>;
  11707. /**
  11708. * Tests the intersection of a sprite with a specific ray.
  11709. * @param ray The ray we are sending to test the collision
  11710. * @param camera The camera space we are sending rays in
  11711. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11712. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11713. * @returns picking info or null.
  11714. */
  11715. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11716. /**
  11717. * Renders the list of sprites on screen.
  11718. */
  11719. render(): void;
  11720. }
  11721. /**
  11722. * Class used to manage multiple sprites on the same spritesheet
  11723. * @see http://doc.babylonjs.com/babylon101/sprites
  11724. */
  11725. export class SpriteManager implements ISpriteManager {
  11726. /** defines the manager's name */
  11727. name: string;
  11728. /** Gets the list of sprites */
  11729. sprites: Sprite[];
  11730. /** Gets or sets the rendering group id (0 by default) */
  11731. renderingGroupId: number;
  11732. /** Gets or sets camera layer mask */
  11733. layerMask: number;
  11734. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11735. fogEnabled: boolean;
  11736. /** Gets or sets a boolean indicating if the sprites are pickable */
  11737. isPickable: boolean;
  11738. /** Defines the default width of a cell in the spritesheet */
  11739. cellWidth: number;
  11740. /** Defines the default height of a cell in the spritesheet */
  11741. cellHeight: number;
  11742. /**
  11743. * An event triggered when the manager is disposed.
  11744. */
  11745. onDisposeObservable: Observable<SpriteManager>;
  11746. private _onDisposeObserver;
  11747. /**
  11748. * Callback called when the manager is disposed
  11749. */
  11750. onDispose: () => void;
  11751. private _capacity;
  11752. private _spriteTexture;
  11753. private _epsilon;
  11754. private _scene;
  11755. private _vertexData;
  11756. private _buffer;
  11757. private _vertexBuffers;
  11758. private _indexBuffer;
  11759. private _effectBase;
  11760. private _effectFog;
  11761. /**
  11762. * Gets or sets the spritesheet texture
  11763. */
  11764. texture: Texture;
  11765. /**
  11766. * Creates a new sprite manager
  11767. * @param name defines the manager's name
  11768. * @param imgUrl defines the sprite sheet url
  11769. * @param capacity defines the maximum allowed number of sprites
  11770. * @param cellSize defines the size of a sprite cell
  11771. * @param scene defines the hosting scene
  11772. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11773. * @param samplingMode defines the smapling mode to use with spritesheet
  11774. */
  11775. constructor(
  11776. /** defines the manager's name */
  11777. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11778. private _appendSpriteVertex;
  11779. /**
  11780. * Intersects the sprites with a ray
  11781. * @param ray defines the ray to intersect with
  11782. * @param camera defines the current active camera
  11783. * @param predicate defines a predicate used to select candidate sprites
  11784. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11785. * @returns null if no hit or a PickingInfo
  11786. */
  11787. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11788. /**
  11789. * Render all child sprites
  11790. */
  11791. render(): void;
  11792. /**
  11793. * Release associated resources
  11794. */
  11795. dispose(): void;
  11796. }
  11797. }
  11798. declare module BABYLON {
  11799. /**
  11800. * Class used to represent a sprite
  11801. * @see http://doc.babylonjs.com/babylon101/sprites
  11802. */
  11803. export class Sprite {
  11804. /** defines the name */
  11805. name: string;
  11806. /** Gets or sets the current world position */
  11807. position: Vector3;
  11808. /** Gets or sets the main color */
  11809. color: Color4;
  11810. /** Gets or sets the width */
  11811. width: number;
  11812. /** Gets or sets the height */
  11813. height: number;
  11814. /** Gets or sets rotation angle */
  11815. angle: number;
  11816. /** Gets or sets the cell index in the sprite sheet */
  11817. cellIndex: number;
  11818. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11819. invertU: number;
  11820. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11821. invertV: number;
  11822. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11823. disposeWhenFinishedAnimating: boolean;
  11824. /** Gets the list of attached animations */
  11825. animations: Animation[];
  11826. /** Gets or sets a boolean indicating if the sprite can be picked */
  11827. isPickable: boolean;
  11828. /**
  11829. * Gets or sets the associated action manager
  11830. */
  11831. actionManager: Nullable<ActionManager>;
  11832. private _animationStarted;
  11833. private _loopAnimation;
  11834. private _fromIndex;
  11835. private _toIndex;
  11836. private _delay;
  11837. private _direction;
  11838. private _manager;
  11839. private _time;
  11840. private _onAnimationEnd;
  11841. /**
  11842. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11843. */
  11844. isVisible: boolean;
  11845. /**
  11846. * Gets or sets the sprite size
  11847. */
  11848. size: number;
  11849. /**
  11850. * Creates a new Sprite
  11851. * @param name defines the name
  11852. * @param manager defines the manager
  11853. */
  11854. constructor(
  11855. /** defines the name */
  11856. name: string, manager: ISpriteManager);
  11857. /**
  11858. * Starts an animation
  11859. * @param from defines the initial key
  11860. * @param to defines the end key
  11861. * @param loop defines if the animation must loop
  11862. * @param delay defines the start delay (in ms)
  11863. * @param onAnimationEnd defines a callback to call when animation ends
  11864. */
  11865. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11866. /** Stops current animation (if any) */
  11867. stopAnimation(): void;
  11868. /** @hidden */
  11869. _animate(deltaTime: number): void;
  11870. /** Release associated resources */
  11871. dispose(): void;
  11872. }
  11873. }
  11874. declare module BABYLON {
  11875. /**
  11876. * Information about the result of picking within a scene
  11877. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11878. */
  11879. export class PickingInfo {
  11880. /** @hidden */
  11881. _pickingUnavailable: boolean;
  11882. /**
  11883. * If the pick collided with an object
  11884. */
  11885. hit: boolean;
  11886. /**
  11887. * Distance away where the pick collided
  11888. */
  11889. distance: number;
  11890. /**
  11891. * The location of pick collision
  11892. */
  11893. pickedPoint: Nullable<Vector3>;
  11894. /**
  11895. * The mesh corresponding the the pick collision
  11896. */
  11897. pickedMesh: Nullable<AbstractMesh>;
  11898. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11899. bu: number;
  11900. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11901. bv: number;
  11902. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11903. faceId: number;
  11904. /** Id of the the submesh that was picked */
  11905. subMeshId: number;
  11906. /** If a sprite was picked, this will be the sprite the pick collided with */
  11907. pickedSprite: Nullable<Sprite>;
  11908. /**
  11909. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11910. */
  11911. originMesh: Nullable<AbstractMesh>;
  11912. /**
  11913. * The ray that was used to perform the picking.
  11914. */
  11915. ray: Nullable<Ray>;
  11916. /**
  11917. * Gets the normal correspodning to the face the pick collided with
  11918. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11919. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11920. * @returns The normal correspodning to the face the pick collided with
  11921. */
  11922. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11923. /**
  11924. * Gets the texture coordinates of where the pick occured
  11925. * @returns the vector containing the coordnates of the texture
  11926. */
  11927. getTextureCoordinates(): Nullable<Vector2>;
  11928. }
  11929. }
  11930. declare module BABYLON {
  11931. /**
  11932. * Gather the list of pointer event types as constants.
  11933. */
  11934. export class PointerEventTypes {
  11935. /**
  11936. * 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.
  11937. */
  11938. static readonly POINTERDOWN: number;
  11939. /**
  11940. * The pointerup event is fired when a pointer is no longer active.
  11941. */
  11942. static readonly POINTERUP: number;
  11943. /**
  11944. * The pointermove event is fired when a pointer changes coordinates.
  11945. */
  11946. static readonly POINTERMOVE: number;
  11947. /**
  11948. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11949. */
  11950. static readonly POINTERWHEEL: number;
  11951. /**
  11952. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11953. */
  11954. static readonly POINTERPICK: number;
  11955. /**
  11956. * The pointertap event is fired when a the object has been touched and released without drag.
  11957. */
  11958. static readonly POINTERTAP: number;
  11959. /**
  11960. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11961. */
  11962. static readonly POINTERDOUBLETAP: number;
  11963. }
  11964. /**
  11965. * Base class of pointer info types.
  11966. */
  11967. export class PointerInfoBase {
  11968. /**
  11969. * Defines the type of event (PointerEventTypes)
  11970. */
  11971. type: number;
  11972. /**
  11973. * Defines the related dom event
  11974. */
  11975. event: PointerEvent | MouseWheelEvent;
  11976. /**
  11977. * Instantiates the base class of pointers info.
  11978. * @param type Defines the type of event (PointerEventTypes)
  11979. * @param event Defines the related dom event
  11980. */
  11981. constructor(
  11982. /**
  11983. * Defines the type of event (PointerEventTypes)
  11984. */
  11985. type: number,
  11986. /**
  11987. * Defines the related dom event
  11988. */
  11989. event: PointerEvent | MouseWheelEvent);
  11990. }
  11991. /**
  11992. * This class is used to store pointer related info for the onPrePointerObservable event.
  11993. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11994. */
  11995. export class PointerInfoPre extends PointerInfoBase {
  11996. /**
  11997. * Ray from a pointer if availible (eg. 6dof controller)
  11998. */
  11999. ray: Nullable<Ray>;
  12000. /**
  12001. * Defines the local position of the pointer on the canvas.
  12002. */
  12003. localPosition: Vector2;
  12004. /**
  12005. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12006. */
  12007. skipOnPointerObservable: boolean;
  12008. /**
  12009. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12010. * @param type Defines the type of event (PointerEventTypes)
  12011. * @param event Defines the related dom event
  12012. * @param localX Defines the local x coordinates of the pointer when the event occured
  12013. * @param localY Defines the local y coordinates of the pointer when the event occured
  12014. */
  12015. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12016. }
  12017. /**
  12018. * This type contains all the data related to a pointer event in Babylon.js.
  12019. * 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.
  12020. */
  12021. export class PointerInfo extends PointerInfoBase {
  12022. /**
  12023. * Defines the picking info associated to the info (if any)\
  12024. */
  12025. pickInfo: Nullable<PickingInfo>;
  12026. /**
  12027. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12028. * @param type Defines the type of event (PointerEventTypes)
  12029. * @param event Defines the related dom event
  12030. * @param pickInfo Defines the picking info associated to the info (if any)\
  12031. */
  12032. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12033. /**
  12034. * Defines the picking info associated to the info (if any)\
  12035. */
  12036. pickInfo: Nullable<PickingInfo>);
  12037. }
  12038. /**
  12039. * Data relating to a touch event on the screen.
  12040. */
  12041. export interface PointerTouch {
  12042. /**
  12043. * X coordinate of touch.
  12044. */
  12045. x: number;
  12046. /**
  12047. * Y coordinate of touch.
  12048. */
  12049. y: number;
  12050. /**
  12051. * Id of touch. Unique for each finger.
  12052. */
  12053. pointerId: number;
  12054. /**
  12055. * Event type passed from DOM.
  12056. */
  12057. type: any;
  12058. }
  12059. }
  12060. declare module BABYLON {
  12061. /**
  12062. * Manage the mouse inputs to control the movement of a free camera.
  12063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12064. */
  12065. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12066. /**
  12067. * Define if touch is enabled in the mouse input
  12068. */
  12069. touchEnabled: boolean;
  12070. /**
  12071. * Defines the camera the input is attached to.
  12072. */
  12073. camera: FreeCamera;
  12074. /**
  12075. * Defines the buttons associated with the input to handle camera move.
  12076. */
  12077. buttons: number[];
  12078. /**
  12079. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12080. */
  12081. angularSensibility: number;
  12082. private _pointerInput;
  12083. private _onMouseMove;
  12084. private _observer;
  12085. private previousPosition;
  12086. /**
  12087. * Observable for when a pointer move event occurs containing the move offset
  12088. */
  12089. onPointerMovedObservable: Observable<{
  12090. offsetX: number;
  12091. offsetY: number;
  12092. }>;
  12093. /**
  12094. * @hidden
  12095. * If the camera should be rotated automatically based on pointer movement
  12096. */
  12097. _allowCameraRotation: boolean;
  12098. /**
  12099. * Manage the mouse inputs to control the movement of a free camera.
  12100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12101. * @param touchEnabled Defines if touch is enabled or not
  12102. */
  12103. constructor(
  12104. /**
  12105. * Define if touch is enabled in the mouse input
  12106. */
  12107. touchEnabled?: boolean);
  12108. /**
  12109. * Attach the input controls to a specific dom element to get the input from.
  12110. * @param element Defines the element the controls should be listened from
  12111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12112. */
  12113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12114. /**
  12115. * Called on JS contextmenu event.
  12116. * Override this method to provide functionality.
  12117. */
  12118. protected onContextMenu(evt: PointerEvent): void;
  12119. /**
  12120. * Detach the current controls from the specified dom element.
  12121. * @param element Defines the element to stop listening the inputs from
  12122. */
  12123. detachControl(element: Nullable<HTMLElement>): void;
  12124. /**
  12125. * Gets the class name of the current intput.
  12126. * @returns the class name
  12127. */
  12128. getClassName(): string;
  12129. /**
  12130. * Get the friendly name associated with the input class.
  12131. * @returns the input friendly name
  12132. */
  12133. getSimpleName(): string;
  12134. }
  12135. }
  12136. declare module BABYLON {
  12137. /**
  12138. * Manage the touch inputs to control the movement of a free camera.
  12139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12140. */
  12141. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12142. /**
  12143. * Defines the camera the input is attached to.
  12144. */
  12145. camera: FreeCamera;
  12146. /**
  12147. * Defines the touch sensibility for rotation.
  12148. * The higher the faster.
  12149. */
  12150. touchAngularSensibility: number;
  12151. /**
  12152. * Defines the touch sensibility for move.
  12153. * The higher the faster.
  12154. */
  12155. touchMoveSensibility: number;
  12156. private _offsetX;
  12157. private _offsetY;
  12158. private _pointerPressed;
  12159. private _pointerInput;
  12160. private _observer;
  12161. private _onLostFocus;
  12162. /**
  12163. * Attach the input controls to a specific dom element to get the input from.
  12164. * @param element Defines the element the controls should be listened from
  12165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12166. */
  12167. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12168. /**
  12169. * Detach the current controls from the specified dom element.
  12170. * @param element Defines the element to stop listening the inputs from
  12171. */
  12172. detachControl(element: Nullable<HTMLElement>): void;
  12173. /**
  12174. * Update the current camera state depending on the inputs that have been used this frame.
  12175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12176. */
  12177. checkInputs(): void;
  12178. /**
  12179. * Gets the class name of the current intput.
  12180. * @returns the class name
  12181. */
  12182. getClassName(): string;
  12183. /**
  12184. * Get the friendly name associated with the input class.
  12185. * @returns the input friendly name
  12186. */
  12187. getSimpleName(): string;
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Default Inputs manager for the FreeCamera.
  12193. * It groups all the default supported inputs for ease of use.
  12194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12195. */
  12196. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12197. /**
  12198. * @hidden
  12199. */
  12200. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12201. /**
  12202. * @hidden
  12203. */
  12204. _mouseInput: Nullable<FreeCameraMouseInput>;
  12205. /**
  12206. * Instantiates a new FreeCameraInputsManager.
  12207. * @param camera Defines the camera the inputs belong to
  12208. */
  12209. constructor(camera: FreeCamera);
  12210. /**
  12211. * Add keyboard input support to the input manager.
  12212. * @returns the current input manager
  12213. */
  12214. addKeyboard(): FreeCameraInputsManager;
  12215. /**
  12216. * Add mouse input support to the input manager.
  12217. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12218. * @returns the current input manager
  12219. */
  12220. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12221. /**
  12222. * Removes the mouse input support from the manager
  12223. * @returns the current input manager
  12224. */
  12225. removeMouse(): FreeCameraInputsManager;
  12226. /**
  12227. * Add touch input support to the input manager.
  12228. * @returns the current input manager
  12229. */
  12230. addTouch(): FreeCameraInputsManager;
  12231. }
  12232. }
  12233. declare module BABYLON {
  12234. /**
  12235. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12236. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12238. */
  12239. export class FreeCamera extends TargetCamera {
  12240. /**
  12241. * Define the collision ellipsoid of the camera.
  12242. * This is helpful to simulate a camera body like the player body around the camera
  12243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12244. */
  12245. ellipsoid: Vector3;
  12246. /**
  12247. * Define an offset for the position of the ellipsoid around the camera.
  12248. * This can be helpful to determine the center of the body near the gravity center of the body
  12249. * instead of its head.
  12250. */
  12251. ellipsoidOffset: Vector3;
  12252. /**
  12253. * Enable or disable collisions of the camera with the rest of the scene objects.
  12254. */
  12255. checkCollisions: boolean;
  12256. /**
  12257. * Enable or disable gravity on the camera.
  12258. */
  12259. applyGravity: boolean;
  12260. /**
  12261. * Define the input manager associated to the camera.
  12262. */
  12263. inputs: FreeCameraInputsManager;
  12264. /**
  12265. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12266. * Higher values reduce sensitivity.
  12267. */
  12268. /**
  12269. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12270. * Higher values reduce sensitivity.
  12271. */
  12272. angularSensibility: number;
  12273. /**
  12274. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12275. */
  12276. keysUp: number[];
  12277. /**
  12278. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12279. */
  12280. keysDown: number[];
  12281. /**
  12282. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12283. */
  12284. keysLeft: number[];
  12285. /**
  12286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12287. */
  12288. keysRight: number[];
  12289. /**
  12290. * Event raised when the camera collide with a mesh in the scene.
  12291. */
  12292. onCollide: (collidedMesh: AbstractMesh) => void;
  12293. private _collider;
  12294. private _needMoveForGravity;
  12295. private _oldPosition;
  12296. private _diffPosition;
  12297. private _newPosition;
  12298. /** @hidden */
  12299. _localDirection: Vector3;
  12300. /** @hidden */
  12301. _transformedDirection: Vector3;
  12302. /**
  12303. * Instantiates a Free Camera.
  12304. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12305. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12307. * @param name Define the name of the camera in the scene
  12308. * @param position Define the start position of the camera in the scene
  12309. * @param scene Define the scene the camera belongs to
  12310. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12311. */
  12312. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12313. /**
  12314. * Attached controls to the current camera.
  12315. * @param element Defines the element the controls should be listened from
  12316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12317. */
  12318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12319. /**
  12320. * Detach the current controls from the camera.
  12321. * The camera will stop reacting to inputs.
  12322. * @param element Defines the element to stop listening the inputs from
  12323. */
  12324. detachControl(element: HTMLElement): void;
  12325. private _collisionMask;
  12326. /**
  12327. * Define a collision mask to limit the list of object the camera can collide with
  12328. */
  12329. collisionMask: number;
  12330. /** @hidden */
  12331. _collideWithWorld(displacement: Vector3): void;
  12332. private _onCollisionPositionChange;
  12333. /** @hidden */
  12334. _checkInputs(): void;
  12335. /** @hidden */
  12336. _decideIfNeedsToMove(): boolean;
  12337. /** @hidden */
  12338. _updatePosition(): void;
  12339. /**
  12340. * Destroy the camera and release the current resources hold by it.
  12341. */
  12342. dispose(): void;
  12343. /**
  12344. * Gets the current object class name.
  12345. * @return the class name
  12346. */
  12347. getClassName(): string;
  12348. }
  12349. }
  12350. declare module BABYLON {
  12351. /**
  12352. * Represents a gamepad control stick position
  12353. */
  12354. export class StickValues {
  12355. /**
  12356. * The x component of the control stick
  12357. */
  12358. x: number;
  12359. /**
  12360. * The y component of the control stick
  12361. */
  12362. y: number;
  12363. /**
  12364. * Initializes the gamepad x and y control stick values
  12365. * @param x The x component of the gamepad control stick value
  12366. * @param y The y component of the gamepad control stick value
  12367. */
  12368. constructor(
  12369. /**
  12370. * The x component of the control stick
  12371. */
  12372. x: number,
  12373. /**
  12374. * The y component of the control stick
  12375. */
  12376. y: number);
  12377. }
  12378. /**
  12379. * An interface which manages callbacks for gamepad button changes
  12380. */
  12381. export interface GamepadButtonChanges {
  12382. /**
  12383. * Called when a gamepad has been changed
  12384. */
  12385. changed: boolean;
  12386. /**
  12387. * Called when a gamepad press event has been triggered
  12388. */
  12389. pressChanged: boolean;
  12390. /**
  12391. * Called when a touch event has been triggered
  12392. */
  12393. touchChanged: boolean;
  12394. /**
  12395. * Called when a value has changed
  12396. */
  12397. valueChanged: boolean;
  12398. }
  12399. /**
  12400. * Represents a gamepad
  12401. */
  12402. export class Gamepad {
  12403. /**
  12404. * The id of the gamepad
  12405. */
  12406. id: string;
  12407. /**
  12408. * The index of the gamepad
  12409. */
  12410. index: number;
  12411. /**
  12412. * The browser gamepad
  12413. */
  12414. browserGamepad: any;
  12415. /**
  12416. * Specifies what type of gamepad this represents
  12417. */
  12418. type: number;
  12419. private _leftStick;
  12420. private _rightStick;
  12421. /** @hidden */
  12422. _isConnected: boolean;
  12423. private _leftStickAxisX;
  12424. private _leftStickAxisY;
  12425. private _rightStickAxisX;
  12426. private _rightStickAxisY;
  12427. /**
  12428. * Triggered when the left control stick has been changed
  12429. */
  12430. private _onleftstickchanged;
  12431. /**
  12432. * Triggered when the right control stick has been changed
  12433. */
  12434. private _onrightstickchanged;
  12435. /**
  12436. * Represents a gamepad controller
  12437. */
  12438. static GAMEPAD: number;
  12439. /**
  12440. * Represents a generic controller
  12441. */
  12442. static GENERIC: number;
  12443. /**
  12444. * Represents an XBox controller
  12445. */
  12446. static XBOX: number;
  12447. /**
  12448. * Represents a pose-enabled controller
  12449. */
  12450. static POSE_ENABLED: number;
  12451. /**
  12452. * Specifies whether the left control stick should be Y-inverted
  12453. */
  12454. protected _invertLeftStickY: boolean;
  12455. /**
  12456. * Specifies if the gamepad has been connected
  12457. */
  12458. readonly isConnected: boolean;
  12459. /**
  12460. * Initializes the gamepad
  12461. * @param id The id of the gamepad
  12462. * @param index The index of the gamepad
  12463. * @param browserGamepad The browser gamepad
  12464. * @param leftStickX The x component of the left joystick
  12465. * @param leftStickY The y component of the left joystick
  12466. * @param rightStickX The x component of the right joystick
  12467. * @param rightStickY The y component of the right joystick
  12468. */
  12469. constructor(
  12470. /**
  12471. * The id of the gamepad
  12472. */
  12473. id: string,
  12474. /**
  12475. * The index of the gamepad
  12476. */
  12477. index: number,
  12478. /**
  12479. * The browser gamepad
  12480. */
  12481. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12482. /**
  12483. * Callback triggered when the left joystick has changed
  12484. * @param callback
  12485. */
  12486. onleftstickchanged(callback: (values: StickValues) => void): void;
  12487. /**
  12488. * Callback triggered when the right joystick has changed
  12489. * @param callback
  12490. */
  12491. onrightstickchanged(callback: (values: StickValues) => void): void;
  12492. /**
  12493. * Gets the left joystick
  12494. */
  12495. /**
  12496. * Sets the left joystick values
  12497. */
  12498. leftStick: StickValues;
  12499. /**
  12500. * Gets the right joystick
  12501. */
  12502. /**
  12503. * Sets the right joystick value
  12504. */
  12505. rightStick: StickValues;
  12506. /**
  12507. * Updates the gamepad joystick positions
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Disposes the gamepad
  12512. */
  12513. dispose(): void;
  12514. }
  12515. /**
  12516. * Represents a generic gamepad
  12517. */
  12518. export class GenericPad extends Gamepad {
  12519. private _buttons;
  12520. private _onbuttondown;
  12521. private _onbuttonup;
  12522. /**
  12523. * Observable triggered when a button has been pressed
  12524. */
  12525. onButtonDownObservable: Observable<number>;
  12526. /**
  12527. * Observable triggered when a button has been released
  12528. */
  12529. onButtonUpObservable: Observable<number>;
  12530. /**
  12531. * Callback triggered when a button has been pressed
  12532. * @param callback Called when a button has been pressed
  12533. */
  12534. onbuttondown(callback: (buttonPressed: number) => void): void;
  12535. /**
  12536. * Callback triggered when a button has been released
  12537. * @param callback Called when a button has been released
  12538. */
  12539. onbuttonup(callback: (buttonReleased: number) => void): void;
  12540. /**
  12541. * Initializes the generic gamepad
  12542. * @param id The id of the generic gamepad
  12543. * @param index The index of the generic gamepad
  12544. * @param browserGamepad The browser gamepad
  12545. */
  12546. constructor(id: string, index: number, browserGamepad: any);
  12547. private _setButtonValue;
  12548. /**
  12549. * Updates the generic gamepad
  12550. */
  12551. update(): void;
  12552. /**
  12553. * Disposes the generic gamepad
  12554. */
  12555. dispose(): void;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. /**
  12560. * Defines the types of pose enabled controllers that are supported
  12561. */
  12562. export enum PoseEnabledControllerType {
  12563. /**
  12564. * HTC Vive
  12565. */
  12566. VIVE = 0,
  12567. /**
  12568. * Oculus Rift
  12569. */
  12570. OCULUS = 1,
  12571. /**
  12572. * Windows mixed reality
  12573. */
  12574. WINDOWS = 2,
  12575. /**
  12576. * Samsung gear VR
  12577. */
  12578. GEAR_VR = 3,
  12579. /**
  12580. * Google Daydream
  12581. */
  12582. DAYDREAM = 4,
  12583. /**
  12584. * Generic
  12585. */
  12586. GENERIC = 5
  12587. }
  12588. /**
  12589. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12590. */
  12591. export interface MutableGamepadButton {
  12592. /**
  12593. * Value of the button/trigger
  12594. */
  12595. value: number;
  12596. /**
  12597. * If the button/trigger is currently touched
  12598. */
  12599. touched: boolean;
  12600. /**
  12601. * If the button/trigger is currently pressed
  12602. */
  12603. pressed: boolean;
  12604. }
  12605. /**
  12606. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12607. * @hidden
  12608. */
  12609. export interface ExtendedGamepadButton extends GamepadButton {
  12610. /**
  12611. * If the button/trigger is currently pressed
  12612. */
  12613. readonly pressed: boolean;
  12614. /**
  12615. * If the button/trigger is currently touched
  12616. */
  12617. readonly touched: boolean;
  12618. /**
  12619. * Value of the button/trigger
  12620. */
  12621. readonly value: number;
  12622. }
  12623. /** @hidden */
  12624. export interface _GamePadFactory {
  12625. /**
  12626. * Returns wether or not the current gamepad can be created for this type of controller.
  12627. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12628. * @returns true if it can be created, otherwise false
  12629. */
  12630. canCreate(gamepadInfo: any): boolean;
  12631. /**
  12632. * Creates a new instance of the Gamepad.
  12633. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12634. * @returns the new gamepad instance
  12635. */
  12636. create(gamepadInfo: any): Gamepad;
  12637. }
  12638. /**
  12639. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12640. */
  12641. export class PoseEnabledControllerHelper {
  12642. /** @hidden */
  12643. static _ControllerFactories: _GamePadFactory[];
  12644. /** @hidden */
  12645. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12646. /**
  12647. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12648. * @param vrGamepad the gamepad to initialized
  12649. * @returns a vr controller of the type the gamepad identified as
  12650. */
  12651. static InitiateController(vrGamepad: any): Gamepad;
  12652. }
  12653. /**
  12654. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12655. */
  12656. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12657. private _deviceRoomPosition;
  12658. private _deviceRoomRotationQuaternion;
  12659. /**
  12660. * The device position in babylon space
  12661. */
  12662. devicePosition: Vector3;
  12663. /**
  12664. * The device rotation in babylon space
  12665. */
  12666. deviceRotationQuaternion: Quaternion;
  12667. /**
  12668. * The scale factor of the device in babylon space
  12669. */
  12670. deviceScaleFactor: number;
  12671. /**
  12672. * (Likely devicePosition should be used instead) The device position in its room space
  12673. */
  12674. position: Vector3;
  12675. /**
  12676. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12677. */
  12678. rotationQuaternion: Quaternion;
  12679. /**
  12680. * The type of controller (Eg. Windows mixed reality)
  12681. */
  12682. controllerType: PoseEnabledControllerType;
  12683. protected _calculatedPosition: Vector3;
  12684. private _calculatedRotation;
  12685. /**
  12686. * The raw pose from the device
  12687. */
  12688. rawPose: DevicePose;
  12689. private _trackPosition;
  12690. private _maxRotationDistFromHeadset;
  12691. private _draggedRoomRotation;
  12692. /**
  12693. * @hidden
  12694. */
  12695. _disableTrackPosition(fixedPosition: Vector3): void;
  12696. /**
  12697. * Internal, the mesh attached to the controller
  12698. * @hidden
  12699. */
  12700. _mesh: Nullable<AbstractMesh>;
  12701. private _poseControlledCamera;
  12702. private _leftHandSystemQuaternion;
  12703. /**
  12704. * Internal, matrix used to convert room space to babylon space
  12705. * @hidden
  12706. */
  12707. _deviceToWorld: Matrix;
  12708. /**
  12709. * Node to be used when casting a ray from the controller
  12710. * @hidden
  12711. */
  12712. _pointingPoseNode: Nullable<TransformNode>;
  12713. /**
  12714. * Name of the child mesh that can be used to cast a ray from the controller
  12715. */
  12716. static readonly POINTING_POSE: string;
  12717. /**
  12718. * Creates a new PoseEnabledController from a gamepad
  12719. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12720. */
  12721. constructor(browserGamepad: any);
  12722. private _workingMatrix;
  12723. /**
  12724. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12725. */
  12726. update(): void;
  12727. /**
  12728. * Updates only the pose device and mesh without doing any button event checking
  12729. */
  12730. protected _updatePoseAndMesh(): void;
  12731. /**
  12732. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12733. * @param poseData raw pose fromthe device
  12734. */
  12735. updateFromDevice(poseData: DevicePose): void;
  12736. /**
  12737. * @hidden
  12738. */
  12739. _meshAttachedObservable: Observable<AbstractMesh>;
  12740. /**
  12741. * Attaches a mesh to the controller
  12742. * @param mesh the mesh to be attached
  12743. */
  12744. attachToMesh(mesh: AbstractMesh): void;
  12745. /**
  12746. * Attaches the controllers mesh to a camera
  12747. * @param camera the camera the mesh should be attached to
  12748. */
  12749. attachToPoseControlledCamera(camera: TargetCamera): void;
  12750. /**
  12751. * Disposes of the controller
  12752. */
  12753. dispose(): void;
  12754. /**
  12755. * The mesh that is attached to the controller
  12756. */
  12757. readonly mesh: Nullable<AbstractMesh>;
  12758. /**
  12759. * Gets the ray of the controller in the direction the controller is pointing
  12760. * @param length the length the resulting ray should be
  12761. * @returns a ray in the direction the controller is pointing
  12762. */
  12763. getForwardRay(length?: number): Ray;
  12764. }
  12765. }
  12766. declare module BABYLON {
  12767. /**
  12768. * Defines the WebVRController object that represents controllers tracked in 3D space
  12769. */
  12770. export abstract class WebVRController extends PoseEnabledController {
  12771. /**
  12772. * Internal, the default controller model for the controller
  12773. */
  12774. protected _defaultModel: AbstractMesh;
  12775. /**
  12776. * Fired when the trigger state has changed
  12777. */
  12778. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12779. /**
  12780. * Fired when the main button state has changed
  12781. */
  12782. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12783. /**
  12784. * Fired when the secondary button state has changed
  12785. */
  12786. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12787. /**
  12788. * Fired when the pad state has changed
  12789. */
  12790. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12791. /**
  12792. * Fired when controllers stick values have changed
  12793. */
  12794. onPadValuesChangedObservable: Observable<StickValues>;
  12795. /**
  12796. * Array of button availible on the controller
  12797. */
  12798. protected _buttons: Array<MutableGamepadButton>;
  12799. private _onButtonStateChange;
  12800. /**
  12801. * Fired when a controller button's state has changed
  12802. * @param callback the callback containing the button that was modified
  12803. */
  12804. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12805. /**
  12806. * X and Y axis corrisponding to the controllers joystick
  12807. */
  12808. pad: StickValues;
  12809. /**
  12810. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12811. */
  12812. hand: string;
  12813. /**
  12814. * The default controller model for the controller
  12815. */
  12816. readonly defaultModel: AbstractMesh;
  12817. /**
  12818. * Creates a new WebVRController from a gamepad
  12819. * @param vrGamepad the gamepad that the WebVRController should be created from
  12820. */
  12821. constructor(vrGamepad: any);
  12822. /**
  12823. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12824. */
  12825. update(): void;
  12826. /**
  12827. * Function to be called when a button is modified
  12828. */
  12829. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12830. /**
  12831. * Loads a mesh and attaches it to the controller
  12832. * @param scene the scene the mesh should be added to
  12833. * @param meshLoaded callback for when the mesh has been loaded
  12834. */
  12835. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12836. private _setButtonValue;
  12837. private _changes;
  12838. private _checkChanges;
  12839. /**
  12840. * Disposes of th webVRCOntroller
  12841. */
  12842. dispose(): void;
  12843. }
  12844. }
  12845. declare module BABYLON {
  12846. /**
  12847. * The HemisphericLight simulates the ambient environment light,
  12848. * so the passed direction is the light reflection direction, not the incoming direction.
  12849. */
  12850. export class HemisphericLight extends Light {
  12851. /**
  12852. * The groundColor is the light in the opposite direction to the one specified during creation.
  12853. * 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.
  12854. */
  12855. groundColor: Color3;
  12856. /**
  12857. * The light reflection direction, not the incoming direction.
  12858. */
  12859. direction: Vector3;
  12860. /**
  12861. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12862. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12863. * The HemisphericLight can't cast shadows.
  12864. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12865. * @param name The friendly name of the light
  12866. * @param direction The direction of the light reflection
  12867. * @param scene The scene the light belongs to
  12868. */
  12869. constructor(name: string, direction: Vector3, scene: Scene);
  12870. protected _buildUniformLayout(): void;
  12871. /**
  12872. * Returns the string "HemisphericLight".
  12873. * @return The class name
  12874. */
  12875. getClassName(): string;
  12876. /**
  12877. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12878. * Returns the updated direction.
  12879. * @param target The target the direction should point to
  12880. * @return The computed direction
  12881. */
  12882. setDirectionToTarget(target: Vector3): Vector3;
  12883. /**
  12884. * Returns the shadow generator associated to the light.
  12885. * @returns Always null for hemispheric lights because it does not support shadows.
  12886. */
  12887. getShadowGenerator(): Nullable<IShadowGenerator>;
  12888. /**
  12889. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12890. * @param effect The effect to update
  12891. * @param lightIndex The index of the light in the effect to update
  12892. * @returns The hemispheric light
  12893. */
  12894. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12895. /**
  12896. * Computes the world matrix of the node
  12897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12898. * @param useWasUpdatedFlag defines a reserved property
  12899. * @returns the world matrix
  12900. */
  12901. computeWorldMatrix(): Matrix;
  12902. /**
  12903. * Returns the integer 3.
  12904. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12905. */
  12906. getTypeID(): number;
  12907. /**
  12908. * Prepares the list of defines specific to the light type.
  12909. * @param defines the list of defines
  12910. * @param lightIndex defines the index of the light for the effect
  12911. */
  12912. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12913. }
  12914. }
  12915. declare module BABYLON {
  12916. /** @hidden */
  12917. export var vrMultiviewToSingleviewPixelShader: {
  12918. name: string;
  12919. shader: string;
  12920. };
  12921. }
  12922. declare module BABYLON {
  12923. /**
  12924. * Renders to multiple views with a single draw call
  12925. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12926. */
  12927. export class MultiviewRenderTarget extends RenderTargetTexture {
  12928. /**
  12929. * Creates a multiview render target
  12930. * @param scene scene used with the render target
  12931. * @param size the size of the render target (used for each view)
  12932. */
  12933. constructor(scene: Scene, size?: number | {
  12934. width: number;
  12935. height: number;
  12936. } | {
  12937. ratio: number;
  12938. });
  12939. /**
  12940. * @hidden
  12941. * @param faceIndex the face index, if its a cube texture
  12942. */
  12943. _bindFrameBuffer(faceIndex?: number): void;
  12944. /**
  12945. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12946. * @returns the view count
  12947. */
  12948. getViewCount(): number;
  12949. }
  12950. }
  12951. declare module BABYLON {
  12952. interface Engine {
  12953. /**
  12954. * Creates a new multiview render target
  12955. * @param width defines the width of the texture
  12956. * @param height defines the height of the texture
  12957. * @returns the created multiview texture
  12958. */
  12959. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12960. /**
  12961. * Binds a multiview framebuffer to be drawn to
  12962. * @param multiviewTexture texture to bind
  12963. */
  12964. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12965. }
  12966. interface Camera {
  12967. /**
  12968. * @hidden
  12969. * 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)
  12970. */
  12971. _useMultiviewToSingleView: boolean;
  12972. /**
  12973. * @hidden
  12974. * 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)
  12975. */
  12976. _multiviewTexture: Nullable<RenderTargetTexture>;
  12977. /**
  12978. * @hidden
  12979. * ensures the multiview texture of the camera exists and has the specified width/height
  12980. * @param width height to set on the multiview texture
  12981. * @param height width to set on the multiview texture
  12982. */
  12983. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12984. }
  12985. interface Scene {
  12986. /** @hidden */
  12987. _transformMatrixR: Matrix;
  12988. /** @hidden */
  12989. _multiviewSceneUbo: Nullable<UniformBuffer>;
  12990. /** @hidden */
  12991. _createMultiviewUbo(): void;
  12992. /** @hidden */
  12993. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12994. /** @hidden */
  12995. _renderMultiviewToSingleView(camera: Camera): void;
  12996. }
  12997. }
  12998. declare module BABYLON {
  12999. /**
  13000. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13001. * This will not be used for webXR as it supports displaying texture arrays directly
  13002. */
  13003. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13004. /**
  13005. * Initializes a VRMultiviewToSingleview
  13006. * @param name name of the post process
  13007. * @param camera camera to be applied to
  13008. * @param scaleFactor scaling factor to the size of the output texture
  13009. */
  13010. constructor(name: string, camera: Camera, scaleFactor: number);
  13011. }
  13012. }
  13013. declare module BABYLON {
  13014. /**
  13015. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13016. * IMPORTANT!! The data is right-hand data.
  13017. * @export
  13018. * @interface DevicePose
  13019. */
  13020. export interface DevicePose {
  13021. /**
  13022. * The position of the device, values in array are [x,y,z].
  13023. */
  13024. readonly position: Nullable<Float32Array>;
  13025. /**
  13026. * The linearVelocity of the device, values in array are [x,y,z].
  13027. */
  13028. readonly linearVelocity: Nullable<Float32Array>;
  13029. /**
  13030. * The linearAcceleration of the device, values in array are [x,y,z].
  13031. */
  13032. readonly linearAcceleration: Nullable<Float32Array>;
  13033. /**
  13034. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13035. */
  13036. readonly orientation: Nullable<Float32Array>;
  13037. /**
  13038. * The angularVelocity of the device, values in array are [x,y,z].
  13039. */
  13040. readonly angularVelocity: Nullable<Float32Array>;
  13041. /**
  13042. * The angularAcceleration of the device, values in array are [x,y,z].
  13043. */
  13044. readonly angularAcceleration: Nullable<Float32Array>;
  13045. }
  13046. /**
  13047. * Interface representing a pose controlled object in Babylon.
  13048. * A pose controlled object has both regular pose values as well as pose values
  13049. * from an external device such as a VR head mounted display
  13050. */
  13051. export interface PoseControlled {
  13052. /**
  13053. * The position of the object in babylon space.
  13054. */
  13055. position: Vector3;
  13056. /**
  13057. * The rotation quaternion of the object in babylon space.
  13058. */
  13059. rotationQuaternion: Quaternion;
  13060. /**
  13061. * The position of the device in babylon space.
  13062. */
  13063. devicePosition?: Vector3;
  13064. /**
  13065. * The rotation quaternion of the device in babylon space.
  13066. */
  13067. deviceRotationQuaternion: Quaternion;
  13068. /**
  13069. * The raw pose coming from the device.
  13070. */
  13071. rawPose: Nullable<DevicePose>;
  13072. /**
  13073. * The scale of the device to be used when translating from device space to babylon space.
  13074. */
  13075. deviceScaleFactor: number;
  13076. /**
  13077. * Updates the poseControlled values based on the input device pose.
  13078. * @param poseData the pose data to update the object with
  13079. */
  13080. updateFromDevice(poseData: DevicePose): void;
  13081. }
  13082. /**
  13083. * Set of options to customize the webVRCamera
  13084. */
  13085. export interface WebVROptions {
  13086. /**
  13087. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13088. */
  13089. trackPosition?: boolean;
  13090. /**
  13091. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13092. */
  13093. positionScale?: number;
  13094. /**
  13095. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13096. */
  13097. displayName?: string;
  13098. /**
  13099. * Should the native controller meshes be initialized. (default: true)
  13100. */
  13101. controllerMeshes?: boolean;
  13102. /**
  13103. * Creating a default HemiLight only on controllers. (default: true)
  13104. */
  13105. defaultLightingOnControllers?: boolean;
  13106. /**
  13107. * If you don't want to use the default VR button of the helper. (default: false)
  13108. */
  13109. useCustomVRButton?: boolean;
  13110. /**
  13111. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13112. */
  13113. customVRButton?: HTMLButtonElement;
  13114. /**
  13115. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13116. */
  13117. rayLength?: number;
  13118. /**
  13119. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13120. */
  13121. defaultHeight?: number;
  13122. /**
  13123. * If multiview should be used if availible (default: false)
  13124. */
  13125. useMultiview?: boolean;
  13126. }
  13127. /**
  13128. * This represents a WebVR camera.
  13129. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13130. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13131. */
  13132. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13133. private webVROptions;
  13134. /**
  13135. * @hidden
  13136. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13137. */
  13138. _vrDevice: any;
  13139. /**
  13140. * The rawPose of the vrDevice.
  13141. */
  13142. rawPose: Nullable<DevicePose>;
  13143. private _onVREnabled;
  13144. private _specsVersion;
  13145. private _attached;
  13146. private _frameData;
  13147. protected _descendants: Array<Node>;
  13148. private _deviceRoomPosition;
  13149. /** @hidden */
  13150. _deviceRoomRotationQuaternion: Quaternion;
  13151. private _standingMatrix;
  13152. /**
  13153. * Represents device position in babylon space.
  13154. */
  13155. devicePosition: Vector3;
  13156. /**
  13157. * Represents device rotation in babylon space.
  13158. */
  13159. deviceRotationQuaternion: Quaternion;
  13160. /**
  13161. * The scale of the device to be used when translating from device space to babylon space.
  13162. */
  13163. deviceScaleFactor: number;
  13164. private _deviceToWorld;
  13165. private _worldToDevice;
  13166. /**
  13167. * References to the webVR controllers for the vrDevice.
  13168. */
  13169. controllers: Array<WebVRController>;
  13170. /**
  13171. * Emits an event when a controller is attached.
  13172. */
  13173. onControllersAttachedObservable: Observable<WebVRController[]>;
  13174. /**
  13175. * Emits an event when a controller's mesh has been loaded;
  13176. */
  13177. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13178. /**
  13179. * Emits an event when the HMD's pose has been updated.
  13180. */
  13181. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13182. private _poseSet;
  13183. /**
  13184. * If the rig cameras be used as parent instead of this camera.
  13185. */
  13186. rigParenting: boolean;
  13187. private _lightOnControllers;
  13188. private _defaultHeight?;
  13189. /**
  13190. * Instantiates a WebVRFreeCamera.
  13191. * @param name The name of the WebVRFreeCamera
  13192. * @param position The starting anchor position for the camera
  13193. * @param scene The scene the camera belongs to
  13194. * @param webVROptions a set of customizable options for the webVRCamera
  13195. */
  13196. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13197. /**
  13198. * Gets the device distance from the ground in meters.
  13199. * @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.
  13200. */
  13201. deviceDistanceToRoomGround(): number;
  13202. /**
  13203. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13204. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13205. */
  13206. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13207. /**
  13208. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13209. * @returns A promise with a boolean set to if the standing matrix is supported.
  13210. */
  13211. useStandingMatrixAsync(): Promise<boolean>;
  13212. /**
  13213. * Disposes the camera
  13214. */
  13215. dispose(): void;
  13216. /**
  13217. * Gets a vrController by name.
  13218. * @param name The name of the controller to retreive
  13219. * @returns the controller matching the name specified or null if not found
  13220. */
  13221. getControllerByName(name: string): Nullable<WebVRController>;
  13222. private _leftController;
  13223. /**
  13224. * The controller corrisponding to the users left hand.
  13225. */
  13226. readonly leftController: Nullable<WebVRController>;
  13227. private _rightController;
  13228. /**
  13229. * The controller corrisponding to the users right hand.
  13230. */
  13231. readonly rightController: Nullable<WebVRController>;
  13232. /**
  13233. * Casts a ray forward from the vrCamera's gaze.
  13234. * @param length Length of the ray (default: 100)
  13235. * @returns the ray corrisponding to the gaze
  13236. */
  13237. getForwardRay(length?: number): Ray;
  13238. /**
  13239. * @hidden
  13240. * Updates the camera based on device's frame data
  13241. */
  13242. _checkInputs(): void;
  13243. /**
  13244. * Updates the poseControlled values based on the input device pose.
  13245. * @param poseData Pose coming from the device
  13246. */
  13247. updateFromDevice(poseData: DevicePose): void;
  13248. private _htmlElementAttached;
  13249. private _detachIfAttached;
  13250. /**
  13251. * WebVR's attach control will start broadcasting frames to the device.
  13252. * Note that in certain browsers (chrome for example) this function must be called
  13253. * within a user-interaction callback. Example:
  13254. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13255. *
  13256. * @param element html element to attach the vrDevice to
  13257. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13258. */
  13259. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13260. /**
  13261. * Detaches the camera from the html element and disables VR
  13262. *
  13263. * @param element html element to detach from
  13264. */
  13265. detachControl(element: HTMLElement): void;
  13266. /**
  13267. * @returns the name of this class
  13268. */
  13269. getClassName(): string;
  13270. /**
  13271. * Calls resetPose on the vrDisplay
  13272. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13273. */
  13274. resetToCurrentRotation(): void;
  13275. /**
  13276. * @hidden
  13277. * Updates the rig cameras (left and right eye)
  13278. */
  13279. _updateRigCameras(): void;
  13280. private _workingVector;
  13281. private _oneVector;
  13282. private _workingMatrix;
  13283. private updateCacheCalled;
  13284. private _correctPositionIfNotTrackPosition;
  13285. /**
  13286. * @hidden
  13287. * Updates the cached values of the camera
  13288. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13289. */
  13290. _updateCache(ignoreParentClass?: boolean): void;
  13291. /**
  13292. * @hidden
  13293. * Get current device position in babylon world
  13294. */
  13295. _computeDevicePosition(): void;
  13296. /**
  13297. * Updates the current device position and rotation in the babylon world
  13298. */
  13299. update(): void;
  13300. /**
  13301. * @hidden
  13302. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13303. * @returns an identity matrix
  13304. */
  13305. _getViewMatrix(): Matrix;
  13306. private _tmpMatrix;
  13307. /**
  13308. * This function is called by the two RIG cameras.
  13309. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13310. * @hidden
  13311. */
  13312. _getWebVRViewMatrix(): Matrix;
  13313. /** @hidden */
  13314. _getWebVRProjectionMatrix(): Matrix;
  13315. private _onGamepadConnectedObserver;
  13316. private _onGamepadDisconnectedObserver;
  13317. private _updateCacheWhenTrackingDisabledObserver;
  13318. /**
  13319. * Initializes the controllers and their meshes
  13320. */
  13321. initControllers(): void;
  13322. }
  13323. }
  13324. declare module BABYLON {
  13325. /**
  13326. * Size options for a post process
  13327. */
  13328. export type PostProcessOptions = {
  13329. width: number;
  13330. height: number;
  13331. };
  13332. /**
  13333. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13334. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13335. */
  13336. export class PostProcess {
  13337. /** Name of the PostProcess. */
  13338. name: string;
  13339. /**
  13340. * Gets or sets the unique id of the post process
  13341. */
  13342. uniqueId: number;
  13343. /**
  13344. * Width of the texture to apply the post process on
  13345. */
  13346. width: number;
  13347. /**
  13348. * Height of the texture to apply the post process on
  13349. */
  13350. height: number;
  13351. /**
  13352. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13353. * @hidden
  13354. */
  13355. _outputTexture: Nullable<InternalTexture>;
  13356. /**
  13357. * Sampling mode used by the shader
  13358. * See https://doc.babylonjs.com/classes/3.1/texture
  13359. */
  13360. renderTargetSamplingMode: number;
  13361. /**
  13362. * Clear color to use when screen clearing
  13363. */
  13364. clearColor: Color4;
  13365. /**
  13366. * If the buffer needs to be cleared before applying the post process. (default: true)
  13367. * Should be set to false if shader will overwrite all previous pixels.
  13368. */
  13369. autoClear: boolean;
  13370. /**
  13371. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13372. */
  13373. alphaMode: number;
  13374. /**
  13375. * Sets the setAlphaBlendConstants of the babylon engine
  13376. */
  13377. alphaConstants: Color4;
  13378. /**
  13379. * Animations to be used for the post processing
  13380. */
  13381. animations: Animation[];
  13382. /**
  13383. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13384. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13385. */
  13386. enablePixelPerfectMode: boolean;
  13387. /**
  13388. * Force the postprocess to be applied without taking in account viewport
  13389. */
  13390. forceFullscreenViewport: boolean;
  13391. /**
  13392. * List of inspectable custom properties (used by the Inspector)
  13393. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13394. */
  13395. inspectableCustomProperties: IInspectable[];
  13396. /**
  13397. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13398. *
  13399. * | Value | Type | Description |
  13400. * | ----- | ----------------------------------- | ----------- |
  13401. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13402. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13403. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13404. *
  13405. */
  13406. scaleMode: number;
  13407. /**
  13408. * Force textures to be a power of two (default: false)
  13409. */
  13410. alwaysForcePOT: boolean;
  13411. private _samples;
  13412. /**
  13413. * Number of sample textures (default: 1)
  13414. */
  13415. samples: number;
  13416. /**
  13417. * Modify the scale of the post process to be the same as the viewport (default: false)
  13418. */
  13419. adaptScaleToCurrentViewport: boolean;
  13420. private _camera;
  13421. private _scene;
  13422. private _engine;
  13423. private _options;
  13424. private _reusable;
  13425. private _textureType;
  13426. /**
  13427. * Smart array of input and output textures for the post process.
  13428. * @hidden
  13429. */
  13430. _textures: SmartArray<InternalTexture>;
  13431. /**
  13432. * The index in _textures that corresponds to the output texture.
  13433. * @hidden
  13434. */
  13435. _currentRenderTextureInd: number;
  13436. private _effect;
  13437. private _samplers;
  13438. private _fragmentUrl;
  13439. private _vertexUrl;
  13440. private _parameters;
  13441. private _scaleRatio;
  13442. protected _indexParameters: any;
  13443. private _shareOutputWithPostProcess;
  13444. private _texelSize;
  13445. private _forcedOutputTexture;
  13446. /**
  13447. * Returns the fragment url or shader name used in the post process.
  13448. * @returns the fragment url or name in the shader store.
  13449. */
  13450. getEffectName(): string;
  13451. /**
  13452. * An event triggered when the postprocess is activated.
  13453. */
  13454. onActivateObservable: Observable<Camera>;
  13455. private _onActivateObserver;
  13456. /**
  13457. * A function that is added to the onActivateObservable
  13458. */
  13459. onActivate: Nullable<(camera: Camera) => void>;
  13460. /**
  13461. * An event triggered when the postprocess changes its size.
  13462. */
  13463. onSizeChangedObservable: Observable<PostProcess>;
  13464. private _onSizeChangedObserver;
  13465. /**
  13466. * A function that is added to the onSizeChangedObservable
  13467. */
  13468. onSizeChanged: (postProcess: PostProcess) => void;
  13469. /**
  13470. * An event triggered when the postprocess applies its effect.
  13471. */
  13472. onApplyObservable: Observable<Effect>;
  13473. private _onApplyObserver;
  13474. /**
  13475. * A function that is added to the onApplyObservable
  13476. */
  13477. onApply: (effect: Effect) => void;
  13478. /**
  13479. * An event triggered before rendering the postprocess
  13480. */
  13481. onBeforeRenderObservable: Observable<Effect>;
  13482. private _onBeforeRenderObserver;
  13483. /**
  13484. * A function that is added to the onBeforeRenderObservable
  13485. */
  13486. onBeforeRender: (effect: Effect) => void;
  13487. /**
  13488. * An event triggered after rendering the postprocess
  13489. */
  13490. onAfterRenderObservable: Observable<Effect>;
  13491. private _onAfterRenderObserver;
  13492. /**
  13493. * A function that is added to the onAfterRenderObservable
  13494. */
  13495. onAfterRender: (efect: Effect) => void;
  13496. /**
  13497. * 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
  13498. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13499. */
  13500. inputTexture: InternalTexture;
  13501. /**
  13502. * Gets the camera which post process is applied to.
  13503. * @returns The camera the post process is applied to.
  13504. */
  13505. getCamera(): Camera;
  13506. /**
  13507. * Gets the texel size of the postprocess.
  13508. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13509. */
  13510. readonly texelSize: Vector2;
  13511. /**
  13512. * Creates a new instance PostProcess
  13513. * @param name The name of the PostProcess.
  13514. * @param fragmentUrl The url of the fragment shader to be used.
  13515. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13516. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13517. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13518. * @param camera The camera to apply the render pass to.
  13519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13520. * @param engine The engine which the post process will be applied. (default: current engine)
  13521. * @param reusable If the post process can be reused on the same frame. (default: false)
  13522. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13523. * @param textureType Type of textures used when performing the post process. (default: 0)
  13524. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13525. * @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
  13526. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13527. */
  13528. constructor(
  13529. /** Name of the PostProcess. */
  13530. 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);
  13531. /**
  13532. * Gets a string idenfifying the name of the class
  13533. * @returns "PostProcess" string
  13534. */
  13535. getClassName(): string;
  13536. /**
  13537. * Gets the engine which this post process belongs to.
  13538. * @returns The engine the post process was enabled with.
  13539. */
  13540. getEngine(): Engine;
  13541. /**
  13542. * The effect that is created when initializing the post process.
  13543. * @returns The created effect corrisponding the the postprocess.
  13544. */
  13545. getEffect(): Effect;
  13546. /**
  13547. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13548. * @param postProcess The post process to share the output with.
  13549. * @returns This post process.
  13550. */
  13551. shareOutputWith(postProcess: PostProcess): PostProcess;
  13552. /**
  13553. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13554. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13555. */
  13556. useOwnOutput(): void;
  13557. /**
  13558. * Updates the effect with the current post process compile time values and recompiles the shader.
  13559. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13560. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13561. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13562. * @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
  13563. * @param onCompiled Called when the shader has been compiled.
  13564. * @param onError Called if there is an error when compiling a shader.
  13565. */
  13566. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13567. /**
  13568. * The post process is reusable if it can be used multiple times within one frame.
  13569. * @returns If the post process is reusable
  13570. */
  13571. isReusable(): boolean;
  13572. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13573. markTextureDirty(): void;
  13574. /**
  13575. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13576. * 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.
  13577. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13578. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13579. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13580. * @returns The target texture that was bound to be written to.
  13581. */
  13582. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13583. /**
  13584. * If the post process is supported.
  13585. */
  13586. readonly isSupported: boolean;
  13587. /**
  13588. * The aspect ratio of the output texture.
  13589. */
  13590. readonly aspectRatio: number;
  13591. /**
  13592. * Get a value indicating if the post-process is ready to be used
  13593. * @returns true if the post-process is ready (shader is compiled)
  13594. */
  13595. isReady(): boolean;
  13596. /**
  13597. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13598. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13599. */
  13600. apply(): Nullable<Effect>;
  13601. private _disposeTextures;
  13602. /**
  13603. * Disposes the post process.
  13604. * @param camera The camera to dispose the post process on.
  13605. */
  13606. dispose(camera?: Camera): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13612. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13613. */
  13614. export class PostProcessManager {
  13615. private _scene;
  13616. private _indexBuffer;
  13617. private _vertexBuffers;
  13618. /**
  13619. * Creates a new instance PostProcess
  13620. * @param scene The scene that the post process is associated with.
  13621. */
  13622. constructor(scene: Scene);
  13623. private _prepareBuffers;
  13624. private _buildIndexBuffer;
  13625. /**
  13626. * Rebuilds the vertex buffers of the manager.
  13627. * @hidden
  13628. */
  13629. _rebuild(): void;
  13630. /**
  13631. * Prepares a frame to be run through a post process.
  13632. * @param sourceTexture The input texture to the post procesess. (default: null)
  13633. * @param postProcesses An array of post processes to be run. (default: null)
  13634. * @returns True if the post processes were able to be run.
  13635. * @hidden
  13636. */
  13637. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13638. /**
  13639. * Manually render a set of post processes to a texture.
  13640. * @param postProcesses An array of post processes to be run.
  13641. * @param targetTexture The target texture to render to.
  13642. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13643. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13644. * @param lodLevel defines which lod of the texture to render to
  13645. */
  13646. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13647. /**
  13648. * Finalize the result of the output of the postprocesses.
  13649. * @param doNotPresent If true the result will not be displayed to the screen.
  13650. * @param targetTexture The target texture to render to.
  13651. * @param faceIndex The index of the face to bind the target texture to.
  13652. * @param postProcesses The array of post processes to render.
  13653. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13654. * @hidden
  13655. */
  13656. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13657. /**
  13658. * Disposes of the post process manager.
  13659. */
  13660. dispose(): void;
  13661. }
  13662. }
  13663. declare module BABYLON {
  13664. interface AbstractScene {
  13665. /**
  13666. * The list of layers (background and foreground) of the scene
  13667. */
  13668. layers: Array<Layer>;
  13669. }
  13670. /**
  13671. * Defines the layer scene component responsible to manage any layers
  13672. * in a given scene.
  13673. */
  13674. export class LayerSceneComponent implements ISceneComponent {
  13675. /**
  13676. * The component name helpfull to identify the component in the list of scene components.
  13677. */
  13678. readonly name: string;
  13679. /**
  13680. * The scene the component belongs to.
  13681. */
  13682. scene: Scene;
  13683. private _engine;
  13684. /**
  13685. * Creates a new instance of the component for the given scene
  13686. * @param scene Defines the scene to register the component in
  13687. */
  13688. constructor(scene: Scene);
  13689. /**
  13690. * Registers the component in a given scene
  13691. */
  13692. register(): void;
  13693. /**
  13694. * Rebuilds the elements related to this component in case of
  13695. * context lost for instance.
  13696. */
  13697. rebuild(): void;
  13698. /**
  13699. * Disposes the component and the associated ressources.
  13700. */
  13701. dispose(): void;
  13702. private _draw;
  13703. private _drawCameraPredicate;
  13704. private _drawCameraBackground;
  13705. private _drawCameraForeground;
  13706. private _drawRenderTargetPredicate;
  13707. private _drawRenderTargetBackground;
  13708. private _drawRenderTargetForeground;
  13709. }
  13710. }
  13711. declare module BABYLON {
  13712. /** @hidden */
  13713. export var layerPixelShader: {
  13714. name: string;
  13715. shader: string;
  13716. };
  13717. }
  13718. declare module BABYLON {
  13719. /** @hidden */
  13720. export var layerVertexShader: {
  13721. name: string;
  13722. shader: string;
  13723. };
  13724. }
  13725. declare module BABYLON {
  13726. /**
  13727. * This represents a full screen 2d layer.
  13728. * This can be useful to display a picture in the background of your scene for instance.
  13729. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13730. */
  13731. export class Layer {
  13732. /**
  13733. * Define the name of the layer.
  13734. */
  13735. name: string;
  13736. /**
  13737. * Define the texture the layer should display.
  13738. */
  13739. texture: Nullable<Texture>;
  13740. /**
  13741. * Is the layer in background or foreground.
  13742. */
  13743. isBackground: boolean;
  13744. /**
  13745. * Define the color of the layer (instead of texture).
  13746. */
  13747. color: Color4;
  13748. /**
  13749. * Define the scale of the layer in order to zoom in out of the texture.
  13750. */
  13751. scale: Vector2;
  13752. /**
  13753. * Define an offset for the layer in order to shift the texture.
  13754. */
  13755. offset: Vector2;
  13756. /**
  13757. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13758. */
  13759. alphaBlendingMode: number;
  13760. /**
  13761. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13762. * Alpha test will not mix with the background color in case of transparency.
  13763. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13764. */
  13765. alphaTest: boolean;
  13766. /**
  13767. * Define a mask to restrict the layer to only some of the scene cameras.
  13768. */
  13769. layerMask: number;
  13770. /**
  13771. * Define the list of render target the layer is visible into.
  13772. */
  13773. renderTargetTextures: RenderTargetTexture[];
  13774. /**
  13775. * Define if the layer is only used in renderTarget or if it also
  13776. * renders in the main frame buffer of the canvas.
  13777. */
  13778. renderOnlyInRenderTargetTextures: boolean;
  13779. private _scene;
  13780. private _vertexBuffers;
  13781. private _indexBuffer;
  13782. private _effect;
  13783. private _alphaTestEffect;
  13784. /**
  13785. * An event triggered when the layer is disposed.
  13786. */
  13787. onDisposeObservable: Observable<Layer>;
  13788. private _onDisposeObserver;
  13789. /**
  13790. * Back compatibility with callback before the onDisposeObservable existed.
  13791. * The set callback will be triggered when the layer has been disposed.
  13792. */
  13793. onDispose: () => void;
  13794. /**
  13795. * An event triggered before rendering the scene
  13796. */
  13797. onBeforeRenderObservable: Observable<Layer>;
  13798. private _onBeforeRenderObserver;
  13799. /**
  13800. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13801. * The set callback will be triggered just before rendering the layer.
  13802. */
  13803. onBeforeRender: () => void;
  13804. /**
  13805. * An event triggered after rendering the scene
  13806. */
  13807. onAfterRenderObservable: Observable<Layer>;
  13808. private _onAfterRenderObserver;
  13809. /**
  13810. * Back compatibility with callback before the onAfterRenderObservable existed.
  13811. * The set callback will be triggered just after rendering the layer.
  13812. */
  13813. onAfterRender: () => void;
  13814. /**
  13815. * Instantiates a new layer.
  13816. * This represents a full screen 2d layer.
  13817. * This can be useful to display a picture in the background of your scene for instance.
  13818. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13819. * @param name Define the name of the layer in the scene
  13820. * @param imgUrl Define the url of the texture to display in the layer
  13821. * @param scene Define the scene the layer belongs to
  13822. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13823. * @param color Defines a color for the layer
  13824. */
  13825. constructor(
  13826. /**
  13827. * Define the name of the layer.
  13828. */
  13829. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13830. private _createIndexBuffer;
  13831. /** @hidden */
  13832. _rebuild(): void;
  13833. /**
  13834. * Renders the layer in the scene.
  13835. */
  13836. render(): void;
  13837. /**
  13838. * Disposes and releases the associated ressources.
  13839. */
  13840. dispose(): void;
  13841. }
  13842. }
  13843. declare module BABYLON {
  13844. interface AbstractScene {
  13845. /**
  13846. * The list of procedural textures added to the scene
  13847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13848. */
  13849. proceduralTextures: Array<ProceduralTexture>;
  13850. }
  13851. /**
  13852. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13853. * in a given scene.
  13854. */
  13855. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13856. /**
  13857. * The component name helpfull to identify the component in the list of scene components.
  13858. */
  13859. readonly name: string;
  13860. /**
  13861. * The scene the component belongs to.
  13862. */
  13863. scene: Scene;
  13864. /**
  13865. * Creates a new instance of the component for the given scene
  13866. * @param scene Defines the scene to register the component in
  13867. */
  13868. constructor(scene: Scene);
  13869. /**
  13870. * Registers the component in a given scene
  13871. */
  13872. register(): void;
  13873. /**
  13874. * Rebuilds the elements related to this component in case of
  13875. * context lost for instance.
  13876. */
  13877. rebuild(): void;
  13878. /**
  13879. * Disposes the component and the associated ressources.
  13880. */
  13881. dispose(): void;
  13882. private _beforeClear;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /** @hidden */
  13887. export var proceduralVertexShader: {
  13888. name: string;
  13889. shader: string;
  13890. };
  13891. }
  13892. declare module BABYLON {
  13893. /**
  13894. * 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.
  13895. * This is the base class of any Procedural texture and contains most of the shareable code.
  13896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13897. */
  13898. export class ProceduralTexture extends Texture {
  13899. isCube: boolean;
  13900. /**
  13901. * Define if the texture is enabled or not (disabled texture will not render)
  13902. */
  13903. isEnabled: boolean;
  13904. /**
  13905. * Define if the texture must be cleared before rendering (default is true)
  13906. */
  13907. autoClear: boolean;
  13908. /**
  13909. * Callback called when the texture is generated
  13910. */
  13911. onGenerated: () => void;
  13912. /**
  13913. * Event raised when the texture is generated
  13914. */
  13915. onGeneratedObservable: Observable<ProceduralTexture>;
  13916. /** @hidden */
  13917. _generateMipMaps: boolean;
  13918. /** @hidden **/
  13919. _effect: Effect;
  13920. /** @hidden */
  13921. _textures: {
  13922. [key: string]: Texture;
  13923. };
  13924. private _size;
  13925. private _currentRefreshId;
  13926. private _refreshRate;
  13927. private _vertexBuffers;
  13928. private _indexBuffer;
  13929. private _uniforms;
  13930. private _samplers;
  13931. private _fragment;
  13932. private _floats;
  13933. private _ints;
  13934. private _floatsArrays;
  13935. private _colors3;
  13936. private _colors4;
  13937. private _vectors2;
  13938. private _vectors3;
  13939. private _matrices;
  13940. private _fallbackTexture;
  13941. private _fallbackTextureUsed;
  13942. private _engine;
  13943. private _cachedDefines;
  13944. private _contentUpdateId;
  13945. private _contentData;
  13946. /**
  13947. * Instantiates a new procedural texture.
  13948. * 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.
  13949. * This is the base class of any Procedural texture and contains most of the shareable code.
  13950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13951. * @param name Define the name of the texture
  13952. * @param size Define the size of the texture to create
  13953. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13954. * @param scene Define the scene the texture belongs to
  13955. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13956. * @param generateMipMaps Define if the texture should creates mip maps or not
  13957. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13958. */
  13959. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13960. /**
  13961. * The effect that is created when initializing the post process.
  13962. * @returns The created effect corrisponding the the postprocess.
  13963. */
  13964. getEffect(): Effect;
  13965. /**
  13966. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13967. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13968. */
  13969. getContent(): Nullable<ArrayBufferView>;
  13970. private _createIndexBuffer;
  13971. /** @hidden */
  13972. _rebuild(): void;
  13973. /**
  13974. * Resets the texture in order to recreate its associated resources.
  13975. * This can be called in case of context loss
  13976. */
  13977. reset(): void;
  13978. protected _getDefines(): string;
  13979. /**
  13980. * Is the texture ready to be used ? (rendered at least once)
  13981. * @returns true if ready, otherwise, false.
  13982. */
  13983. isReady(): boolean;
  13984. /**
  13985. * Resets the refresh counter of the texture and start bak from scratch.
  13986. * Could be useful to regenerate the texture if it is setup to render only once.
  13987. */
  13988. resetRefreshCounter(): void;
  13989. /**
  13990. * Set the fragment shader to use in order to render the texture.
  13991. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13992. */
  13993. setFragment(fragment: any): void;
  13994. /**
  13995. * Define the refresh rate of the texture or the rendering frequency.
  13996. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13997. */
  13998. refreshRate: number;
  13999. /** @hidden */
  14000. _shouldRender(): boolean;
  14001. /**
  14002. * Get the size the texture is rendering at.
  14003. * @returns the size (texture is always squared)
  14004. */
  14005. getRenderSize(): number;
  14006. /**
  14007. * Resize the texture to new value.
  14008. * @param size Define the new size the texture should have
  14009. * @param generateMipMaps Define whether the new texture should create mip maps
  14010. */
  14011. resize(size: number, generateMipMaps: boolean): void;
  14012. private _checkUniform;
  14013. /**
  14014. * Set a texture in the shader program used to render.
  14015. * @param name Define the name of the uniform samplers as defined in the shader
  14016. * @param texture Define the texture to bind to this sampler
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setTexture(name: string, texture: Texture): ProceduralTexture;
  14020. /**
  14021. * Set a float in the shader.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setFloat(name: string, value: number): ProceduralTexture;
  14027. /**
  14028. * Set a int in the shader.
  14029. * @param name Define the name of the uniform as defined in the shader
  14030. * @param value Define the value to give to the uniform
  14031. * @return the texture itself allowing "fluent" like uniform updates
  14032. */
  14033. setInt(name: string, value: number): ProceduralTexture;
  14034. /**
  14035. * Set an array of floats in the shader.
  14036. * @param name Define the name of the uniform as defined in the shader
  14037. * @param value Define the value to give to the uniform
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setFloats(name: string, value: number[]): ProceduralTexture;
  14041. /**
  14042. * Set a vec3 in the shader from a Color3.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setColor3(name: string, value: Color3): ProceduralTexture;
  14048. /**
  14049. * Set a vec4 in the shader from a Color4.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setColor4(name: string, value: Color4): ProceduralTexture;
  14055. /**
  14056. * Set a vec2 in the shader from a Vector2.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setVector2(name: string, value: Vector2): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Vector3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setVector3(name: string, value: Vector3): ProceduralTexture;
  14069. /**
  14070. * Set a mat4 in the shader from a MAtrix.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14076. /**
  14077. * Render the texture to its associated render target.
  14078. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14079. */
  14080. render(useCameraPostProcess?: boolean): void;
  14081. /**
  14082. * Clone the texture.
  14083. * @returns the cloned texture
  14084. */
  14085. clone(): ProceduralTexture;
  14086. /**
  14087. * Dispose the texture and release its asoociated resources.
  14088. */
  14089. dispose(): void;
  14090. }
  14091. }
  14092. declare module BABYLON {
  14093. /**
  14094. * This represents the base class for particle system in Babylon.
  14095. * 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.
  14096. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14097. * @example https://doc.babylonjs.com/babylon101/particles
  14098. */
  14099. export class BaseParticleSystem {
  14100. /**
  14101. * Source color is added to the destination color without alpha affecting the result
  14102. */
  14103. static BLENDMODE_ONEONE: number;
  14104. /**
  14105. * Blend current color and particle color using particle’s alpha
  14106. */
  14107. static BLENDMODE_STANDARD: number;
  14108. /**
  14109. * Add current color and particle color multiplied by particle’s alpha
  14110. */
  14111. static BLENDMODE_ADD: number;
  14112. /**
  14113. * Multiply current color with particle color
  14114. */
  14115. static BLENDMODE_MULTIPLY: number;
  14116. /**
  14117. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14118. */
  14119. static BLENDMODE_MULTIPLYADD: number;
  14120. /**
  14121. * List of animations used by the particle system.
  14122. */
  14123. animations: Animation[];
  14124. /**
  14125. * The id of the Particle system.
  14126. */
  14127. id: string;
  14128. /**
  14129. * The friendly name of the Particle system.
  14130. */
  14131. name: string;
  14132. /**
  14133. * The rendering group used by the Particle system to chose when to render.
  14134. */
  14135. renderingGroupId: number;
  14136. /**
  14137. * The emitter represents the Mesh or position we are attaching the particle system to.
  14138. */
  14139. emitter: Nullable<AbstractMesh | Vector3>;
  14140. /**
  14141. * The maximum number of particles to emit per frame
  14142. */
  14143. emitRate: number;
  14144. /**
  14145. * If you want to launch only a few particles at once, that can be done, as well.
  14146. */
  14147. manualEmitCount: number;
  14148. /**
  14149. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14150. */
  14151. updateSpeed: number;
  14152. /**
  14153. * The amount of time the particle system is running (depends of the overall update speed).
  14154. */
  14155. targetStopDuration: number;
  14156. /**
  14157. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14158. */
  14159. disposeOnStop: boolean;
  14160. /**
  14161. * Minimum power of emitting particles.
  14162. */
  14163. minEmitPower: number;
  14164. /**
  14165. * Maximum power of emitting particles.
  14166. */
  14167. maxEmitPower: number;
  14168. /**
  14169. * Minimum life time of emitting particles.
  14170. */
  14171. minLifeTime: number;
  14172. /**
  14173. * Maximum life time of emitting particles.
  14174. */
  14175. maxLifeTime: number;
  14176. /**
  14177. * Minimum Size of emitting particles.
  14178. */
  14179. minSize: number;
  14180. /**
  14181. * Maximum Size of emitting particles.
  14182. */
  14183. maxSize: number;
  14184. /**
  14185. * Minimum scale of emitting particles on X axis.
  14186. */
  14187. minScaleX: number;
  14188. /**
  14189. * Maximum scale of emitting particles on X axis.
  14190. */
  14191. maxScaleX: number;
  14192. /**
  14193. * Minimum scale of emitting particles on Y axis.
  14194. */
  14195. minScaleY: number;
  14196. /**
  14197. * Maximum scale of emitting particles on Y axis.
  14198. */
  14199. maxScaleY: number;
  14200. /**
  14201. * Gets or sets the minimal initial rotation in radians.
  14202. */
  14203. minInitialRotation: number;
  14204. /**
  14205. * Gets or sets the maximal initial rotation in radians.
  14206. */
  14207. maxInitialRotation: number;
  14208. /**
  14209. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14210. */
  14211. minAngularSpeed: number;
  14212. /**
  14213. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14214. */
  14215. maxAngularSpeed: number;
  14216. /**
  14217. * The texture used to render each particle. (this can be a spritesheet)
  14218. */
  14219. particleTexture: Nullable<Texture>;
  14220. /**
  14221. * The layer mask we are rendering the particles through.
  14222. */
  14223. layerMask: number;
  14224. /**
  14225. * This can help using your own shader to render the particle system.
  14226. * The according effect will be created
  14227. */
  14228. customShader: any;
  14229. /**
  14230. * By default particle system starts as soon as they are created. This prevents the
  14231. * automatic start to happen and let you decide when to start emitting particles.
  14232. */
  14233. preventAutoStart: boolean;
  14234. private _noiseTexture;
  14235. /**
  14236. * Gets or sets a texture used to add random noise to particle positions
  14237. */
  14238. noiseTexture: Nullable<ProceduralTexture>;
  14239. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14240. noiseStrength: Vector3;
  14241. /**
  14242. * Callback triggered when the particle animation is ending.
  14243. */
  14244. onAnimationEnd: Nullable<() => void>;
  14245. /**
  14246. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14247. */
  14248. blendMode: number;
  14249. /**
  14250. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14251. * to override the particles.
  14252. */
  14253. forceDepthWrite: boolean;
  14254. /** 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 */
  14255. preWarmCycles: number;
  14256. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14257. preWarmStepOffset: number;
  14258. /**
  14259. * 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)
  14260. */
  14261. spriteCellChangeSpeed: number;
  14262. /**
  14263. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14264. */
  14265. startSpriteCellID: number;
  14266. /**
  14267. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14268. */
  14269. endSpriteCellID: number;
  14270. /**
  14271. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14272. */
  14273. spriteCellWidth: number;
  14274. /**
  14275. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14276. */
  14277. spriteCellHeight: number;
  14278. /**
  14279. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14280. */
  14281. spriteRandomStartCell: boolean;
  14282. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14283. translationPivot: Vector2;
  14284. /** @hidden */
  14285. protected _isAnimationSheetEnabled: boolean;
  14286. /**
  14287. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14288. */
  14289. beginAnimationOnStart: boolean;
  14290. /**
  14291. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14292. */
  14293. beginAnimationFrom: number;
  14294. /**
  14295. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14296. */
  14297. beginAnimationTo: number;
  14298. /**
  14299. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14300. */
  14301. beginAnimationLoop: boolean;
  14302. /**
  14303. * Gets or sets a world offset applied to all particles
  14304. */
  14305. worldOffset: Vector3;
  14306. /**
  14307. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14308. */
  14309. isAnimationSheetEnabled: boolean;
  14310. /**
  14311. * Get hosting scene
  14312. * @returns the scene
  14313. */
  14314. getScene(): Scene;
  14315. /**
  14316. * You can use gravity if you want to give an orientation to your particles.
  14317. */
  14318. gravity: Vector3;
  14319. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14320. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14321. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14322. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14323. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14324. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14325. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14326. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14327. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14328. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14329. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14330. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14331. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14332. /**
  14333. * Defines the delay in milliseconds before starting the system (0 by default)
  14334. */
  14335. startDelay: number;
  14336. /**
  14337. * Gets the current list of drag gradients.
  14338. * You must use addDragGradient and removeDragGradient to udpate this list
  14339. * @returns the list of drag gradients
  14340. */
  14341. getDragGradients(): Nullable<Array<FactorGradient>>;
  14342. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14343. limitVelocityDamping: number;
  14344. /**
  14345. * Gets the current list of limit velocity gradients.
  14346. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14347. * @returns the list of limit velocity gradients
  14348. */
  14349. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14350. /**
  14351. * Gets the current list of color gradients.
  14352. * You must use addColorGradient and removeColorGradient to udpate this list
  14353. * @returns the list of color gradients
  14354. */
  14355. getColorGradients(): Nullable<Array<ColorGradient>>;
  14356. /**
  14357. * Gets the current list of size gradients.
  14358. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14359. * @returns the list of size gradients
  14360. */
  14361. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14362. /**
  14363. * Gets the current list of color remap gradients.
  14364. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14365. * @returns the list of color remap gradients
  14366. */
  14367. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14368. /**
  14369. * Gets the current list of alpha remap gradients.
  14370. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14371. * @returns the list of alpha remap gradients
  14372. */
  14373. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14374. /**
  14375. * Gets the current list of life time gradients.
  14376. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14377. * @returns the list of life time gradients
  14378. */
  14379. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14380. /**
  14381. * Gets the current list of angular speed gradients.
  14382. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14383. * @returns the list of angular speed gradients
  14384. */
  14385. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14386. /**
  14387. * Gets the current list of velocity gradients.
  14388. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14389. * @returns the list of velocity gradients
  14390. */
  14391. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of start size gradients.
  14394. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14395. * @returns the list of start size gradients
  14396. */
  14397. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14398. /**
  14399. * Gets the current list of emit rate gradients.
  14400. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14401. * @returns the list of emit rate gradients
  14402. */
  14403. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14406. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14407. */
  14408. direction1: Vector3;
  14409. /**
  14410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14411. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14412. */
  14413. direction2: Vector3;
  14414. /**
  14415. * 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.
  14416. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14417. */
  14418. minEmitBox: Vector3;
  14419. /**
  14420. * 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.
  14421. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14422. */
  14423. maxEmitBox: Vector3;
  14424. /**
  14425. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14426. */
  14427. color1: Color4;
  14428. /**
  14429. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14430. */
  14431. color2: Color4;
  14432. /**
  14433. * Color the particle will have at the end of its lifetime
  14434. */
  14435. colorDead: Color4;
  14436. /**
  14437. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14438. */
  14439. textureMask: Color4;
  14440. /**
  14441. * The particle emitter type defines the emitter used by the particle system.
  14442. * It can be for example box, sphere, or cone...
  14443. */
  14444. particleEmitterType: IParticleEmitterType;
  14445. /** @hidden */
  14446. _isSubEmitter: boolean;
  14447. /**
  14448. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14449. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14450. */
  14451. billboardMode: number;
  14452. protected _isBillboardBased: boolean;
  14453. /**
  14454. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14455. */
  14456. isBillboardBased: boolean;
  14457. /**
  14458. * The scene the particle system belongs to.
  14459. */
  14460. protected _scene: Scene;
  14461. /**
  14462. * Local cache of defines for image processing.
  14463. */
  14464. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14465. /**
  14466. * Default configuration related to image processing available in the standard Material.
  14467. */
  14468. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14469. /**
  14470. * Gets the image processing configuration used either in this material.
  14471. */
  14472. /**
  14473. * Sets the Default image processing configuration used either in the this material.
  14474. *
  14475. * If sets to null, the scene one is in use.
  14476. */
  14477. imageProcessingConfiguration: ImageProcessingConfiguration;
  14478. /**
  14479. * Attaches a new image processing configuration to the Standard Material.
  14480. * @param configuration
  14481. */
  14482. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14483. /** @hidden */
  14484. protected _reset(): void;
  14485. /** @hidden */
  14486. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14487. /**
  14488. * Instantiates a particle system.
  14489. * 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.
  14490. * @param name The name of the particle system
  14491. */
  14492. constructor(name: string);
  14493. /**
  14494. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @returns the emitter
  14498. */
  14499. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14500. /**
  14501. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14502. * @param radius The radius of the hemisphere to emit from
  14503. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14504. * @returns the emitter
  14505. */
  14506. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14507. /**
  14508. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14509. * @param radius The radius of the sphere to emit from
  14510. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14511. * @returns the emitter
  14512. */
  14513. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14514. /**
  14515. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14516. * @param radius The radius of the sphere to emit from
  14517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14519. * @returns the emitter
  14520. */
  14521. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14522. /**
  14523. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14524. * @param radius The radius of the emission cylinder
  14525. * @param height The height of the emission cylinder
  14526. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14527. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14528. * @returns the emitter
  14529. */
  14530. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14531. /**
  14532. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14533. * @param radius The radius of the cylinder to emit from
  14534. * @param height The height of the emission cylinder
  14535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14538. * @returns the emitter
  14539. */
  14540. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14541. /**
  14542. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14543. * @param radius The radius of the cone to emit from
  14544. * @param angle The base angle of the cone
  14545. * @returns the emitter
  14546. */
  14547. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14548. /**
  14549. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14552. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14553. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14554. * @returns the emitter
  14555. */
  14556. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. /**
  14561. * Type of sub emitter
  14562. */
  14563. export enum SubEmitterType {
  14564. /**
  14565. * Attached to the particle over it's lifetime
  14566. */
  14567. ATTACHED = 0,
  14568. /**
  14569. * Created when the particle dies
  14570. */
  14571. END = 1
  14572. }
  14573. /**
  14574. * Sub emitter class used to emit particles from an existing particle
  14575. */
  14576. export class SubEmitter {
  14577. /**
  14578. * the particle system to be used by the sub emitter
  14579. */
  14580. particleSystem: ParticleSystem;
  14581. /**
  14582. * Type of the submitter (Default: END)
  14583. */
  14584. type: SubEmitterType;
  14585. /**
  14586. * 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)
  14587. * Note: This only is supported when using an emitter of type Mesh
  14588. */
  14589. inheritDirection: boolean;
  14590. /**
  14591. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14592. */
  14593. inheritedVelocityAmount: number;
  14594. /**
  14595. * Creates a sub emitter
  14596. * @param particleSystem the particle system to be used by the sub emitter
  14597. */
  14598. constructor(
  14599. /**
  14600. * the particle system to be used by the sub emitter
  14601. */
  14602. particleSystem: ParticleSystem);
  14603. /**
  14604. * Clones the sub emitter
  14605. * @returns the cloned sub emitter
  14606. */
  14607. clone(): SubEmitter;
  14608. /**
  14609. * Serialize current object to a JSON object
  14610. * @returns the serialized object
  14611. */
  14612. serialize(): any;
  14613. /** @hidden */
  14614. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14615. /**
  14616. * Creates a new SubEmitter from a serialized JSON version
  14617. * @param serializationObject defines the JSON object to read from
  14618. * @param scene defines the hosting scene
  14619. * @param rootUrl defines the rootUrl for data loading
  14620. * @returns a new SubEmitter
  14621. */
  14622. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14623. /** Release associated resources */
  14624. dispose(): void;
  14625. }
  14626. }
  14627. declare module BABYLON {
  14628. /** @hidden */
  14629. export var clipPlaneFragmentDeclaration: {
  14630. name: string;
  14631. shader: string;
  14632. };
  14633. }
  14634. declare module BABYLON {
  14635. /** @hidden */
  14636. export var imageProcessingDeclaration: {
  14637. name: string;
  14638. shader: string;
  14639. };
  14640. }
  14641. declare module BABYLON {
  14642. /** @hidden */
  14643. export var imageProcessingFunctions: {
  14644. name: string;
  14645. shader: string;
  14646. };
  14647. }
  14648. declare module BABYLON {
  14649. /** @hidden */
  14650. export var clipPlaneFragment: {
  14651. name: string;
  14652. shader: string;
  14653. };
  14654. }
  14655. declare module BABYLON {
  14656. /** @hidden */
  14657. export var particlesPixelShader: {
  14658. name: string;
  14659. shader: string;
  14660. };
  14661. }
  14662. declare module BABYLON {
  14663. /** @hidden */
  14664. export var clipPlaneVertexDeclaration: {
  14665. name: string;
  14666. shader: string;
  14667. };
  14668. }
  14669. declare module BABYLON {
  14670. /** @hidden */
  14671. export var clipPlaneVertex: {
  14672. name: string;
  14673. shader: string;
  14674. };
  14675. }
  14676. declare module BABYLON {
  14677. /** @hidden */
  14678. export var particlesVertexShader: {
  14679. name: string;
  14680. shader: string;
  14681. };
  14682. }
  14683. declare module BABYLON {
  14684. /**
  14685. * This represents a particle system in Babylon.
  14686. * 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.
  14687. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14688. * @example https://doc.babylonjs.com/babylon101/particles
  14689. */
  14690. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14691. /**
  14692. * Billboard mode will only apply to Y axis
  14693. */
  14694. static readonly BILLBOARDMODE_Y: number;
  14695. /**
  14696. * Billboard mode will apply to all axes
  14697. */
  14698. static readonly BILLBOARDMODE_ALL: number;
  14699. /**
  14700. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14701. */
  14702. static readonly BILLBOARDMODE_STRETCHED: number;
  14703. /**
  14704. * This function can be defined to provide custom update for active particles.
  14705. * This function will be called instead of regular update (age, position, color, etc.).
  14706. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14707. */
  14708. updateFunction: (particles: Particle[]) => void;
  14709. private _emitterWorldMatrix;
  14710. /**
  14711. * This function can be defined to specify initial direction for every new particle.
  14712. * It by default use the emitterType defined function
  14713. */
  14714. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14715. /**
  14716. * This function can be defined to specify initial position for every new particle.
  14717. * It by default use the emitterType defined function
  14718. */
  14719. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14720. /**
  14721. * @hidden
  14722. */
  14723. _inheritedVelocityOffset: Vector3;
  14724. /**
  14725. * An event triggered when the system is disposed
  14726. */
  14727. onDisposeObservable: Observable<ParticleSystem>;
  14728. private _onDisposeObserver;
  14729. /**
  14730. * Sets a callback that will be triggered when the system is disposed
  14731. */
  14732. onDispose: () => void;
  14733. private _particles;
  14734. private _epsilon;
  14735. private _capacity;
  14736. private _stockParticles;
  14737. private _newPartsExcess;
  14738. private _vertexData;
  14739. private _vertexBuffer;
  14740. private _vertexBuffers;
  14741. private _spriteBuffer;
  14742. private _indexBuffer;
  14743. private _effect;
  14744. private _customEffect;
  14745. private _cachedDefines;
  14746. private _scaledColorStep;
  14747. private _colorDiff;
  14748. private _scaledDirection;
  14749. private _scaledGravity;
  14750. private _currentRenderId;
  14751. private _alive;
  14752. private _useInstancing;
  14753. private _started;
  14754. private _stopped;
  14755. private _actualFrame;
  14756. private _scaledUpdateSpeed;
  14757. private _vertexBufferSize;
  14758. /** @hidden */
  14759. _currentEmitRateGradient: Nullable<FactorGradient>;
  14760. /** @hidden */
  14761. _currentEmitRate1: number;
  14762. /** @hidden */
  14763. _currentEmitRate2: number;
  14764. /** @hidden */
  14765. _currentStartSizeGradient: Nullable<FactorGradient>;
  14766. /** @hidden */
  14767. _currentStartSize1: number;
  14768. /** @hidden */
  14769. _currentStartSize2: number;
  14770. private readonly _rawTextureWidth;
  14771. private _rampGradientsTexture;
  14772. private _useRampGradients;
  14773. /** Gets or sets a boolean indicating that ramp gradients must be used
  14774. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14775. */
  14776. useRampGradients: boolean;
  14777. /**
  14778. * 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.
  14779. * 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: [])
  14780. */
  14781. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14782. private _subEmitters;
  14783. /**
  14784. * @hidden
  14785. * If the particle systems emitter should be disposed when the particle system is disposed
  14786. */
  14787. _disposeEmitterOnDispose: boolean;
  14788. /**
  14789. * The current active Sub-systems, this property is used by the root particle system only.
  14790. */
  14791. activeSubSystems: Array<ParticleSystem>;
  14792. private _rootParticleSystem;
  14793. /**
  14794. * Gets the current list of active particles
  14795. */
  14796. readonly particles: Particle[];
  14797. /**
  14798. * Returns the string "ParticleSystem"
  14799. * @returns a string containing the class name
  14800. */
  14801. getClassName(): string;
  14802. /**
  14803. * Instantiates a particle system.
  14804. * 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.
  14805. * @param name The name of the particle system
  14806. * @param capacity The max number of particles alive at the same time
  14807. * @param scene The scene the particle system belongs to
  14808. * @param customEffect a custom effect used to change the way particles are rendered by default
  14809. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14810. * @param epsilon Offset used to render the particles
  14811. */
  14812. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14813. private _addFactorGradient;
  14814. private _removeFactorGradient;
  14815. /**
  14816. * Adds a new life time gradient
  14817. * @param gradient defines the gradient to use (between 0 and 1)
  14818. * @param factor defines the life time factor to affect to the specified gradient
  14819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14820. * @returns the current particle system
  14821. */
  14822. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14823. /**
  14824. * Remove a specific life time gradient
  14825. * @param gradient defines the gradient to remove
  14826. * @returns the current particle system
  14827. */
  14828. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14829. /**
  14830. * Adds a new size gradient
  14831. * @param gradient defines the gradient to use (between 0 and 1)
  14832. * @param factor defines the size factor to affect to the specified gradient
  14833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14834. * @returns the current particle system
  14835. */
  14836. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14837. /**
  14838. * Remove a specific size gradient
  14839. * @param gradient defines the gradient to remove
  14840. * @returns the current particle system
  14841. */
  14842. removeSizeGradient(gradient: number): IParticleSystem;
  14843. /**
  14844. * Adds a new color remap gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param min defines the color remap minimal range
  14847. * @param max defines the color remap maximal range
  14848. * @returns the current particle system
  14849. */
  14850. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific color remap gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeColorRemapGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Adds a new alpha remap gradient
  14859. * @param gradient defines the gradient to use (between 0 and 1)
  14860. * @param min defines the alpha remap minimal range
  14861. * @param max defines the alpha remap maximal range
  14862. * @returns the current particle system
  14863. */
  14864. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14865. /**
  14866. * Remove a specific alpha remap gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14871. /**
  14872. * Adds a new angular speed gradient
  14873. * @param gradient defines the gradient to use (between 0 and 1)
  14874. * @param factor defines the angular speed to affect to the specified gradient
  14875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14876. * @returns the current particle system
  14877. */
  14878. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14879. /**
  14880. * Remove a specific angular speed gradient
  14881. * @param gradient defines the gradient to remove
  14882. * @returns the current particle system
  14883. */
  14884. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14885. /**
  14886. * Adds a new velocity gradient
  14887. * @param gradient defines the gradient to use (between 0 and 1)
  14888. * @param factor defines the velocity to affect to the specified gradient
  14889. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14890. * @returns the current particle system
  14891. */
  14892. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14893. /**
  14894. * Remove a specific velocity gradient
  14895. * @param gradient defines the gradient to remove
  14896. * @returns the current particle system
  14897. */
  14898. removeVelocityGradient(gradient: number): IParticleSystem;
  14899. /**
  14900. * Adds a new limit velocity gradient
  14901. * @param gradient defines the gradient to use (between 0 and 1)
  14902. * @param factor defines the limit velocity value to affect to the specified gradient
  14903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14904. * @returns the current particle system
  14905. */
  14906. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14907. /**
  14908. * Remove a specific limit velocity gradient
  14909. * @param gradient defines the gradient to remove
  14910. * @returns the current particle system
  14911. */
  14912. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14913. /**
  14914. * Adds a new drag gradient
  14915. * @param gradient defines the gradient to use (between 0 and 1)
  14916. * @param factor defines the drag value to affect to the specified gradient
  14917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14918. * @returns the current particle system
  14919. */
  14920. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14921. /**
  14922. * Remove a specific drag gradient
  14923. * @param gradient defines the gradient to remove
  14924. * @returns the current particle system
  14925. */
  14926. removeDragGradient(gradient: number): IParticleSystem;
  14927. /**
  14928. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14929. * @param gradient defines the gradient to use (between 0 and 1)
  14930. * @param factor defines the emit rate value to affect to the specified gradient
  14931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14932. * @returns the current particle system
  14933. */
  14934. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14935. /**
  14936. * Remove a specific emit rate gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeEmitRateGradient(gradient: number): IParticleSystem;
  14941. /**
  14942. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param factor defines the start size value to affect to the specified gradient
  14945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14946. * @returns the current particle system
  14947. */
  14948. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14949. /**
  14950. * Remove a specific start size gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns the current particle system
  14953. */
  14954. removeStartSizeGradient(gradient: number): IParticleSystem;
  14955. private _createRampGradientTexture;
  14956. /**
  14957. * Gets the current list of ramp gradients.
  14958. * You must use addRampGradient and removeRampGradient to udpate this list
  14959. * @returns the list of ramp gradients
  14960. */
  14961. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14962. /**
  14963. * Adds a new ramp gradient used to remap particle colors
  14964. * @param gradient defines the gradient to use (between 0 and 1)
  14965. * @param color defines the color to affect to the specified gradient
  14966. * @returns the current particle system
  14967. */
  14968. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14969. /**
  14970. * Remove a specific ramp gradient
  14971. * @param gradient defines the gradient to remove
  14972. * @returns the current particle system
  14973. */
  14974. removeRampGradient(gradient: number): ParticleSystem;
  14975. /**
  14976. * Adds a new color gradient
  14977. * @param gradient defines the gradient to use (between 0 and 1)
  14978. * @param color1 defines the color to affect to the specified gradient
  14979. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14980. * @returns this particle system
  14981. */
  14982. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14983. /**
  14984. * Remove a specific color gradient
  14985. * @param gradient defines the gradient to remove
  14986. * @returns this particle system
  14987. */
  14988. removeColorGradient(gradient: number): IParticleSystem;
  14989. private _fetchR;
  14990. protected _reset(): void;
  14991. private _resetEffect;
  14992. private _createVertexBuffers;
  14993. private _createIndexBuffer;
  14994. /**
  14995. * Gets the maximum number of particles active at the same time.
  14996. * @returns The max number of active particles.
  14997. */
  14998. getCapacity(): number;
  14999. /**
  15000. * Gets whether there are still active particles in the system.
  15001. * @returns True if it is alive, otherwise false.
  15002. */
  15003. isAlive(): boolean;
  15004. /**
  15005. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15006. * @returns True if it has been started, otherwise false.
  15007. */
  15008. isStarted(): boolean;
  15009. private _prepareSubEmitterInternalArray;
  15010. /**
  15011. * Starts the particle system and begins to emit
  15012. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15013. */
  15014. start(delay?: number): void;
  15015. /**
  15016. * Stops the particle system.
  15017. * @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.
  15018. */
  15019. stop(stopSubEmitters?: boolean): void;
  15020. /**
  15021. * Remove all active particles
  15022. */
  15023. reset(): void;
  15024. /**
  15025. * @hidden (for internal use only)
  15026. */
  15027. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15028. /**
  15029. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15030. * Its lifetime will start back at 0.
  15031. */
  15032. recycleParticle: (particle: Particle) => void;
  15033. private _stopSubEmitters;
  15034. private _createParticle;
  15035. private _removeFromRoot;
  15036. private _emitFromParticle;
  15037. private _update;
  15038. /** @hidden */
  15039. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15040. /** @hidden */
  15041. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15042. /** @hidden */
  15043. private _getEffect;
  15044. /**
  15045. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15046. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15047. */
  15048. animate(preWarmOnly?: boolean): void;
  15049. private _appendParticleVertices;
  15050. /**
  15051. * Rebuilds the particle system.
  15052. */
  15053. rebuild(): void;
  15054. /**
  15055. * Is this system ready to be used/rendered
  15056. * @return true if the system is ready
  15057. */
  15058. isReady(): boolean;
  15059. private _render;
  15060. /**
  15061. * Renders the particle system in its current state.
  15062. * @returns the current number of particles
  15063. */
  15064. render(): number;
  15065. /**
  15066. * Disposes the particle system and free the associated resources
  15067. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15068. */
  15069. dispose(disposeTexture?: boolean): void;
  15070. /**
  15071. * Clones the particle system.
  15072. * @param name The name of the cloned object
  15073. * @param newEmitter The new emitter to use
  15074. * @returns the cloned particle system
  15075. */
  15076. clone(name: string, newEmitter: any): ParticleSystem;
  15077. /**
  15078. * Serializes the particle system to a JSON object.
  15079. * @returns the JSON object
  15080. */
  15081. serialize(): any;
  15082. /** @hidden */
  15083. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15084. /** @hidden */
  15085. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15086. /**
  15087. * Parses a JSON object to create a particle system.
  15088. * @param parsedParticleSystem The JSON object to parse
  15089. * @param scene The scene to create the particle system in
  15090. * @param rootUrl The root url to use to load external dependencies like texture
  15091. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15092. * @returns the Parsed particle system
  15093. */
  15094. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15095. }
  15096. }
  15097. declare module BABYLON {
  15098. /**
  15099. * A particle represents one of the element emitted by a particle system.
  15100. * This is mainly define by its coordinates, direction, velocity and age.
  15101. */
  15102. export class Particle {
  15103. /**
  15104. * The particle system the particle belongs to.
  15105. */
  15106. particleSystem: ParticleSystem;
  15107. private static _Count;
  15108. /**
  15109. * Unique ID of the particle
  15110. */
  15111. id: number;
  15112. /**
  15113. * The world position of the particle in the scene.
  15114. */
  15115. position: Vector3;
  15116. /**
  15117. * The world direction of the particle in the scene.
  15118. */
  15119. direction: Vector3;
  15120. /**
  15121. * The color of the particle.
  15122. */
  15123. color: Color4;
  15124. /**
  15125. * The color change of the particle per step.
  15126. */
  15127. colorStep: Color4;
  15128. /**
  15129. * Defines how long will the life of the particle be.
  15130. */
  15131. lifeTime: number;
  15132. /**
  15133. * The current age of the particle.
  15134. */
  15135. age: number;
  15136. /**
  15137. * The current size of the particle.
  15138. */
  15139. size: number;
  15140. /**
  15141. * The current scale of the particle.
  15142. */
  15143. scale: Vector2;
  15144. /**
  15145. * The current angle of the particle.
  15146. */
  15147. angle: number;
  15148. /**
  15149. * Defines how fast is the angle changing.
  15150. */
  15151. angularSpeed: number;
  15152. /**
  15153. * Defines the cell index used by the particle to be rendered from a sprite.
  15154. */
  15155. cellIndex: number;
  15156. /**
  15157. * The information required to support color remapping
  15158. */
  15159. remapData: Vector4;
  15160. /** @hidden */
  15161. _randomCellOffset?: number;
  15162. /** @hidden */
  15163. _initialDirection: Nullable<Vector3>;
  15164. /** @hidden */
  15165. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15166. /** @hidden */
  15167. _initialStartSpriteCellID: number;
  15168. /** @hidden */
  15169. _initialEndSpriteCellID: number;
  15170. /** @hidden */
  15171. _currentColorGradient: Nullable<ColorGradient>;
  15172. /** @hidden */
  15173. _currentColor1: Color4;
  15174. /** @hidden */
  15175. _currentColor2: Color4;
  15176. /** @hidden */
  15177. _currentSizeGradient: Nullable<FactorGradient>;
  15178. /** @hidden */
  15179. _currentSize1: number;
  15180. /** @hidden */
  15181. _currentSize2: number;
  15182. /** @hidden */
  15183. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15184. /** @hidden */
  15185. _currentAngularSpeed1: number;
  15186. /** @hidden */
  15187. _currentAngularSpeed2: number;
  15188. /** @hidden */
  15189. _currentVelocityGradient: Nullable<FactorGradient>;
  15190. /** @hidden */
  15191. _currentVelocity1: number;
  15192. /** @hidden */
  15193. _currentVelocity2: number;
  15194. /** @hidden */
  15195. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15196. /** @hidden */
  15197. _currentLimitVelocity1: number;
  15198. /** @hidden */
  15199. _currentLimitVelocity2: number;
  15200. /** @hidden */
  15201. _currentDragGradient: Nullable<FactorGradient>;
  15202. /** @hidden */
  15203. _currentDrag1: number;
  15204. /** @hidden */
  15205. _currentDrag2: number;
  15206. /** @hidden */
  15207. _randomNoiseCoordinates1: Vector3;
  15208. /** @hidden */
  15209. _randomNoiseCoordinates2: Vector3;
  15210. /**
  15211. * Creates a new instance Particle
  15212. * @param particleSystem the particle system the particle belongs to
  15213. */
  15214. constructor(
  15215. /**
  15216. * The particle system the particle belongs to.
  15217. */
  15218. particleSystem: ParticleSystem);
  15219. private updateCellInfoFromSystem;
  15220. /**
  15221. * Defines how the sprite cell index is updated for the particle
  15222. */
  15223. updateCellIndex(): void;
  15224. /** @hidden */
  15225. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15226. /** @hidden */
  15227. _inheritParticleInfoToSubEmitters(): void;
  15228. /** @hidden */
  15229. _reset(): void;
  15230. /**
  15231. * Copy the properties of particle to another one.
  15232. * @param other the particle to copy the information to.
  15233. */
  15234. copyTo(other: Particle): void;
  15235. }
  15236. }
  15237. declare module BABYLON {
  15238. /**
  15239. * Particle emitter represents a volume emitting particles.
  15240. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15241. */
  15242. export interface IParticleEmitterType {
  15243. /**
  15244. * Called by the particle System when the direction is computed for the created particle.
  15245. * @param worldMatrix is the world matrix of the particle system
  15246. * @param directionToUpdate is the direction vector to update with the result
  15247. * @param particle is the particle we are computed the direction for
  15248. */
  15249. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15250. /**
  15251. * Called by the particle System when the position is computed for the created particle.
  15252. * @param worldMatrix is the world matrix of the particle system
  15253. * @param positionToUpdate is the position vector to update with the result
  15254. * @param particle is the particle we are computed the position for
  15255. */
  15256. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15257. /**
  15258. * Clones the current emitter and returns a copy of it
  15259. * @returns the new emitter
  15260. */
  15261. clone(): IParticleEmitterType;
  15262. /**
  15263. * Called by the GPUParticleSystem to setup the update shader
  15264. * @param effect defines the update shader
  15265. */
  15266. applyToShader(effect: Effect): void;
  15267. /**
  15268. * Returns a string to use to update the GPU particles update shader
  15269. * @returns the effect defines string
  15270. */
  15271. getEffectDefines(): string;
  15272. /**
  15273. * Returns a string representing the class name
  15274. * @returns a string containing the class name
  15275. */
  15276. getClassName(): string;
  15277. /**
  15278. * Serializes the particle system to a JSON object.
  15279. * @returns the JSON object
  15280. */
  15281. serialize(): any;
  15282. /**
  15283. * Parse properties from a JSON object
  15284. * @param serializationObject defines the JSON object
  15285. */
  15286. parse(serializationObject: any): void;
  15287. }
  15288. }
  15289. declare module BABYLON {
  15290. /**
  15291. * Particle emitter emitting particles from the inside of a box.
  15292. * It emits the particles randomly between 2 given directions.
  15293. */
  15294. export class BoxParticleEmitter implements IParticleEmitterType {
  15295. /**
  15296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15297. */
  15298. direction1: Vector3;
  15299. /**
  15300. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15301. */
  15302. direction2: Vector3;
  15303. /**
  15304. * 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.
  15305. */
  15306. minEmitBox: Vector3;
  15307. /**
  15308. * 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.
  15309. */
  15310. maxEmitBox: Vector3;
  15311. /**
  15312. * Creates a new instance BoxParticleEmitter
  15313. */
  15314. constructor();
  15315. /**
  15316. * Called by the particle System when the direction is computed for the created particle.
  15317. * @param worldMatrix is the world matrix of the particle system
  15318. * @param directionToUpdate is the direction vector to update with the result
  15319. * @param particle is the particle we are computed the direction for
  15320. */
  15321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15322. /**
  15323. * Called by the particle System when the position is computed for the created particle.
  15324. * @param worldMatrix is the world matrix of the particle system
  15325. * @param positionToUpdate is the position vector to update with the result
  15326. * @param particle is the particle we are computed the position for
  15327. */
  15328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15329. /**
  15330. * Clones the current emitter and returns a copy of it
  15331. * @returns the new emitter
  15332. */
  15333. clone(): BoxParticleEmitter;
  15334. /**
  15335. * Called by the GPUParticleSystem to setup the update shader
  15336. * @param effect defines the update shader
  15337. */
  15338. applyToShader(effect: Effect): void;
  15339. /**
  15340. * Returns a string to use to update the GPU particles update shader
  15341. * @returns a string containng the defines string
  15342. */
  15343. getEffectDefines(): string;
  15344. /**
  15345. * Returns the string "BoxParticleEmitter"
  15346. * @returns a string containing the class name
  15347. */
  15348. getClassName(): string;
  15349. /**
  15350. * Serializes the particle system to a JSON object.
  15351. * @returns the JSON object
  15352. */
  15353. serialize(): any;
  15354. /**
  15355. * Parse properties from a JSON object
  15356. * @param serializationObject defines the JSON object
  15357. */
  15358. parse(serializationObject: any): void;
  15359. }
  15360. }
  15361. declare module BABYLON {
  15362. /**
  15363. * Particle emitter emitting particles from the inside of a cone.
  15364. * It emits the particles alongside the cone volume from the base to the particle.
  15365. * The emission direction might be randomized.
  15366. */
  15367. export class ConeParticleEmitter implements IParticleEmitterType {
  15368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15369. directionRandomizer: number;
  15370. private _radius;
  15371. private _angle;
  15372. private _height;
  15373. /**
  15374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15375. */
  15376. radiusRange: number;
  15377. /**
  15378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15379. */
  15380. heightRange: number;
  15381. /**
  15382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15383. */
  15384. emitFromSpawnPointOnly: boolean;
  15385. /**
  15386. * Gets or sets the radius of the emission cone
  15387. */
  15388. radius: number;
  15389. /**
  15390. * Gets or sets the angle of the emission cone
  15391. */
  15392. angle: number;
  15393. private _buildHeight;
  15394. /**
  15395. * Creates a new instance ConeParticleEmitter
  15396. * @param radius the radius of the emission cone (1 by default)
  15397. * @param angle the cone base angle (PI by default)
  15398. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15399. */
  15400. constructor(radius?: number, angle?: number,
  15401. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15402. directionRandomizer?: number);
  15403. /**
  15404. * Called by the particle System when the direction is computed for the created particle.
  15405. * @param worldMatrix is the world matrix of the particle system
  15406. * @param directionToUpdate is the direction vector to update with the result
  15407. * @param particle is the particle we are computed the direction for
  15408. */
  15409. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15410. /**
  15411. * Called by the particle System when the position is computed for the created particle.
  15412. * @param worldMatrix is the world matrix of the particle system
  15413. * @param positionToUpdate is the position vector to update with the result
  15414. * @param particle is the particle we are computed the position for
  15415. */
  15416. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15417. /**
  15418. * Clones the current emitter and returns a copy of it
  15419. * @returns the new emitter
  15420. */
  15421. clone(): ConeParticleEmitter;
  15422. /**
  15423. * Called by the GPUParticleSystem to setup the update shader
  15424. * @param effect defines the update shader
  15425. */
  15426. applyToShader(effect: Effect): void;
  15427. /**
  15428. * Returns a string to use to update the GPU particles update shader
  15429. * @returns a string containng the defines string
  15430. */
  15431. getEffectDefines(): string;
  15432. /**
  15433. * Returns the string "ConeParticleEmitter"
  15434. * @returns a string containing the class name
  15435. */
  15436. getClassName(): string;
  15437. /**
  15438. * Serializes the particle system to a JSON object.
  15439. * @returns the JSON object
  15440. */
  15441. serialize(): any;
  15442. /**
  15443. * Parse properties from a JSON object
  15444. * @param serializationObject defines the JSON object
  15445. */
  15446. parse(serializationObject: any): void;
  15447. }
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * Particle emitter emitting particles from the inside of a cylinder.
  15452. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15453. */
  15454. export class CylinderParticleEmitter implements IParticleEmitterType {
  15455. /**
  15456. * The radius of the emission cylinder.
  15457. */
  15458. radius: number;
  15459. /**
  15460. * The height of the emission cylinder.
  15461. */
  15462. height: number;
  15463. /**
  15464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15465. */
  15466. radiusRange: number;
  15467. /**
  15468. * How much to randomize the particle direction [0-1].
  15469. */
  15470. directionRandomizer: number;
  15471. /**
  15472. * Creates a new instance CylinderParticleEmitter
  15473. * @param radius the radius of the emission cylinder (1 by default)
  15474. * @param height the height of the emission cylinder (1 by default)
  15475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15476. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15477. */
  15478. constructor(
  15479. /**
  15480. * The radius of the emission cylinder.
  15481. */
  15482. radius?: number,
  15483. /**
  15484. * The height of the emission cylinder.
  15485. */
  15486. height?: number,
  15487. /**
  15488. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15489. */
  15490. radiusRange?: number,
  15491. /**
  15492. * How much to randomize the particle direction [0-1].
  15493. */
  15494. directionRandomizer?: number);
  15495. /**
  15496. * Called by the particle System when the direction is computed for the created particle.
  15497. * @param worldMatrix is the world matrix of the particle system
  15498. * @param directionToUpdate is the direction vector to update with the result
  15499. * @param particle is the particle we are computed the direction for
  15500. */
  15501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15502. /**
  15503. * Called by the particle System when the position is computed for the created particle.
  15504. * @param worldMatrix is the world matrix of the particle system
  15505. * @param positionToUpdate is the position vector to update with the result
  15506. * @param particle is the particle we are computed the position for
  15507. */
  15508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15509. /**
  15510. * Clones the current emitter and returns a copy of it
  15511. * @returns the new emitter
  15512. */
  15513. clone(): CylinderParticleEmitter;
  15514. /**
  15515. * Called by the GPUParticleSystem to setup the update shader
  15516. * @param effect defines the update shader
  15517. */
  15518. applyToShader(effect: Effect): void;
  15519. /**
  15520. * Returns a string to use to update the GPU particles update shader
  15521. * @returns a string containng the defines string
  15522. */
  15523. getEffectDefines(): string;
  15524. /**
  15525. * Returns the string "CylinderParticleEmitter"
  15526. * @returns a string containing the class name
  15527. */
  15528. getClassName(): string;
  15529. /**
  15530. * Serializes the particle system to a JSON object.
  15531. * @returns the JSON object
  15532. */
  15533. serialize(): any;
  15534. /**
  15535. * Parse properties from a JSON object
  15536. * @param serializationObject defines the JSON object
  15537. */
  15538. parse(serializationObject: any): void;
  15539. }
  15540. /**
  15541. * Particle emitter emitting particles from the inside of a cylinder.
  15542. * It emits the particles randomly between two vectors.
  15543. */
  15544. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15545. /**
  15546. * The min limit of the emission direction.
  15547. */
  15548. direction1: Vector3;
  15549. /**
  15550. * The max limit of the emission direction.
  15551. */
  15552. direction2: Vector3;
  15553. /**
  15554. * Creates a new instance CylinderDirectedParticleEmitter
  15555. * @param radius the radius of the emission cylinder (1 by default)
  15556. * @param height the height of the emission cylinder (1 by default)
  15557. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15558. * @param direction1 the min limit of the emission direction (up vector by default)
  15559. * @param direction2 the max limit of the emission direction (up vector by default)
  15560. */
  15561. constructor(radius?: number, height?: number, radiusRange?: number,
  15562. /**
  15563. * The min limit of the emission direction.
  15564. */
  15565. direction1?: Vector3,
  15566. /**
  15567. * The max limit of the emission direction.
  15568. */
  15569. direction2?: Vector3);
  15570. /**
  15571. * Called by the particle System when the direction is computed for the created particle.
  15572. * @param worldMatrix is the world matrix of the particle system
  15573. * @param directionToUpdate is the direction vector to update with the result
  15574. * @param particle is the particle we are computed the direction for
  15575. */
  15576. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15577. /**
  15578. * Clones the current emitter and returns a copy of it
  15579. * @returns the new emitter
  15580. */
  15581. clone(): CylinderDirectedParticleEmitter;
  15582. /**
  15583. * Called by the GPUParticleSystem to setup the update shader
  15584. * @param effect defines the update shader
  15585. */
  15586. applyToShader(effect: Effect): void;
  15587. /**
  15588. * Returns a string to use to update the GPU particles update shader
  15589. * @returns a string containng the defines string
  15590. */
  15591. getEffectDefines(): string;
  15592. /**
  15593. * Returns the string "CylinderDirectedParticleEmitter"
  15594. * @returns a string containing the class name
  15595. */
  15596. getClassName(): string;
  15597. /**
  15598. * Serializes the particle system to a JSON object.
  15599. * @returns the JSON object
  15600. */
  15601. serialize(): any;
  15602. /**
  15603. * Parse properties from a JSON object
  15604. * @param serializationObject defines the JSON object
  15605. */
  15606. parse(serializationObject: any): void;
  15607. }
  15608. }
  15609. declare module BABYLON {
  15610. /**
  15611. * Particle emitter emitting particles from the inside of a hemisphere.
  15612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15613. */
  15614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15615. /**
  15616. * The radius of the emission hemisphere.
  15617. */
  15618. radius: number;
  15619. /**
  15620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15621. */
  15622. radiusRange: number;
  15623. /**
  15624. * How much to randomize the particle direction [0-1].
  15625. */
  15626. directionRandomizer: number;
  15627. /**
  15628. * Creates a new instance HemisphericParticleEmitter
  15629. * @param radius the radius of the emission hemisphere (1 by default)
  15630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15632. */
  15633. constructor(
  15634. /**
  15635. * The radius of the emission hemisphere.
  15636. */
  15637. radius?: number,
  15638. /**
  15639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15640. */
  15641. radiusRange?: number,
  15642. /**
  15643. * How much to randomize the particle direction [0-1].
  15644. */
  15645. directionRandomizer?: number);
  15646. /**
  15647. * Called by the particle System when the direction is computed for the created particle.
  15648. * @param worldMatrix is the world matrix of the particle system
  15649. * @param directionToUpdate is the direction vector to update with the result
  15650. * @param particle is the particle we are computed the direction for
  15651. */
  15652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15653. /**
  15654. * Called by the particle System when the position is computed for the created particle.
  15655. * @param worldMatrix is the world matrix of the particle system
  15656. * @param positionToUpdate is the position vector to update with the result
  15657. * @param particle is the particle we are computed the position for
  15658. */
  15659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15660. /**
  15661. * Clones the current emitter and returns a copy of it
  15662. * @returns the new emitter
  15663. */
  15664. clone(): HemisphericParticleEmitter;
  15665. /**
  15666. * Called by the GPUParticleSystem to setup the update shader
  15667. * @param effect defines the update shader
  15668. */
  15669. applyToShader(effect: Effect): void;
  15670. /**
  15671. * Returns a string to use to update the GPU particles update shader
  15672. * @returns a string containng the defines string
  15673. */
  15674. getEffectDefines(): string;
  15675. /**
  15676. * Returns the string "HemisphericParticleEmitter"
  15677. * @returns a string containing the class name
  15678. */
  15679. getClassName(): string;
  15680. /**
  15681. * Serializes the particle system to a JSON object.
  15682. * @returns the JSON object
  15683. */
  15684. serialize(): any;
  15685. /**
  15686. * Parse properties from a JSON object
  15687. * @param serializationObject defines the JSON object
  15688. */
  15689. parse(serializationObject: any): void;
  15690. }
  15691. }
  15692. declare module BABYLON {
  15693. /**
  15694. * Particle emitter emitting particles from a point.
  15695. * It emits the particles randomly between 2 given directions.
  15696. */
  15697. export class PointParticleEmitter implements IParticleEmitterType {
  15698. /**
  15699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15700. */
  15701. direction1: Vector3;
  15702. /**
  15703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15704. */
  15705. direction2: Vector3;
  15706. /**
  15707. * Creates a new instance PointParticleEmitter
  15708. */
  15709. constructor();
  15710. /**
  15711. * Called by the particle System when the direction is computed for the created particle.
  15712. * @param worldMatrix is the world matrix of the particle system
  15713. * @param directionToUpdate is the direction vector to update with the result
  15714. * @param particle is the particle we are computed the direction for
  15715. */
  15716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15717. /**
  15718. * Called by the particle System when the position is computed for the created particle.
  15719. * @param worldMatrix is the world matrix of the particle system
  15720. * @param positionToUpdate is the position vector to update with the result
  15721. * @param particle is the particle we are computed the position for
  15722. */
  15723. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15724. /**
  15725. * Clones the current emitter and returns a copy of it
  15726. * @returns the new emitter
  15727. */
  15728. clone(): PointParticleEmitter;
  15729. /**
  15730. * Called by the GPUParticleSystem to setup the update shader
  15731. * @param effect defines the update shader
  15732. */
  15733. applyToShader(effect: Effect): void;
  15734. /**
  15735. * Returns a string to use to update the GPU particles update shader
  15736. * @returns a string containng the defines string
  15737. */
  15738. getEffectDefines(): string;
  15739. /**
  15740. * Returns the string "PointParticleEmitter"
  15741. * @returns a string containing the class name
  15742. */
  15743. getClassName(): string;
  15744. /**
  15745. * Serializes the particle system to a JSON object.
  15746. * @returns the JSON object
  15747. */
  15748. serialize(): any;
  15749. /**
  15750. * Parse properties from a JSON object
  15751. * @param serializationObject defines the JSON object
  15752. */
  15753. parse(serializationObject: any): void;
  15754. }
  15755. }
  15756. declare module BABYLON {
  15757. /**
  15758. * Particle emitter emitting particles from the inside of a sphere.
  15759. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15760. */
  15761. export class SphereParticleEmitter implements IParticleEmitterType {
  15762. /**
  15763. * The radius of the emission sphere.
  15764. */
  15765. radius: number;
  15766. /**
  15767. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15768. */
  15769. radiusRange: number;
  15770. /**
  15771. * How much to randomize the particle direction [0-1].
  15772. */
  15773. directionRandomizer: number;
  15774. /**
  15775. * Creates a new instance SphereParticleEmitter
  15776. * @param radius the radius of the emission sphere (1 by default)
  15777. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15778. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15779. */
  15780. constructor(
  15781. /**
  15782. * The radius of the emission sphere.
  15783. */
  15784. radius?: number,
  15785. /**
  15786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15787. */
  15788. radiusRange?: number,
  15789. /**
  15790. * How much to randomize the particle direction [0-1].
  15791. */
  15792. directionRandomizer?: number);
  15793. /**
  15794. * Called by the particle System when the direction is computed for the created particle.
  15795. * @param worldMatrix is the world matrix of the particle system
  15796. * @param directionToUpdate is the direction vector to update with the result
  15797. * @param particle is the particle we are computed the direction for
  15798. */
  15799. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15800. /**
  15801. * Called by the particle System when the position is computed for the created particle.
  15802. * @param worldMatrix is the world matrix of the particle system
  15803. * @param positionToUpdate is the position vector to update with the result
  15804. * @param particle is the particle we are computed the position for
  15805. */
  15806. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15807. /**
  15808. * Clones the current emitter and returns a copy of it
  15809. * @returns the new emitter
  15810. */
  15811. clone(): SphereParticleEmitter;
  15812. /**
  15813. * Called by the GPUParticleSystem to setup the update shader
  15814. * @param effect defines the update shader
  15815. */
  15816. applyToShader(effect: Effect): void;
  15817. /**
  15818. * Returns a string to use to update the GPU particles update shader
  15819. * @returns a string containng the defines string
  15820. */
  15821. getEffectDefines(): string;
  15822. /**
  15823. * Returns the string "SphereParticleEmitter"
  15824. * @returns a string containing the class name
  15825. */
  15826. getClassName(): string;
  15827. /**
  15828. * Serializes the particle system to a JSON object.
  15829. * @returns the JSON object
  15830. */
  15831. serialize(): any;
  15832. /**
  15833. * Parse properties from a JSON object
  15834. * @param serializationObject defines the JSON object
  15835. */
  15836. parse(serializationObject: any): void;
  15837. }
  15838. /**
  15839. * Particle emitter emitting particles from the inside of a sphere.
  15840. * It emits the particles randomly between two vectors.
  15841. */
  15842. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15843. /**
  15844. * The min limit of the emission direction.
  15845. */
  15846. direction1: Vector3;
  15847. /**
  15848. * The max limit of the emission direction.
  15849. */
  15850. direction2: Vector3;
  15851. /**
  15852. * Creates a new instance SphereDirectedParticleEmitter
  15853. * @param radius the radius of the emission sphere (1 by default)
  15854. * @param direction1 the min limit of the emission direction (up vector by default)
  15855. * @param direction2 the max limit of the emission direction (up vector by default)
  15856. */
  15857. constructor(radius?: number,
  15858. /**
  15859. * The min limit of the emission direction.
  15860. */
  15861. direction1?: Vector3,
  15862. /**
  15863. * The max limit of the emission direction.
  15864. */
  15865. direction2?: Vector3);
  15866. /**
  15867. * Called by the particle System when the direction is computed for the created particle.
  15868. * @param worldMatrix is the world matrix of the particle system
  15869. * @param directionToUpdate is the direction vector to update with the result
  15870. * @param particle is the particle we are computed the direction for
  15871. */
  15872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15873. /**
  15874. * Clones the current emitter and returns a copy of it
  15875. * @returns the new emitter
  15876. */
  15877. clone(): SphereDirectedParticleEmitter;
  15878. /**
  15879. * Called by the GPUParticleSystem to setup the update shader
  15880. * @param effect defines the update shader
  15881. */
  15882. applyToShader(effect: Effect): void;
  15883. /**
  15884. * Returns a string to use to update the GPU particles update shader
  15885. * @returns a string containng the defines string
  15886. */
  15887. getEffectDefines(): string;
  15888. /**
  15889. * Returns the string "SphereDirectedParticleEmitter"
  15890. * @returns a string containing the class name
  15891. */
  15892. getClassName(): string;
  15893. /**
  15894. * Serializes the particle system to a JSON object.
  15895. * @returns the JSON object
  15896. */
  15897. serialize(): any;
  15898. /**
  15899. * Parse properties from a JSON object
  15900. * @param serializationObject defines the JSON object
  15901. */
  15902. parse(serializationObject: any): void;
  15903. }
  15904. }
  15905. declare module BABYLON {
  15906. /**
  15907. * Interface representing a particle system in Babylon.js.
  15908. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15909. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15910. */
  15911. export interface IParticleSystem {
  15912. /**
  15913. * List of animations used by the particle system.
  15914. */
  15915. animations: Animation[];
  15916. /**
  15917. * The id of the Particle system.
  15918. */
  15919. id: string;
  15920. /**
  15921. * The name of the Particle system.
  15922. */
  15923. name: string;
  15924. /**
  15925. * The emitter represents the Mesh or position we are attaching the particle system to.
  15926. */
  15927. emitter: Nullable<AbstractMesh | Vector3>;
  15928. /**
  15929. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15930. */
  15931. isBillboardBased: boolean;
  15932. /**
  15933. * The rendering group used by the Particle system to chose when to render.
  15934. */
  15935. renderingGroupId: number;
  15936. /**
  15937. * The layer mask we are rendering the particles through.
  15938. */
  15939. layerMask: number;
  15940. /**
  15941. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15942. */
  15943. updateSpeed: number;
  15944. /**
  15945. * The amount of time the particle system is running (depends of the overall update speed).
  15946. */
  15947. targetStopDuration: number;
  15948. /**
  15949. * The texture used to render each particle. (this can be a spritesheet)
  15950. */
  15951. particleTexture: Nullable<Texture>;
  15952. /**
  15953. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15954. */
  15955. blendMode: number;
  15956. /**
  15957. * Minimum life time of emitting particles.
  15958. */
  15959. minLifeTime: number;
  15960. /**
  15961. * Maximum life time of emitting particles.
  15962. */
  15963. maxLifeTime: number;
  15964. /**
  15965. * Minimum Size of emitting particles.
  15966. */
  15967. minSize: number;
  15968. /**
  15969. * Maximum Size of emitting particles.
  15970. */
  15971. maxSize: number;
  15972. /**
  15973. * Minimum scale of emitting particles on X axis.
  15974. */
  15975. minScaleX: number;
  15976. /**
  15977. * Maximum scale of emitting particles on X axis.
  15978. */
  15979. maxScaleX: number;
  15980. /**
  15981. * Minimum scale of emitting particles on Y axis.
  15982. */
  15983. minScaleY: number;
  15984. /**
  15985. * Maximum scale of emitting particles on Y axis.
  15986. */
  15987. maxScaleY: number;
  15988. /**
  15989. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15990. */
  15991. color1: Color4;
  15992. /**
  15993. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15994. */
  15995. color2: Color4;
  15996. /**
  15997. * Color the particle will have at the end of its lifetime.
  15998. */
  15999. colorDead: Color4;
  16000. /**
  16001. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16002. */
  16003. emitRate: number;
  16004. /**
  16005. * You can use gravity if you want to give an orientation to your particles.
  16006. */
  16007. gravity: Vector3;
  16008. /**
  16009. * Minimum power of emitting particles.
  16010. */
  16011. minEmitPower: number;
  16012. /**
  16013. * Maximum power of emitting particles.
  16014. */
  16015. maxEmitPower: number;
  16016. /**
  16017. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16018. */
  16019. minAngularSpeed: number;
  16020. /**
  16021. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16022. */
  16023. maxAngularSpeed: number;
  16024. /**
  16025. * Gets or sets the minimal initial rotation in radians.
  16026. */
  16027. minInitialRotation: number;
  16028. /**
  16029. * Gets or sets the maximal initial rotation in radians.
  16030. */
  16031. maxInitialRotation: number;
  16032. /**
  16033. * The particle emitter type defines the emitter used by the particle system.
  16034. * It can be for example box, sphere, or cone...
  16035. */
  16036. particleEmitterType: Nullable<IParticleEmitterType>;
  16037. /**
  16038. * Defines the delay in milliseconds before starting the system (0 by default)
  16039. */
  16040. startDelay: number;
  16041. /**
  16042. * 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
  16043. */
  16044. preWarmCycles: number;
  16045. /**
  16046. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16047. */
  16048. preWarmStepOffset: number;
  16049. /**
  16050. * 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)
  16051. */
  16052. spriteCellChangeSpeed: number;
  16053. /**
  16054. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16055. */
  16056. startSpriteCellID: number;
  16057. /**
  16058. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16059. */
  16060. endSpriteCellID: number;
  16061. /**
  16062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16063. */
  16064. spriteCellWidth: number;
  16065. /**
  16066. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16067. */
  16068. spriteCellHeight: number;
  16069. /**
  16070. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16071. */
  16072. spriteRandomStartCell: boolean;
  16073. /**
  16074. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16075. */
  16076. isAnimationSheetEnabled: boolean;
  16077. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16078. translationPivot: Vector2;
  16079. /**
  16080. * Gets or sets a texture used to add random noise to particle positions
  16081. */
  16082. noiseTexture: Nullable<BaseTexture>;
  16083. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16084. noiseStrength: Vector3;
  16085. /**
  16086. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16087. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16088. */
  16089. billboardMode: number;
  16090. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16091. limitVelocityDamping: number;
  16092. /**
  16093. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16094. */
  16095. beginAnimationOnStart: boolean;
  16096. /**
  16097. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16098. */
  16099. beginAnimationFrom: number;
  16100. /**
  16101. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16102. */
  16103. beginAnimationTo: number;
  16104. /**
  16105. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16106. */
  16107. beginAnimationLoop: boolean;
  16108. /**
  16109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16110. */
  16111. disposeOnStop: boolean;
  16112. /**
  16113. * Gets the maximum number of particles active at the same time.
  16114. * @returns The max number of active particles.
  16115. */
  16116. getCapacity(): number;
  16117. /**
  16118. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16119. * @returns True if it has been started, otherwise false.
  16120. */
  16121. isStarted(): boolean;
  16122. /**
  16123. * Animates the particle system for this frame.
  16124. */
  16125. animate(): void;
  16126. /**
  16127. * Renders the particle system in its current state.
  16128. * @returns the current number of particles
  16129. */
  16130. render(): number;
  16131. /**
  16132. * Dispose the particle system and frees its associated resources.
  16133. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16134. */
  16135. dispose(disposeTexture?: boolean): void;
  16136. /**
  16137. * Clones the particle system.
  16138. * @param name The name of the cloned object
  16139. * @param newEmitter The new emitter to use
  16140. * @returns the cloned particle system
  16141. */
  16142. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16143. /**
  16144. * Serializes the particle system to a JSON object.
  16145. * @returns the JSON object
  16146. */
  16147. serialize(): any;
  16148. /**
  16149. * Rebuild the particle system
  16150. */
  16151. rebuild(): void;
  16152. /**
  16153. * Starts the particle system and begins to emit
  16154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16155. */
  16156. start(delay?: number): void;
  16157. /**
  16158. * Stops the particle system.
  16159. */
  16160. stop(): void;
  16161. /**
  16162. * Remove all active particles
  16163. */
  16164. reset(): void;
  16165. /**
  16166. * Is this system ready to be used/rendered
  16167. * @return true if the system is ready
  16168. */
  16169. isReady(): boolean;
  16170. /**
  16171. * Adds a new color gradient
  16172. * @param gradient defines the gradient to use (between 0 and 1)
  16173. * @param color1 defines the color to affect to the specified gradient
  16174. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16175. * @returns the current particle system
  16176. */
  16177. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16178. /**
  16179. * Remove a specific color gradient
  16180. * @param gradient defines the gradient to remove
  16181. * @returns the current particle system
  16182. */
  16183. removeColorGradient(gradient: number): IParticleSystem;
  16184. /**
  16185. * Adds a new size gradient
  16186. * @param gradient defines the gradient to use (between 0 and 1)
  16187. * @param factor defines the size factor to affect to the specified gradient
  16188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16189. * @returns the current particle system
  16190. */
  16191. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16192. /**
  16193. * Remove a specific size gradient
  16194. * @param gradient defines the gradient to remove
  16195. * @returns the current particle system
  16196. */
  16197. removeSizeGradient(gradient: number): IParticleSystem;
  16198. /**
  16199. * Gets the current list of color gradients.
  16200. * You must use addColorGradient and removeColorGradient to udpate this list
  16201. * @returns the list of color gradients
  16202. */
  16203. getColorGradients(): Nullable<Array<ColorGradient>>;
  16204. /**
  16205. * Gets the current list of size gradients.
  16206. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16207. * @returns the list of size gradients
  16208. */
  16209. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16210. /**
  16211. * Gets the current list of angular speed gradients.
  16212. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16213. * @returns the list of angular speed gradients
  16214. */
  16215. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16216. /**
  16217. * Adds a new angular speed gradient
  16218. * @param gradient defines the gradient to use (between 0 and 1)
  16219. * @param factor defines the angular speed to affect to the specified gradient
  16220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16221. * @returns the current particle system
  16222. */
  16223. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16224. /**
  16225. * Remove a specific angular speed gradient
  16226. * @param gradient defines the gradient to remove
  16227. * @returns the current particle system
  16228. */
  16229. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16230. /**
  16231. * Gets the current list of velocity gradients.
  16232. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16233. * @returns the list of velocity gradients
  16234. */
  16235. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16236. /**
  16237. * Adds a new velocity gradient
  16238. * @param gradient defines the gradient to use (between 0 and 1)
  16239. * @param factor defines the velocity to affect to the specified gradient
  16240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16241. * @returns the current particle system
  16242. */
  16243. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16244. /**
  16245. * Remove a specific velocity gradient
  16246. * @param gradient defines the gradient to remove
  16247. * @returns the current particle system
  16248. */
  16249. removeVelocityGradient(gradient: number): IParticleSystem;
  16250. /**
  16251. * Gets the current list of limit velocity gradients.
  16252. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16253. * @returns the list of limit velocity gradients
  16254. */
  16255. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16256. /**
  16257. * Adds a new limit velocity gradient
  16258. * @param gradient defines the gradient to use (between 0 and 1)
  16259. * @param factor defines the limit velocity to affect to the specified gradient
  16260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16261. * @returns the current particle system
  16262. */
  16263. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16264. /**
  16265. * Remove a specific limit velocity gradient
  16266. * @param gradient defines the gradient to remove
  16267. * @returns the current particle system
  16268. */
  16269. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16270. /**
  16271. * Adds a new drag gradient
  16272. * @param gradient defines the gradient to use (between 0 and 1)
  16273. * @param factor defines the drag to affect to the specified gradient
  16274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16275. * @returns the current particle system
  16276. */
  16277. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16278. /**
  16279. * Remove a specific drag gradient
  16280. * @param gradient defines the gradient to remove
  16281. * @returns the current particle system
  16282. */
  16283. removeDragGradient(gradient: number): IParticleSystem;
  16284. /**
  16285. * Gets the current list of drag gradients.
  16286. * You must use addDragGradient and removeDragGradient to udpate this list
  16287. * @returns the list of drag gradients
  16288. */
  16289. getDragGradients(): Nullable<Array<FactorGradient>>;
  16290. /**
  16291. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16292. * @param gradient defines the gradient to use (between 0 and 1)
  16293. * @param factor defines the emit rate to affect to the specified gradient
  16294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16295. * @returns the current particle system
  16296. */
  16297. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16298. /**
  16299. * Remove a specific emit rate gradient
  16300. * @param gradient defines the gradient to remove
  16301. * @returns the current particle system
  16302. */
  16303. removeEmitRateGradient(gradient: number): IParticleSystem;
  16304. /**
  16305. * Gets the current list of emit rate gradients.
  16306. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16307. * @returns the list of emit rate gradients
  16308. */
  16309. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16310. /**
  16311. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16312. * @param gradient defines the gradient to use (between 0 and 1)
  16313. * @param factor defines the start size to affect to the specified gradient
  16314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16315. * @returns the current particle system
  16316. */
  16317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16318. /**
  16319. * Remove a specific start size gradient
  16320. * @param gradient defines the gradient to remove
  16321. * @returns the current particle system
  16322. */
  16323. removeStartSizeGradient(gradient: number): IParticleSystem;
  16324. /**
  16325. * Gets the current list of start size gradients.
  16326. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16327. * @returns the list of start size gradients
  16328. */
  16329. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16330. /**
  16331. * Adds a new life time gradient
  16332. * @param gradient defines the gradient to use (between 0 and 1)
  16333. * @param factor defines the life time factor to affect to the specified gradient
  16334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16335. * @returns the current particle system
  16336. */
  16337. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16338. /**
  16339. * Remove a specific life time gradient
  16340. * @param gradient defines the gradient to remove
  16341. * @returns the current particle system
  16342. */
  16343. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16344. /**
  16345. * Gets the current list of life time gradients.
  16346. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16347. * @returns the list of life time gradients
  16348. */
  16349. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16350. /**
  16351. * Gets the current list of color gradients.
  16352. * You must use addColorGradient and removeColorGradient to udpate this list
  16353. * @returns the list of color gradients
  16354. */
  16355. getColorGradients(): Nullable<Array<ColorGradient>>;
  16356. /**
  16357. * Adds a new ramp gradient used to remap particle colors
  16358. * @param gradient defines the gradient to use (between 0 and 1)
  16359. * @param color defines the color to affect to the specified gradient
  16360. * @returns the current particle system
  16361. */
  16362. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16363. /**
  16364. * Gets the current list of ramp gradients.
  16365. * You must use addRampGradient and removeRampGradient to udpate this list
  16366. * @returns the list of ramp gradients
  16367. */
  16368. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16369. /** Gets or sets a boolean indicating that ramp gradients must be used
  16370. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16371. */
  16372. useRampGradients: boolean;
  16373. /**
  16374. * Adds a new color remap gradient
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param min defines the color remap minimal range
  16377. * @param max defines the color remap maximal range
  16378. * @returns the current particle system
  16379. */
  16380. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16381. /**
  16382. * Gets the current list of color remap gradients.
  16383. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16384. * @returns the list of color remap gradients
  16385. */
  16386. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16387. /**
  16388. * Adds a new alpha remap gradient
  16389. * @param gradient defines the gradient to use (between 0 and 1)
  16390. * @param min defines the alpha remap minimal range
  16391. * @param max defines the alpha remap maximal range
  16392. * @returns the current particle system
  16393. */
  16394. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16395. /**
  16396. * Gets the current list of alpha remap gradients.
  16397. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16398. * @returns the list of alpha remap gradients
  16399. */
  16400. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16405. * @returns the emitter
  16406. */
  16407. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16408. /**
  16409. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16410. * @param radius The radius of the hemisphere to emit from
  16411. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16412. * @returns the emitter
  16413. */
  16414. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16415. /**
  16416. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16417. * @param radius The radius of the sphere to emit from
  16418. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16419. * @returns the emitter
  16420. */
  16421. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16422. /**
  16423. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16424. * @param radius The radius of the sphere to emit from
  16425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16427. * @returns the emitter
  16428. */
  16429. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16430. /**
  16431. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16432. * @param radius The radius of the emission cylinder
  16433. * @param height The height of the emission cylinder
  16434. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16435. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16436. * @returns the emitter
  16437. */
  16438. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16439. /**
  16440. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16441. * @param radius The radius of the cylinder to emit from
  16442. * @param height The height of the emission cylinder
  16443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16446. * @returns the emitter
  16447. */
  16448. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16449. /**
  16450. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16451. * @param radius The radius of the cone to emit from
  16452. * @param angle The base angle of the cone
  16453. * @returns the emitter
  16454. */
  16455. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16456. /**
  16457. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16458. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16459. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16460. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16461. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16462. * @returns the emitter
  16463. */
  16464. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16465. /**
  16466. * Get hosting scene
  16467. * @returns the scene
  16468. */
  16469. getScene(): Scene;
  16470. }
  16471. }
  16472. declare module BABYLON {
  16473. /**
  16474. * Creates an instance based on a source mesh.
  16475. */
  16476. export class InstancedMesh extends AbstractMesh {
  16477. private _sourceMesh;
  16478. private _currentLOD;
  16479. /** @hidden */
  16480. _indexInSourceMeshInstanceArray: number;
  16481. constructor(name: string, source: Mesh);
  16482. /**
  16483. * Returns the string "InstancedMesh".
  16484. */
  16485. getClassName(): string;
  16486. /**
  16487. * If the source mesh receives shadows
  16488. */
  16489. readonly receiveShadows: boolean;
  16490. /**
  16491. * The material of the source mesh
  16492. */
  16493. readonly material: Nullable<Material>;
  16494. /**
  16495. * Visibility of the source mesh
  16496. */
  16497. readonly visibility: number;
  16498. /**
  16499. * Skeleton of the source mesh
  16500. */
  16501. readonly skeleton: Nullable<Skeleton>;
  16502. /**
  16503. * Rendering ground id of the source mesh
  16504. */
  16505. renderingGroupId: number;
  16506. /**
  16507. * Returns the total number of vertices (integer).
  16508. */
  16509. getTotalVertices(): number;
  16510. /**
  16511. * Returns a positive integer : the total number of indices in this mesh geometry.
  16512. * @returns the numner of indices or zero if the mesh has no geometry.
  16513. */
  16514. getTotalIndices(): number;
  16515. /**
  16516. * The source mesh of the instance
  16517. */
  16518. readonly sourceMesh: Mesh;
  16519. /**
  16520. * Is this node ready to be used/rendered
  16521. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16522. * @return {boolean} is it ready
  16523. */
  16524. isReady(completeCheck?: boolean): boolean;
  16525. /**
  16526. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16527. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16528. * @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.
  16529. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16530. */
  16531. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16532. /**
  16533. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16534. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16535. * The `data` are either a numeric array either a Float32Array.
  16536. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16537. * 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).
  16538. * Note that a new underlying VertexBuffer object is created each call.
  16539. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16540. *
  16541. * Possible `kind` values :
  16542. * - VertexBuffer.PositionKind
  16543. * - VertexBuffer.UVKind
  16544. * - VertexBuffer.UV2Kind
  16545. * - VertexBuffer.UV3Kind
  16546. * - VertexBuffer.UV4Kind
  16547. * - VertexBuffer.UV5Kind
  16548. * - VertexBuffer.UV6Kind
  16549. * - VertexBuffer.ColorKind
  16550. * - VertexBuffer.MatricesIndicesKind
  16551. * - VertexBuffer.MatricesIndicesExtraKind
  16552. * - VertexBuffer.MatricesWeightsKind
  16553. * - VertexBuffer.MatricesWeightsExtraKind
  16554. *
  16555. * Returns the Mesh.
  16556. */
  16557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16558. /**
  16559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16560. * If the mesh has no geometry, it is simply returned as it is.
  16561. * The `data` are either a numeric array either a Float32Array.
  16562. * No new underlying VertexBuffer object is created.
  16563. * 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.
  16564. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16565. *
  16566. * Possible `kind` values :
  16567. * - VertexBuffer.PositionKind
  16568. * - VertexBuffer.UVKind
  16569. * - VertexBuffer.UV2Kind
  16570. * - VertexBuffer.UV3Kind
  16571. * - VertexBuffer.UV4Kind
  16572. * - VertexBuffer.UV5Kind
  16573. * - VertexBuffer.UV6Kind
  16574. * - VertexBuffer.ColorKind
  16575. * - VertexBuffer.MatricesIndicesKind
  16576. * - VertexBuffer.MatricesIndicesExtraKind
  16577. * - VertexBuffer.MatricesWeightsKind
  16578. * - VertexBuffer.MatricesWeightsExtraKind
  16579. *
  16580. * Returns the Mesh.
  16581. */
  16582. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16583. /**
  16584. * Sets the mesh indices.
  16585. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16586. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16587. * This method creates a new index buffer each call.
  16588. * Returns the Mesh.
  16589. */
  16590. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16591. /**
  16592. * Boolean : True if the mesh owns the requested kind of data.
  16593. */
  16594. isVerticesDataPresent(kind: string): boolean;
  16595. /**
  16596. * Returns an array of indices (IndicesArray).
  16597. */
  16598. getIndices(): Nullable<IndicesArray>;
  16599. readonly _positions: Nullable<Vector3[]>;
  16600. /**
  16601. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16602. * This means the mesh underlying bounding box and sphere are recomputed.
  16603. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16604. * @returns the current mesh
  16605. */
  16606. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16607. /** @hidden */
  16608. _preActivate(): InstancedMesh;
  16609. /** @hidden */
  16610. _activate(renderId: number): boolean;
  16611. /**
  16612. * Returns the current associated LOD AbstractMesh.
  16613. */
  16614. getLOD(camera: Camera): AbstractMesh;
  16615. /** @hidden */
  16616. _syncSubMeshes(): InstancedMesh;
  16617. /** @hidden */
  16618. _generatePointsArray(): boolean;
  16619. /**
  16620. * Creates a new InstancedMesh from the current mesh.
  16621. * - name (string) : the cloned mesh name
  16622. * - newParent (optional Node) : the optional Node to parent the clone to.
  16623. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16624. *
  16625. * Returns the clone.
  16626. */
  16627. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16628. /**
  16629. * Disposes the InstancedMesh.
  16630. * Returns nothing.
  16631. */
  16632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16633. }
  16634. }
  16635. declare module BABYLON {
  16636. /**
  16637. * Defines the options associated with the creation of a shader material.
  16638. */
  16639. export interface IShaderMaterialOptions {
  16640. /**
  16641. * Does the material work in alpha blend mode
  16642. */
  16643. needAlphaBlending: boolean;
  16644. /**
  16645. * Does the material work in alpha test mode
  16646. */
  16647. needAlphaTesting: boolean;
  16648. /**
  16649. * The list of attribute names used in the shader
  16650. */
  16651. attributes: string[];
  16652. /**
  16653. * The list of unifrom names used in the shader
  16654. */
  16655. uniforms: string[];
  16656. /**
  16657. * The list of UBO names used in the shader
  16658. */
  16659. uniformBuffers: string[];
  16660. /**
  16661. * The list of sampler names used in the shader
  16662. */
  16663. samplers: string[];
  16664. /**
  16665. * The list of defines used in the shader
  16666. */
  16667. defines: string[];
  16668. }
  16669. /**
  16670. * 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.
  16671. *
  16672. * This returned material effects how the mesh will look based on the code in the shaders.
  16673. *
  16674. * @see http://doc.babylonjs.com/how_to/shader_material
  16675. */
  16676. export class ShaderMaterial extends Material {
  16677. private _shaderPath;
  16678. private _options;
  16679. private _textures;
  16680. private _textureArrays;
  16681. private _floats;
  16682. private _ints;
  16683. private _floatsArrays;
  16684. private _colors3;
  16685. private _colors3Arrays;
  16686. private _colors4;
  16687. private _vectors2;
  16688. private _vectors3;
  16689. private _vectors4;
  16690. private _matrices;
  16691. private _matrices3x3;
  16692. private _matrices2x2;
  16693. private _vectors2Arrays;
  16694. private _vectors3Arrays;
  16695. private _cachedWorldViewMatrix;
  16696. private _renderId;
  16697. /**
  16698. * Instantiate a new shader material.
  16699. * 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.
  16700. * This returned material effects how the mesh will look based on the code in the shaders.
  16701. * @see http://doc.babylonjs.com/how_to/shader_material
  16702. * @param name Define the name of the material in the scene
  16703. * @param scene Define the scene the material belongs to
  16704. * @param shaderPath Defines the route to the shader code in one of three ways:
  16705. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16706. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16707. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16708. * @param options Define the options used to create the shader
  16709. */
  16710. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16711. /**
  16712. * Gets the options used to compile the shader.
  16713. * They can be modified to trigger a new compilation
  16714. */
  16715. readonly options: IShaderMaterialOptions;
  16716. /**
  16717. * Gets the current class name of the material e.g. "ShaderMaterial"
  16718. * Mainly use in serialization.
  16719. * @returns the class name
  16720. */
  16721. getClassName(): string;
  16722. /**
  16723. * Specifies if the material will require alpha blending
  16724. * @returns a boolean specifying if alpha blending is needed
  16725. */
  16726. needAlphaBlending(): boolean;
  16727. /**
  16728. * Specifies if this material should be rendered in alpha test mode
  16729. * @returns a boolean specifying if an alpha test is needed.
  16730. */
  16731. needAlphaTesting(): boolean;
  16732. private _checkUniform;
  16733. /**
  16734. * Set a texture in the shader.
  16735. * @param name Define the name of the uniform samplers as defined in the shader
  16736. * @param texture Define the texture to bind to this sampler
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setTexture(name: string, texture: Texture): ShaderMaterial;
  16740. /**
  16741. * Set a texture array in the shader.
  16742. * @param name Define the name of the uniform sampler array as defined in the shader
  16743. * @param textures Define the list of textures to bind to this sampler
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16747. /**
  16748. * Set a float in the shader.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setFloat(name: string, value: number): ShaderMaterial;
  16754. /**
  16755. * Set a int in the shader.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setInt(name: string, value: number): ShaderMaterial;
  16761. /**
  16762. * Set an array of floats in the shader.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setFloats(name: string, value: number[]): ShaderMaterial;
  16768. /**
  16769. * Set a vec3 in the shader from a Color3.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setColor3(name: string, value: Color3): ShaderMaterial;
  16775. /**
  16776. * Set a vec3 array in the shader from a Color3 array.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16782. /**
  16783. * Set a vec4 in the shader from a Color4.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the material itself allowing "fluent" like uniform updates
  16787. */
  16788. setColor4(name: string, value: Color4): ShaderMaterial;
  16789. /**
  16790. * Set a vec2 in the shader from a Vector2.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the material itself allowing "fluent" like uniform updates
  16794. */
  16795. setVector2(name: string, value: Vector2): ShaderMaterial;
  16796. /**
  16797. * Set a vec3 in the shader from a Vector3.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the material itself allowing "fluent" like uniform updates
  16801. */
  16802. setVector3(name: string, value: Vector3): ShaderMaterial;
  16803. /**
  16804. * Set a vec4 in the shader from a Vector4.
  16805. * @param name Define the name of the uniform as defined in the shader
  16806. * @param value Define the value to give to the uniform
  16807. * @return the material itself allowing "fluent" like uniform updates
  16808. */
  16809. setVector4(name: string, value: Vector4): ShaderMaterial;
  16810. /**
  16811. * Set a mat4 in the shader from a Matrix.
  16812. * @param name Define the name of the uniform as defined in the shader
  16813. * @param value Define the value to give to the uniform
  16814. * @return the material itself allowing "fluent" like uniform updates
  16815. */
  16816. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16817. /**
  16818. * Set a mat3 in the shader from a Float32Array.
  16819. * @param name Define the name of the uniform as defined in the shader
  16820. * @param value Define the value to give to the uniform
  16821. * @return the material itself allowing "fluent" like uniform updates
  16822. */
  16823. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16824. /**
  16825. * Set a mat2 in the shader from a Float32Array.
  16826. * @param name Define the name of the uniform as defined in the shader
  16827. * @param value Define the value to give to the uniform
  16828. * @return the material itself allowing "fluent" like uniform updates
  16829. */
  16830. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16831. /**
  16832. * Set a vec2 array in the shader from a number array.
  16833. * @param name Define the name of the uniform as defined in the shader
  16834. * @param value Define the value to give to the uniform
  16835. * @return the material itself allowing "fluent" like uniform updates
  16836. */
  16837. setArray2(name: string, value: number[]): ShaderMaterial;
  16838. /**
  16839. * Set a vec3 array in the shader from a number array.
  16840. * @param name Define the name of the uniform as defined in the shader
  16841. * @param value Define the value to give to the uniform
  16842. * @return the material itself allowing "fluent" like uniform updates
  16843. */
  16844. setArray3(name: string, value: number[]): ShaderMaterial;
  16845. private _checkCache;
  16846. /**
  16847. * Specifies that the submesh is ready to be used
  16848. * @param mesh defines the mesh to check
  16849. * @param subMesh defines which submesh to check
  16850. * @param useInstances specifies that instances should be used
  16851. * @returns a boolean indicating that the submesh is ready or not
  16852. */
  16853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16854. /**
  16855. * Checks if the material is ready to render the requested mesh
  16856. * @param mesh Define the mesh to render
  16857. * @param useInstances Define whether or not the material is used with instances
  16858. * @returns true if ready, otherwise false
  16859. */
  16860. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16861. /**
  16862. * Binds the world matrix to the material
  16863. * @param world defines the world transformation matrix
  16864. */
  16865. bindOnlyWorldMatrix(world: Matrix): void;
  16866. /**
  16867. * Binds the material to the mesh
  16868. * @param world defines the world transformation matrix
  16869. * @param mesh defines the mesh to bind the material to
  16870. */
  16871. bind(world: Matrix, mesh?: Mesh): void;
  16872. /**
  16873. * Gets the active textures from the material
  16874. * @returns an array of textures
  16875. */
  16876. getActiveTextures(): BaseTexture[];
  16877. /**
  16878. * Specifies if the material uses a texture
  16879. * @param texture defines the texture to check against the material
  16880. * @returns a boolean specifying if the material uses the texture
  16881. */
  16882. hasTexture(texture: BaseTexture): boolean;
  16883. /**
  16884. * Makes a duplicate of the material, and gives it a new name
  16885. * @param name defines the new name for the duplicated material
  16886. * @returns the cloned material
  16887. */
  16888. clone(name: string): ShaderMaterial;
  16889. /**
  16890. * Disposes the material
  16891. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16892. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16893. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16894. */
  16895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16896. /**
  16897. * Serializes this material in a JSON representation
  16898. * @returns the serialized material object
  16899. */
  16900. serialize(): any;
  16901. /**
  16902. * Creates a shader material from parsed shader material data
  16903. * @param source defines the JSON represnetation of the material
  16904. * @param scene defines the hosting scene
  16905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16906. * @returns a new material
  16907. */
  16908. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16909. }
  16910. }
  16911. declare module BABYLON {
  16912. /** @hidden */
  16913. export var colorPixelShader: {
  16914. name: string;
  16915. shader: string;
  16916. };
  16917. }
  16918. declare module BABYLON {
  16919. /** @hidden */
  16920. export var colorVertexShader: {
  16921. name: string;
  16922. shader: string;
  16923. };
  16924. }
  16925. declare module BABYLON {
  16926. /**
  16927. * Line mesh
  16928. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16929. */
  16930. export class LinesMesh extends Mesh {
  16931. /**
  16932. * If vertex color should be applied to the mesh
  16933. */
  16934. useVertexColor?: boolean | undefined;
  16935. /**
  16936. * If vertex alpha should be applied to the mesh
  16937. */
  16938. useVertexAlpha?: boolean | undefined;
  16939. /**
  16940. * Color of the line (Default: White)
  16941. */
  16942. color: Color3;
  16943. /**
  16944. * Alpha of the line (Default: 1)
  16945. */
  16946. alpha: number;
  16947. /**
  16948. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16949. * This margin is expressed in world space coordinates, so its value may vary.
  16950. * Default value is 0.1
  16951. */
  16952. intersectionThreshold: number;
  16953. private _colorShader;
  16954. /**
  16955. * Creates a new LinesMesh
  16956. * @param name defines the name
  16957. * @param scene defines the hosting scene
  16958. * @param parent defines the parent mesh if any
  16959. * @param source defines the optional source LinesMesh used to clone data from
  16960. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16961. * When false, achieved by calling a clone(), also passing False.
  16962. * This will make creation of children, recursive.
  16963. * @param useVertexColor defines if this LinesMesh supports vertex color
  16964. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16965. */
  16966. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16967. /**
  16968. * If vertex color should be applied to the mesh
  16969. */
  16970. useVertexColor?: boolean | undefined,
  16971. /**
  16972. * If vertex alpha should be applied to the mesh
  16973. */
  16974. useVertexAlpha?: boolean | undefined);
  16975. private _addClipPlaneDefine;
  16976. private _removeClipPlaneDefine;
  16977. isReady(): boolean;
  16978. /**
  16979. * Returns the string "LineMesh"
  16980. */
  16981. getClassName(): string;
  16982. /**
  16983. * @hidden
  16984. */
  16985. /**
  16986. * @hidden
  16987. */
  16988. material: Material;
  16989. /**
  16990. * @hidden
  16991. */
  16992. readonly checkCollisions: boolean;
  16993. /** @hidden */
  16994. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16995. /** @hidden */
  16996. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16997. /**
  16998. * Disposes of the line mesh
  16999. * @param doNotRecurse If children should be disposed
  17000. */
  17001. dispose(doNotRecurse?: boolean): void;
  17002. /**
  17003. * Returns a new LineMesh object cloned from the current one.
  17004. */
  17005. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17006. /**
  17007. * Creates a new InstancedLinesMesh object from the mesh model.
  17008. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17009. * @param name defines the name of the new instance
  17010. * @returns a new InstancedLinesMesh
  17011. */
  17012. createInstance(name: string): InstancedLinesMesh;
  17013. }
  17014. /**
  17015. * Creates an instance based on a source LinesMesh
  17016. */
  17017. export class InstancedLinesMesh extends InstancedMesh {
  17018. /**
  17019. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17020. * This margin is expressed in world space coordinates, so its value may vary.
  17021. * Initilized with the intersectionThreshold value of the source LinesMesh
  17022. */
  17023. intersectionThreshold: number;
  17024. constructor(name: string, source: LinesMesh);
  17025. /**
  17026. * Returns the string "InstancedLinesMesh".
  17027. */
  17028. getClassName(): string;
  17029. }
  17030. }
  17031. declare module BABYLON {
  17032. /** @hidden */
  17033. export var linePixelShader: {
  17034. name: string;
  17035. shader: string;
  17036. };
  17037. }
  17038. declare module BABYLON {
  17039. /** @hidden */
  17040. export var lineVertexShader: {
  17041. name: string;
  17042. shader: string;
  17043. };
  17044. }
  17045. declare module BABYLON {
  17046. interface AbstractMesh {
  17047. /**
  17048. * Disables the mesh edge rendering mode
  17049. * @returns the currentAbstractMesh
  17050. */
  17051. disableEdgesRendering(): AbstractMesh;
  17052. /**
  17053. * Enables the edge rendering mode on the mesh.
  17054. * This mode makes the mesh edges visible
  17055. * @param epsilon defines the maximal distance between two angles to detect a face
  17056. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17057. * @returns the currentAbstractMesh
  17058. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17059. */
  17060. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17061. /**
  17062. * Gets the edgesRenderer associated with the mesh
  17063. */
  17064. edgesRenderer: Nullable<EdgesRenderer>;
  17065. }
  17066. interface LinesMesh {
  17067. /**
  17068. * Enables the edge rendering mode on the mesh.
  17069. * This mode makes the mesh edges visible
  17070. * @param epsilon defines the maximal distance between two angles to detect a face
  17071. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17072. * @returns the currentAbstractMesh
  17073. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17074. */
  17075. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17076. }
  17077. interface InstancedLinesMesh {
  17078. /**
  17079. * Enables the edge rendering mode on the mesh.
  17080. * This mode makes the mesh edges visible
  17081. * @param epsilon defines the maximal distance between two angles to detect a face
  17082. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17083. * @returns the current InstancedLinesMesh
  17084. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17085. */
  17086. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17087. }
  17088. /**
  17089. * Defines the minimum contract an Edges renderer should follow.
  17090. */
  17091. export interface IEdgesRenderer extends IDisposable {
  17092. /**
  17093. * Gets or sets a boolean indicating if the edgesRenderer is active
  17094. */
  17095. isEnabled: boolean;
  17096. /**
  17097. * Renders the edges of the attached mesh,
  17098. */
  17099. render(): void;
  17100. /**
  17101. * Checks wether or not the edges renderer is ready to render.
  17102. * @return true if ready, otherwise false.
  17103. */
  17104. isReady(): boolean;
  17105. }
  17106. /**
  17107. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17108. */
  17109. export class EdgesRenderer implements IEdgesRenderer {
  17110. /**
  17111. * Define the size of the edges with an orthographic camera
  17112. */
  17113. edgesWidthScalerForOrthographic: number;
  17114. /**
  17115. * Define the size of the edges with a perspective camera
  17116. */
  17117. edgesWidthScalerForPerspective: number;
  17118. protected _source: AbstractMesh;
  17119. protected _linesPositions: number[];
  17120. protected _linesNormals: number[];
  17121. protected _linesIndices: number[];
  17122. protected _epsilon: number;
  17123. protected _indicesCount: number;
  17124. protected _lineShader: ShaderMaterial;
  17125. protected _ib: WebGLBuffer;
  17126. protected _buffers: {
  17127. [key: string]: Nullable<VertexBuffer>;
  17128. };
  17129. protected _checkVerticesInsteadOfIndices: boolean;
  17130. private _meshRebuildObserver;
  17131. private _meshDisposeObserver;
  17132. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17133. isEnabled: boolean;
  17134. /**
  17135. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17136. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17137. * @param source Mesh used to create edges
  17138. * @param epsilon sum of angles in adjacency to check for edge
  17139. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17140. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17141. */
  17142. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17143. protected _prepareRessources(): void;
  17144. /** @hidden */
  17145. _rebuild(): void;
  17146. /**
  17147. * Releases the required resources for the edges renderer
  17148. */
  17149. dispose(): void;
  17150. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17151. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17152. /**
  17153. * Checks if the pair of p0 and p1 is en edge
  17154. * @param faceIndex
  17155. * @param edge
  17156. * @param faceNormals
  17157. * @param p0
  17158. * @param p1
  17159. * @private
  17160. */
  17161. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17162. /**
  17163. * push line into the position, normal and index buffer
  17164. * @protected
  17165. */
  17166. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17167. /**
  17168. * Generates lines edges from adjacencjes
  17169. * @private
  17170. */
  17171. _generateEdgesLines(): void;
  17172. /**
  17173. * Checks wether or not the edges renderer is ready to render.
  17174. * @return true if ready, otherwise false.
  17175. */
  17176. isReady(): boolean;
  17177. /**
  17178. * Renders the edges of the attached mesh,
  17179. */
  17180. render(): void;
  17181. }
  17182. /**
  17183. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17184. */
  17185. export class LineEdgesRenderer extends EdgesRenderer {
  17186. /**
  17187. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17188. * @param source LineMesh used to generate edges
  17189. * @param epsilon not important (specified angle for edge detection)
  17190. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17191. */
  17192. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17193. /**
  17194. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17195. */
  17196. _generateEdgesLines(): void;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * This represents the object necessary to create a rendering group.
  17202. * This is exclusively used and created by the rendering manager.
  17203. * To modify the behavior, you use the available helpers in your scene or meshes.
  17204. * @hidden
  17205. */
  17206. export class RenderingGroup {
  17207. index: number;
  17208. private _scene;
  17209. private _opaqueSubMeshes;
  17210. private _transparentSubMeshes;
  17211. private _alphaTestSubMeshes;
  17212. private _depthOnlySubMeshes;
  17213. private _particleSystems;
  17214. private _spriteManagers;
  17215. private _opaqueSortCompareFn;
  17216. private _alphaTestSortCompareFn;
  17217. private _transparentSortCompareFn;
  17218. private _renderOpaque;
  17219. private _renderAlphaTest;
  17220. private _renderTransparent;
  17221. /** @hidden */
  17222. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17223. onBeforeTransparentRendering: () => void;
  17224. /**
  17225. * Set the opaque sort comparison function.
  17226. * If null the sub meshes will be render in the order they were created
  17227. */
  17228. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17229. /**
  17230. * Set the alpha test sort comparison function.
  17231. * If null the sub meshes will be render in the order they were created
  17232. */
  17233. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17234. /**
  17235. * Set the transparent sort comparison function.
  17236. * If null the sub meshes will be render in the order they were created
  17237. */
  17238. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17239. /**
  17240. * Creates a new rendering group.
  17241. * @param index The rendering group index
  17242. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17243. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17244. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17245. */
  17246. 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>);
  17247. /**
  17248. * Render all the sub meshes contained in the group.
  17249. * @param customRenderFunction Used to override the default render behaviour of the group.
  17250. * @returns true if rendered some submeshes.
  17251. */
  17252. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17253. /**
  17254. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17255. * @param subMeshes The submeshes to render
  17256. */
  17257. private renderOpaqueSorted;
  17258. /**
  17259. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17260. * @param subMeshes The submeshes to render
  17261. */
  17262. private renderAlphaTestSorted;
  17263. /**
  17264. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17265. * @param subMeshes The submeshes to render
  17266. */
  17267. private renderTransparentSorted;
  17268. /**
  17269. * Renders the submeshes in a specified order.
  17270. * @param subMeshes The submeshes to sort before render
  17271. * @param sortCompareFn The comparison function use to sort
  17272. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17273. * @param transparent Specifies to activate blending if true
  17274. */
  17275. private static renderSorted;
  17276. /**
  17277. * Renders the submeshes in the order they were dispatched (no sort applied).
  17278. * @param subMeshes The submeshes to render
  17279. */
  17280. private static renderUnsorted;
  17281. /**
  17282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17283. * are rendered back to front if in the same alpha index.
  17284. *
  17285. * @param a The first submesh
  17286. * @param b The second submesh
  17287. * @returns The result of the comparison
  17288. */
  17289. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17290. /**
  17291. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17292. * are rendered back to front.
  17293. *
  17294. * @param a The first submesh
  17295. * @param b The second submesh
  17296. * @returns The result of the comparison
  17297. */
  17298. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17299. /**
  17300. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17301. * are rendered front to back (prevent overdraw).
  17302. *
  17303. * @param a The first submesh
  17304. * @param b The second submesh
  17305. * @returns The result of the comparison
  17306. */
  17307. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17308. /**
  17309. * Resets the different lists of submeshes to prepare a new frame.
  17310. */
  17311. prepare(): void;
  17312. dispose(): void;
  17313. /**
  17314. * Inserts the submesh in its correct queue depending on its material.
  17315. * @param subMesh The submesh to dispatch
  17316. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17317. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17318. */
  17319. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17320. dispatchSprites(spriteManager: ISpriteManager): void;
  17321. dispatchParticles(particleSystem: IParticleSystem): void;
  17322. private _renderParticles;
  17323. private _renderSprites;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Interface describing the different options available in the rendering manager
  17329. * regarding Auto Clear between groups.
  17330. */
  17331. export interface IRenderingManagerAutoClearSetup {
  17332. /**
  17333. * Defines whether or not autoclear is enable.
  17334. */
  17335. autoClear: boolean;
  17336. /**
  17337. * Defines whether or not to autoclear the depth buffer.
  17338. */
  17339. depth: boolean;
  17340. /**
  17341. * Defines whether or not to autoclear the stencil buffer.
  17342. */
  17343. stencil: boolean;
  17344. }
  17345. /**
  17346. * This class is used by the onRenderingGroupObservable
  17347. */
  17348. export class RenderingGroupInfo {
  17349. /**
  17350. * The Scene that being rendered
  17351. */
  17352. scene: Scene;
  17353. /**
  17354. * The camera currently used for the rendering pass
  17355. */
  17356. camera: Nullable<Camera>;
  17357. /**
  17358. * The ID of the renderingGroup being processed
  17359. */
  17360. renderingGroupId: number;
  17361. }
  17362. /**
  17363. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17364. * It is enable to manage the different groups as well as the different necessary sort functions.
  17365. * This should not be used directly aside of the few static configurations
  17366. */
  17367. export class RenderingManager {
  17368. /**
  17369. * The max id used for rendering groups (not included)
  17370. */
  17371. static MAX_RENDERINGGROUPS: number;
  17372. /**
  17373. * The min id used for rendering groups (included)
  17374. */
  17375. static MIN_RENDERINGGROUPS: number;
  17376. /**
  17377. * Used to globally prevent autoclearing scenes.
  17378. */
  17379. static AUTOCLEAR: boolean;
  17380. /**
  17381. * @hidden
  17382. */
  17383. _useSceneAutoClearSetup: boolean;
  17384. private _scene;
  17385. private _renderingGroups;
  17386. private _depthStencilBufferAlreadyCleaned;
  17387. private _autoClearDepthStencil;
  17388. private _customOpaqueSortCompareFn;
  17389. private _customAlphaTestSortCompareFn;
  17390. private _customTransparentSortCompareFn;
  17391. private _renderingGroupInfo;
  17392. /**
  17393. * Instantiates a new rendering group for a particular scene
  17394. * @param scene Defines the scene the groups belongs to
  17395. */
  17396. constructor(scene: Scene);
  17397. private _clearDepthStencilBuffer;
  17398. /**
  17399. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17400. * @hidden
  17401. */
  17402. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17403. /**
  17404. * Resets the different information of the group to prepare a new frame
  17405. * @hidden
  17406. */
  17407. reset(): void;
  17408. /**
  17409. * Dispose and release the group and its associated resources.
  17410. * @hidden
  17411. */
  17412. dispose(): void;
  17413. /**
  17414. * Clear the info related to rendering groups preventing retention points during dispose.
  17415. */
  17416. freeRenderingGroups(): void;
  17417. private _prepareRenderingGroup;
  17418. /**
  17419. * Add a sprite manager to the rendering manager in order to render it this frame.
  17420. * @param spriteManager Define the sprite manager to render
  17421. */
  17422. dispatchSprites(spriteManager: ISpriteManager): void;
  17423. /**
  17424. * Add a particle system to the rendering manager in order to render it this frame.
  17425. * @param particleSystem Define the particle system to render
  17426. */
  17427. dispatchParticles(particleSystem: IParticleSystem): void;
  17428. /**
  17429. * Add a submesh to the manager in order to render it this frame
  17430. * @param subMesh The submesh to dispatch
  17431. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17432. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17433. */
  17434. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17435. /**
  17436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17437. * This allowed control for front to back rendering or reversly depending of the special needs.
  17438. *
  17439. * @param renderingGroupId The rendering group id corresponding to its index
  17440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17443. */
  17444. 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;
  17445. /**
  17446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17447. *
  17448. * @param renderingGroupId The rendering group id corresponding to its index
  17449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17450. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17451. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17452. */
  17453. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17454. /**
  17455. * Gets the current auto clear configuration for one rendering group of the rendering
  17456. * manager.
  17457. * @param index the rendering group index to get the information for
  17458. * @returns The auto clear setup for the requested rendering group
  17459. */
  17460. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17461. }
  17462. }
  17463. declare module BABYLON {
  17464. /**
  17465. * This Helps creating a texture that will be created from a camera in your scene.
  17466. * It is basically a dynamic texture that could be used to create special effects for instance.
  17467. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17468. */
  17469. export class RenderTargetTexture extends Texture {
  17470. isCube: boolean;
  17471. /**
  17472. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17473. */
  17474. static readonly REFRESHRATE_RENDER_ONCE: number;
  17475. /**
  17476. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17477. */
  17478. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17479. /**
  17480. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17481. * the central point of your effect and can save a lot of performances.
  17482. */
  17483. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17484. /**
  17485. * Use this predicate to dynamically define the list of mesh you want to render.
  17486. * If set, the renderList property will be overwritten.
  17487. */
  17488. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17489. private _renderList;
  17490. /**
  17491. * Use this list to define the list of mesh you want to render.
  17492. */
  17493. renderList: Nullable<Array<AbstractMesh>>;
  17494. private _hookArray;
  17495. /**
  17496. * Define if particles should be rendered in your texture.
  17497. */
  17498. renderParticles: boolean;
  17499. /**
  17500. * Define if sprites should be rendered in your texture.
  17501. */
  17502. renderSprites: boolean;
  17503. /**
  17504. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17505. */
  17506. coordinatesMode: number;
  17507. /**
  17508. * Define the camera used to render the texture.
  17509. */
  17510. activeCamera: Nullable<Camera>;
  17511. /**
  17512. * Override the render function of the texture with your own one.
  17513. */
  17514. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17515. /**
  17516. * Define if camera post processes should be use while rendering the texture.
  17517. */
  17518. useCameraPostProcesses: boolean;
  17519. /**
  17520. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17521. */
  17522. ignoreCameraViewport: boolean;
  17523. private _postProcessManager;
  17524. private _postProcesses;
  17525. private _resizeObserver;
  17526. /**
  17527. * An event triggered when the texture is unbind.
  17528. */
  17529. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17530. /**
  17531. * An event triggered when the texture is unbind.
  17532. */
  17533. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17534. private _onAfterUnbindObserver;
  17535. /**
  17536. * Set a after unbind callback in the texture.
  17537. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17538. */
  17539. onAfterUnbind: () => void;
  17540. /**
  17541. * An event triggered before rendering the texture
  17542. */
  17543. onBeforeRenderObservable: Observable<number>;
  17544. private _onBeforeRenderObserver;
  17545. /**
  17546. * Set a before render callback in the texture.
  17547. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17548. */
  17549. onBeforeRender: (faceIndex: number) => void;
  17550. /**
  17551. * An event triggered after rendering the texture
  17552. */
  17553. onAfterRenderObservable: Observable<number>;
  17554. private _onAfterRenderObserver;
  17555. /**
  17556. * Set a after render callback in the texture.
  17557. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17558. */
  17559. onAfterRender: (faceIndex: number) => void;
  17560. /**
  17561. * An event triggered after the texture clear
  17562. */
  17563. onClearObservable: Observable<Engine>;
  17564. private _onClearObserver;
  17565. /**
  17566. * Set a clear callback in the texture.
  17567. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17568. */
  17569. onClear: (Engine: Engine) => void;
  17570. /**
  17571. * Define the clear color of the Render Target if it should be different from the scene.
  17572. */
  17573. clearColor: Color4;
  17574. protected _size: number | {
  17575. width: number;
  17576. height: number;
  17577. };
  17578. protected _initialSizeParameter: number | {
  17579. width: number;
  17580. height: number;
  17581. } | {
  17582. ratio: number;
  17583. };
  17584. protected _sizeRatio: Nullable<number>;
  17585. /** @hidden */
  17586. _generateMipMaps: boolean;
  17587. protected _renderingManager: RenderingManager;
  17588. /** @hidden */
  17589. _waitingRenderList: string[];
  17590. protected _doNotChangeAspectRatio: boolean;
  17591. protected _currentRefreshId: number;
  17592. protected _refreshRate: number;
  17593. protected _textureMatrix: Matrix;
  17594. protected _samples: number;
  17595. protected _renderTargetOptions: RenderTargetCreationOptions;
  17596. /**
  17597. * Gets render target creation options that were used.
  17598. */
  17599. readonly renderTargetOptions: RenderTargetCreationOptions;
  17600. protected _engine: Engine;
  17601. protected _onRatioRescale(): void;
  17602. /**
  17603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17604. * It must define where the camera used to render the texture is set
  17605. */
  17606. boundingBoxPosition: Vector3;
  17607. private _boundingBoxSize;
  17608. /**
  17609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17610. * When defined, the cubemap will switch to local mode
  17611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17612. * @example https://www.babylonjs-playground.com/#RNASML
  17613. */
  17614. boundingBoxSize: Vector3;
  17615. /**
  17616. * In case the RTT has been created with a depth texture, get the associated
  17617. * depth texture.
  17618. * Otherwise, return null.
  17619. */
  17620. depthStencilTexture: Nullable<InternalTexture>;
  17621. /**
  17622. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17623. * or used a shadow, depth texture...
  17624. * @param name The friendly name of the texture
  17625. * @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)
  17626. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17627. * @param generateMipMaps True if mip maps need to be generated after render.
  17628. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17629. * @param type The type of the buffer in the RTT (int, half float, float...)
  17630. * @param isCube True if a cube texture needs to be created
  17631. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17632. * @param generateDepthBuffer True to generate a depth buffer
  17633. * @param generateStencilBuffer True to generate a stencil buffer
  17634. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17635. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17637. */
  17638. constructor(name: string, size: number | {
  17639. width: number;
  17640. height: number;
  17641. } | {
  17642. ratio: number;
  17643. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17644. /**
  17645. * Creates a depth stencil texture.
  17646. * This is only available in WebGL 2 or with the depth texture extension available.
  17647. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17648. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17649. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17650. */
  17651. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17652. private _processSizeParameter;
  17653. /**
  17654. * Define the number of samples to use in case of MSAA.
  17655. * It defaults to one meaning no MSAA has been enabled.
  17656. */
  17657. samples: number;
  17658. /**
  17659. * Resets the refresh counter of the texture and start bak from scratch.
  17660. * Could be useful to regenerate the texture if it is setup to render only once.
  17661. */
  17662. resetRefreshCounter(): void;
  17663. /**
  17664. * Define the refresh rate of the texture or the rendering frequency.
  17665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17666. */
  17667. refreshRate: number;
  17668. /**
  17669. * Adds a post process to the render target rendering passes.
  17670. * @param postProcess define the post process to add
  17671. */
  17672. addPostProcess(postProcess: PostProcess): void;
  17673. /**
  17674. * Clear all the post processes attached to the render target
  17675. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17676. */
  17677. clearPostProcesses(dispose?: boolean): void;
  17678. /**
  17679. * Remove one of the post process from the list of attached post processes to the texture
  17680. * @param postProcess define the post process to remove from the list
  17681. */
  17682. removePostProcess(postProcess: PostProcess): void;
  17683. /** @hidden */
  17684. _shouldRender(): boolean;
  17685. /**
  17686. * Gets the actual render size of the texture.
  17687. * @returns the width of the render size
  17688. */
  17689. getRenderSize(): number;
  17690. /**
  17691. * Gets the actual render width of the texture.
  17692. * @returns the width of the render size
  17693. */
  17694. getRenderWidth(): number;
  17695. /**
  17696. * Gets the actual render height of the texture.
  17697. * @returns the height of the render size
  17698. */
  17699. getRenderHeight(): number;
  17700. /**
  17701. * Get if the texture can be rescaled or not.
  17702. */
  17703. readonly canRescale: boolean;
  17704. /**
  17705. * Resize the texture using a ratio.
  17706. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17707. */
  17708. scale(ratio: number): void;
  17709. /**
  17710. * Get the texture reflection matrix used to rotate/transform the reflection.
  17711. * @returns the reflection matrix
  17712. */
  17713. getReflectionTextureMatrix(): Matrix;
  17714. /**
  17715. * Resize the texture to a new desired size.
  17716. * Be carrefull as it will recreate all the data in the new texture.
  17717. * @param size Define the new size. It can be:
  17718. * - a number for squared texture,
  17719. * - an object containing { width: number, height: number }
  17720. * - or an object containing a ratio { ratio: number }
  17721. */
  17722. resize(size: number | {
  17723. width: number;
  17724. height: number;
  17725. } | {
  17726. ratio: number;
  17727. }): void;
  17728. /**
  17729. * Renders all the objects from the render list into the texture.
  17730. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17731. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17732. */
  17733. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17734. private _bestReflectionRenderTargetDimension;
  17735. /**
  17736. * @hidden
  17737. * @param faceIndex face index to bind to if this is a cubetexture
  17738. */
  17739. _bindFrameBuffer(faceIndex?: number): void;
  17740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17741. private renderToTarget;
  17742. /**
  17743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17744. * This allowed control for front to back rendering or reversly depending of the special needs.
  17745. *
  17746. * @param renderingGroupId The rendering group id corresponding to its index
  17747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17750. */
  17751. 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;
  17752. /**
  17753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17754. *
  17755. * @param renderingGroupId The rendering group id corresponding to its index
  17756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17757. */
  17758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17759. /**
  17760. * Clones the texture.
  17761. * @returns the cloned texture
  17762. */
  17763. clone(): RenderTargetTexture;
  17764. /**
  17765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17766. * @returns The JSON representation of the texture
  17767. */
  17768. serialize(): any;
  17769. /**
  17770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17771. */
  17772. disposeFramebufferObjects(): void;
  17773. /**
  17774. * Dispose the texture and release its associated resources.
  17775. */
  17776. dispose(): void;
  17777. /** @hidden */
  17778. _rebuild(): void;
  17779. /**
  17780. * Clear the info related to rendering groups preventing retention point in material dispose.
  17781. */
  17782. freeRenderingGroups(): void;
  17783. /**
  17784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17785. * @returns the view count
  17786. */
  17787. getViewCount(): number;
  17788. }
  17789. }
  17790. declare module BABYLON {
  17791. /**
  17792. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17793. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17794. * You can then easily use it as a reflectionTexture on a flat surface.
  17795. * In case the surface is not a plane, please consider relying on reflection probes.
  17796. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17797. */
  17798. export class MirrorTexture extends RenderTargetTexture {
  17799. private scene;
  17800. /**
  17801. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17802. * 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.
  17803. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17804. */
  17805. mirrorPlane: Plane;
  17806. /**
  17807. * Define the blur ratio used to blur the reflection if needed.
  17808. */
  17809. blurRatio: number;
  17810. /**
  17811. * Define the adaptive blur kernel used to blur the reflection if needed.
  17812. * This will autocompute the closest best match for the `blurKernel`
  17813. */
  17814. adaptiveBlurKernel: number;
  17815. /**
  17816. * Define the blur kernel used to blur the reflection if needed.
  17817. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17818. */
  17819. blurKernel: number;
  17820. /**
  17821. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17822. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17823. */
  17824. blurKernelX: number;
  17825. /**
  17826. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17827. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17828. */
  17829. blurKernelY: number;
  17830. private _autoComputeBlurKernel;
  17831. protected _onRatioRescale(): void;
  17832. private _updateGammaSpace;
  17833. private _imageProcessingConfigChangeObserver;
  17834. private _transformMatrix;
  17835. private _mirrorMatrix;
  17836. private _savedViewMatrix;
  17837. private _blurX;
  17838. private _blurY;
  17839. private _adaptiveBlurKernel;
  17840. private _blurKernelX;
  17841. private _blurKernelY;
  17842. private _blurRatio;
  17843. /**
  17844. * Instantiates a Mirror Texture.
  17845. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17846. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17847. * You can then easily use it as a reflectionTexture on a flat surface.
  17848. * In case the surface is not a plane, please consider relying on reflection probes.
  17849. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17850. * @param name
  17851. * @param size
  17852. * @param scene
  17853. * @param generateMipMaps
  17854. * @param type
  17855. * @param samplingMode
  17856. * @param generateDepthBuffer
  17857. */
  17858. constructor(name: string, size: number | {
  17859. width: number;
  17860. height: number;
  17861. } | {
  17862. ratio: number;
  17863. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17864. private _preparePostProcesses;
  17865. /**
  17866. * Clone the mirror texture.
  17867. * @returns the cloned texture
  17868. */
  17869. clone(): MirrorTexture;
  17870. /**
  17871. * Serialize the texture to a JSON representation you could use in Parse later on
  17872. * @returns the serialized JSON representation
  17873. */
  17874. serialize(): any;
  17875. /**
  17876. * Dispose the texture and release its associated resources.
  17877. */
  17878. dispose(): void;
  17879. }
  17880. }
  17881. declare module BABYLON {
  17882. /**
  17883. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17884. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17885. */
  17886. export class Texture extends BaseTexture {
  17887. /** @hidden */
  17888. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17889. /** @hidden */
  17890. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17891. /** @hidden */
  17892. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17893. /** nearest is mag = nearest and min = nearest and mip = linear */
  17894. static readonly NEAREST_SAMPLINGMODE: number;
  17895. /** nearest is mag = nearest and min = nearest and mip = linear */
  17896. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17897. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17898. static readonly BILINEAR_SAMPLINGMODE: number;
  17899. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17900. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17901. /** Trilinear is mag = linear and min = linear and mip = linear */
  17902. static readonly TRILINEAR_SAMPLINGMODE: number;
  17903. /** Trilinear is mag = linear and min = linear and mip = linear */
  17904. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17905. /** mag = nearest and min = nearest and mip = nearest */
  17906. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17907. /** mag = nearest and min = linear and mip = nearest */
  17908. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17909. /** mag = nearest and min = linear and mip = linear */
  17910. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17911. /** mag = nearest and min = linear and mip = none */
  17912. static readonly NEAREST_LINEAR: number;
  17913. /** mag = nearest and min = nearest and mip = none */
  17914. static readonly NEAREST_NEAREST: number;
  17915. /** mag = linear and min = nearest and mip = nearest */
  17916. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17917. /** mag = linear and min = nearest and mip = linear */
  17918. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17919. /** mag = linear and min = linear and mip = none */
  17920. static readonly LINEAR_LINEAR: number;
  17921. /** mag = linear and min = nearest and mip = none */
  17922. static readonly LINEAR_NEAREST: number;
  17923. /** Explicit coordinates mode */
  17924. static readonly EXPLICIT_MODE: number;
  17925. /** Spherical coordinates mode */
  17926. static readonly SPHERICAL_MODE: number;
  17927. /** Planar coordinates mode */
  17928. static readonly PLANAR_MODE: number;
  17929. /** Cubic coordinates mode */
  17930. static readonly CUBIC_MODE: number;
  17931. /** Projection coordinates mode */
  17932. static readonly PROJECTION_MODE: number;
  17933. /** Inverse Cubic coordinates mode */
  17934. static readonly SKYBOX_MODE: number;
  17935. /** Inverse Cubic coordinates mode */
  17936. static readonly INVCUBIC_MODE: number;
  17937. /** Equirectangular coordinates mode */
  17938. static readonly EQUIRECTANGULAR_MODE: number;
  17939. /** Equirectangular Fixed coordinates mode */
  17940. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17941. /** Equirectangular Fixed Mirrored coordinates mode */
  17942. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17943. /** Texture is not repeating outside of 0..1 UVs */
  17944. static readonly CLAMP_ADDRESSMODE: number;
  17945. /** Texture is repeating outside of 0..1 UVs */
  17946. static readonly WRAP_ADDRESSMODE: number;
  17947. /** Texture is repeating and mirrored */
  17948. static readonly MIRROR_ADDRESSMODE: number;
  17949. /**
  17950. * 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
  17951. */
  17952. static UseSerializedUrlIfAny: boolean;
  17953. /**
  17954. * Define the url of the texture.
  17955. */
  17956. url: Nullable<string>;
  17957. /**
  17958. * Define an offset on the texture to offset the u coordinates of the UVs
  17959. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17960. */
  17961. uOffset: number;
  17962. /**
  17963. * Define an offset on the texture to offset the v coordinates of the UVs
  17964. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17965. */
  17966. vOffset: number;
  17967. /**
  17968. * Define an offset on the texture to scale the u coordinates of the UVs
  17969. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17970. */
  17971. uScale: number;
  17972. /**
  17973. * Define an offset on the texture to scale the v coordinates of the UVs
  17974. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17975. */
  17976. vScale: number;
  17977. /**
  17978. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17979. * @see http://doc.babylonjs.com/how_to/more_materials
  17980. */
  17981. uAng: number;
  17982. /**
  17983. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17984. * @see http://doc.babylonjs.com/how_to/more_materials
  17985. */
  17986. vAng: number;
  17987. /**
  17988. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17989. * @see http://doc.babylonjs.com/how_to/more_materials
  17990. */
  17991. wAng: number;
  17992. /**
  17993. * Defines the center of rotation (U)
  17994. */
  17995. uRotationCenter: number;
  17996. /**
  17997. * Defines the center of rotation (V)
  17998. */
  17999. vRotationCenter: number;
  18000. /**
  18001. * Defines the center of rotation (W)
  18002. */
  18003. wRotationCenter: number;
  18004. /**
  18005. * Are mip maps generated for this texture or not.
  18006. */
  18007. readonly noMipmap: boolean;
  18008. /**
  18009. * List of inspectable custom properties (used by the Inspector)
  18010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18011. */
  18012. inspectableCustomProperties: Nullable<IInspectable[]>;
  18013. private _noMipmap;
  18014. /** @hidden */
  18015. _invertY: boolean;
  18016. private _rowGenerationMatrix;
  18017. private _cachedTextureMatrix;
  18018. private _projectionModeMatrix;
  18019. private _t0;
  18020. private _t1;
  18021. private _t2;
  18022. private _cachedUOffset;
  18023. private _cachedVOffset;
  18024. private _cachedUScale;
  18025. private _cachedVScale;
  18026. private _cachedUAng;
  18027. private _cachedVAng;
  18028. private _cachedWAng;
  18029. private _cachedProjectionMatrixId;
  18030. private _cachedCoordinatesMode;
  18031. /** @hidden */
  18032. protected _initialSamplingMode: number;
  18033. /** @hidden */
  18034. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18035. private _deleteBuffer;
  18036. protected _format: Nullable<number>;
  18037. private _delayedOnLoad;
  18038. private _delayedOnError;
  18039. /**
  18040. * Observable triggered once the texture has been loaded.
  18041. */
  18042. onLoadObservable: Observable<Texture>;
  18043. protected _isBlocking: boolean;
  18044. /**
  18045. * Is the texture preventing material to render while loading.
  18046. * If false, a default texture will be used instead of the loading one during the preparation step.
  18047. */
  18048. isBlocking: boolean;
  18049. /**
  18050. * Get the current sampling mode associated with the texture.
  18051. */
  18052. readonly samplingMode: number;
  18053. /**
  18054. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18055. */
  18056. readonly invertY: boolean;
  18057. /**
  18058. * Instantiates a new texture.
  18059. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18060. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18061. * @param url define the url of the picture to load as a texture
  18062. * @param scene define the scene the texture will belong to
  18063. * @param noMipmap define if the texture will require mip maps or not
  18064. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18065. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18066. * @param onLoad define a callback triggered when the texture has been loaded
  18067. * @param onError define a callback triggered when an error occurred during the loading session
  18068. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18069. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18070. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18071. */
  18072. 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);
  18073. /**
  18074. * Update the url (and optional buffer) of this texture if url was null during construction.
  18075. * @param url the url of the texture
  18076. * @param buffer the buffer of the texture (defaults to null)
  18077. * @param onLoad callback called when the texture is loaded (defaults to null)
  18078. */
  18079. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18080. /**
  18081. * Finish the loading sequence of a texture flagged as delayed load.
  18082. * @hidden
  18083. */
  18084. delayLoad(): void;
  18085. private _prepareRowForTextureGeneration;
  18086. /**
  18087. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18088. * @returns the transform matrix of the texture.
  18089. */
  18090. getTextureMatrix(): Matrix;
  18091. /**
  18092. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18093. * @returns The reflection texture transform
  18094. */
  18095. getReflectionTextureMatrix(): Matrix;
  18096. /**
  18097. * Clones the texture.
  18098. * @returns the cloned texture
  18099. */
  18100. clone(): Texture;
  18101. /**
  18102. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18103. * @returns The JSON representation of the texture
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Get the current class name of the texture useful for serialization or dynamic coding.
  18108. * @returns "Texture"
  18109. */
  18110. getClassName(): string;
  18111. /**
  18112. * Dispose the texture and release its associated resources.
  18113. */
  18114. dispose(): void;
  18115. /**
  18116. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18117. * @param parsedTexture Define the JSON representation of the texture
  18118. * @param scene Define the scene the parsed texture should be instantiated in
  18119. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18120. * @returns The parsed texture if successful
  18121. */
  18122. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18123. /**
  18124. * Creates a texture from its base 64 representation.
  18125. * @param data Define the base64 payload without the data: prefix
  18126. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18127. * @param scene Define the scene the texture should belong to
  18128. * @param noMipmap Forces the texture to not create mip map information if true
  18129. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18130. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18131. * @param onLoad define a callback triggered when the texture has been loaded
  18132. * @param onError define a callback triggered when an error occurred during the loading session
  18133. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18134. * @returns the created texture
  18135. */
  18136. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18137. /**
  18138. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18139. * @param data Define the base64 payload without the data: prefix
  18140. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18141. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18142. * @param scene Define the scene the texture should belong to
  18143. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18144. * @param noMipmap Forces the texture to not create mip map information if true
  18145. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18146. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18147. * @param onLoad define a callback triggered when the texture has been loaded
  18148. * @param onError define a callback triggered when an error occurred during the loading session
  18149. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18150. * @returns the created texture
  18151. */
  18152. 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;
  18153. }
  18154. }
  18155. declare module BABYLON {
  18156. /**
  18157. * Raw texture can help creating a texture directly from an array of data.
  18158. * This can be super useful if you either get the data from an uncompressed source or
  18159. * if you wish to create your texture pixel by pixel.
  18160. */
  18161. export class RawTexture extends Texture {
  18162. /**
  18163. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18164. */
  18165. format: number;
  18166. private _engine;
  18167. /**
  18168. * Instantiates a new RawTexture.
  18169. * Raw texture can help creating a texture directly from an array of data.
  18170. * This can be super useful if you either get the data from an uncompressed source or
  18171. * if you wish to create your texture pixel by pixel.
  18172. * @param data define the array of data to use to create the texture
  18173. * @param width define the width of the texture
  18174. * @param height define the height of the texture
  18175. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18176. * @param scene define the scene the texture belongs to
  18177. * @param generateMipMaps define whether mip maps should be generated or not
  18178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18180. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18181. */
  18182. constructor(data: ArrayBufferView, width: number, height: number,
  18183. /**
  18184. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18185. */
  18186. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18187. /**
  18188. * Updates the texture underlying data.
  18189. * @param data Define the new data of the texture
  18190. */
  18191. update(data: ArrayBufferView): void;
  18192. /**
  18193. * Creates a luminance texture from some data.
  18194. * @param data Define the texture data
  18195. * @param width Define the width of the texture
  18196. * @param height Define the height of the texture
  18197. * @param scene Define the scene the texture belongs to
  18198. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18199. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18200. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18201. * @returns the luminance texture
  18202. */
  18203. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18204. /**
  18205. * Creates a luminance alpha texture from some data.
  18206. * @param data Define the texture data
  18207. * @param width Define the width of the texture
  18208. * @param height Define the height of the texture
  18209. * @param scene Define the scene the texture belongs to
  18210. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18211. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18212. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18213. * @returns the luminance alpha texture
  18214. */
  18215. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18216. /**
  18217. * Creates an alpha texture from some data.
  18218. * @param data Define the texture data
  18219. * @param width Define the width of the texture
  18220. * @param height Define the height of the texture
  18221. * @param scene Define the scene the texture belongs to
  18222. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18223. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18224. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18225. * @returns the alpha texture
  18226. */
  18227. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18228. /**
  18229. * Creates a RGB texture from some data.
  18230. * @param data Define the texture data
  18231. * @param width Define the width of the texture
  18232. * @param height Define the height of the texture
  18233. * @param scene Define the scene the texture belongs to
  18234. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18235. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18236. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18237. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18238. * @returns the RGB alpha texture
  18239. */
  18240. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18241. /**
  18242. * Creates a RGBA texture from some data.
  18243. * @param data Define the texture data
  18244. * @param width Define the width of the texture
  18245. * @param height Define the height of the texture
  18246. * @param scene Define the scene the texture belongs to
  18247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18250. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18251. * @returns the RGBA texture
  18252. */
  18253. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18254. /**
  18255. * Creates a R texture from some data.
  18256. * @param data Define the texture data
  18257. * @param width Define the width of the texture
  18258. * @param height Define the height of the texture
  18259. * @param scene Define the scene the texture belongs to
  18260. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18261. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18262. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18263. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18264. * @returns the R texture
  18265. */
  18266. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18267. }
  18268. }
  18269. declare module BABYLON {
  18270. /**
  18271. * Defines a runtime animation
  18272. */
  18273. export class RuntimeAnimation {
  18274. private _events;
  18275. /**
  18276. * The current frame of the runtime animation
  18277. */
  18278. private _currentFrame;
  18279. /**
  18280. * The animation used by the runtime animation
  18281. */
  18282. private _animation;
  18283. /**
  18284. * The target of the runtime animation
  18285. */
  18286. private _target;
  18287. /**
  18288. * The initiating animatable
  18289. */
  18290. private _host;
  18291. /**
  18292. * The original value of the runtime animation
  18293. */
  18294. private _originalValue;
  18295. /**
  18296. * The original blend value of the runtime animation
  18297. */
  18298. private _originalBlendValue;
  18299. /**
  18300. * The offsets cache of the runtime animation
  18301. */
  18302. private _offsetsCache;
  18303. /**
  18304. * The high limits cache of the runtime animation
  18305. */
  18306. private _highLimitsCache;
  18307. /**
  18308. * Specifies if the runtime animation has been stopped
  18309. */
  18310. private _stopped;
  18311. /**
  18312. * The blending factor of the runtime animation
  18313. */
  18314. private _blendingFactor;
  18315. /**
  18316. * The BabylonJS scene
  18317. */
  18318. private _scene;
  18319. /**
  18320. * The current value of the runtime animation
  18321. */
  18322. private _currentValue;
  18323. /** @hidden */
  18324. _animationState: _IAnimationState;
  18325. /**
  18326. * The active target of the runtime animation
  18327. */
  18328. private _activeTargets;
  18329. private _currentActiveTarget;
  18330. private _directTarget;
  18331. /**
  18332. * The target path of the runtime animation
  18333. */
  18334. private _targetPath;
  18335. /**
  18336. * The weight of the runtime animation
  18337. */
  18338. private _weight;
  18339. /**
  18340. * The ratio offset of the runtime animation
  18341. */
  18342. private _ratioOffset;
  18343. /**
  18344. * The previous delay of the runtime animation
  18345. */
  18346. private _previousDelay;
  18347. /**
  18348. * The previous ratio of the runtime animation
  18349. */
  18350. private _previousRatio;
  18351. private _enableBlending;
  18352. private _keys;
  18353. private _minFrame;
  18354. private _maxFrame;
  18355. private _minValue;
  18356. private _maxValue;
  18357. private _targetIsArray;
  18358. /**
  18359. * Gets the current frame of the runtime animation
  18360. */
  18361. readonly currentFrame: number;
  18362. /**
  18363. * Gets the weight of the runtime animation
  18364. */
  18365. readonly weight: number;
  18366. /**
  18367. * Gets the current value of the runtime animation
  18368. */
  18369. readonly currentValue: any;
  18370. /**
  18371. * Gets the target path of the runtime animation
  18372. */
  18373. readonly targetPath: string;
  18374. /**
  18375. * Gets the actual target of the runtime animation
  18376. */
  18377. readonly target: any;
  18378. /** @hidden */
  18379. _onLoop: () => void;
  18380. /**
  18381. * Create a new RuntimeAnimation object
  18382. * @param target defines the target of the animation
  18383. * @param animation defines the source animation object
  18384. * @param scene defines the hosting scene
  18385. * @param host defines the initiating Animatable
  18386. */
  18387. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18388. private _preparePath;
  18389. /**
  18390. * Gets the animation from the runtime animation
  18391. */
  18392. readonly animation: Animation;
  18393. /**
  18394. * Resets the runtime animation to the beginning
  18395. * @param restoreOriginal defines whether to restore the target property to the original value
  18396. */
  18397. reset(restoreOriginal?: boolean): void;
  18398. /**
  18399. * Specifies if the runtime animation is stopped
  18400. * @returns Boolean specifying if the runtime animation is stopped
  18401. */
  18402. isStopped(): boolean;
  18403. /**
  18404. * Disposes of the runtime animation
  18405. */
  18406. dispose(): void;
  18407. /**
  18408. * Apply the interpolated value to the target
  18409. * @param currentValue defines the value computed by the animation
  18410. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18411. */
  18412. setValue(currentValue: any, weight: number): void;
  18413. private _getOriginalValues;
  18414. private _setValue;
  18415. /**
  18416. * Gets the loop pmode of the runtime animation
  18417. * @returns Loop Mode
  18418. */
  18419. private _getCorrectLoopMode;
  18420. /**
  18421. * Move the current animation to a given frame
  18422. * @param frame defines the frame to move to
  18423. */
  18424. goToFrame(frame: number): void;
  18425. /**
  18426. * @hidden Internal use only
  18427. */
  18428. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18429. /**
  18430. * Execute the current animation
  18431. * @param delay defines the delay to add to the current frame
  18432. * @param from defines the lower bound of the animation range
  18433. * @param to defines the upper bound of the animation range
  18434. * @param loop defines if the current animation must loop
  18435. * @param speedRatio defines the current speed ratio
  18436. * @param weight defines the weight of the animation (default is -1 so no weight)
  18437. * @param onLoop optional callback called when animation loops
  18438. * @returns a boolean indicating if the animation is running
  18439. */
  18440. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18441. }
  18442. }
  18443. declare module BABYLON {
  18444. /**
  18445. * Class used to store an actual running animation
  18446. */
  18447. export class Animatable {
  18448. /** defines the target object */
  18449. target: any;
  18450. /** defines the starting frame number (default is 0) */
  18451. fromFrame: number;
  18452. /** defines the ending frame number (default is 100) */
  18453. toFrame: number;
  18454. /** defines if the animation must loop (default is false) */
  18455. loopAnimation: boolean;
  18456. /** defines a callback to call when animation ends if it is not looping */
  18457. onAnimationEnd?: (() => void) | null | undefined;
  18458. /** defines a callback to call when animation loops */
  18459. onAnimationLoop?: (() => void) | null | undefined;
  18460. private _localDelayOffset;
  18461. private _pausedDelay;
  18462. private _runtimeAnimations;
  18463. private _paused;
  18464. private _scene;
  18465. private _speedRatio;
  18466. private _weight;
  18467. private _syncRoot;
  18468. /**
  18469. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18470. * This will only apply for non looping animation (default is true)
  18471. */
  18472. disposeOnEnd: boolean;
  18473. /**
  18474. * Gets a boolean indicating if the animation has started
  18475. */
  18476. animationStarted: boolean;
  18477. /**
  18478. * Observer raised when the animation ends
  18479. */
  18480. onAnimationEndObservable: Observable<Animatable>;
  18481. /**
  18482. * Observer raised when the animation loops
  18483. */
  18484. onAnimationLoopObservable: Observable<Animatable>;
  18485. /**
  18486. * Gets the root Animatable used to synchronize and normalize animations
  18487. */
  18488. readonly syncRoot: Nullable<Animatable>;
  18489. /**
  18490. * Gets the current frame of the first RuntimeAnimation
  18491. * Used to synchronize Animatables
  18492. */
  18493. readonly masterFrame: number;
  18494. /**
  18495. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18496. */
  18497. weight: number;
  18498. /**
  18499. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18500. */
  18501. speedRatio: number;
  18502. /**
  18503. * Creates a new Animatable
  18504. * @param scene defines the hosting scene
  18505. * @param target defines the target object
  18506. * @param fromFrame defines the starting frame number (default is 0)
  18507. * @param toFrame defines the ending frame number (default is 100)
  18508. * @param loopAnimation defines if the animation must loop (default is false)
  18509. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18510. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18511. * @param animations defines a group of animation to add to the new Animatable
  18512. * @param onAnimationLoop defines a callback to call when animation loops
  18513. */
  18514. constructor(scene: Scene,
  18515. /** defines the target object */
  18516. target: any,
  18517. /** defines the starting frame number (default is 0) */
  18518. fromFrame?: number,
  18519. /** defines the ending frame number (default is 100) */
  18520. toFrame?: number,
  18521. /** defines if the animation must loop (default is false) */
  18522. loopAnimation?: boolean, speedRatio?: number,
  18523. /** defines a callback to call when animation ends if it is not looping */
  18524. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18525. /** defines a callback to call when animation loops */
  18526. onAnimationLoop?: (() => void) | null | undefined);
  18527. /**
  18528. * Synchronize and normalize current Animatable with a source Animatable
  18529. * This is useful when using animation weights and when animations are not of the same length
  18530. * @param root defines the root Animatable to synchronize with
  18531. * @returns the current Animatable
  18532. */
  18533. syncWith(root: Animatable): Animatable;
  18534. /**
  18535. * Gets the list of runtime animations
  18536. * @returns an array of RuntimeAnimation
  18537. */
  18538. getAnimations(): RuntimeAnimation[];
  18539. /**
  18540. * Adds more animations to the current animatable
  18541. * @param target defines the target of the animations
  18542. * @param animations defines the new animations to add
  18543. */
  18544. appendAnimations(target: any, animations: Animation[]): void;
  18545. /**
  18546. * Gets the source animation for a specific property
  18547. * @param property defines the propertyu to look for
  18548. * @returns null or the source animation for the given property
  18549. */
  18550. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18551. /**
  18552. * Gets the runtime animation for a specific property
  18553. * @param property defines the propertyu to look for
  18554. * @returns null or the runtime animation for the given property
  18555. */
  18556. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18557. /**
  18558. * Resets the animatable to its original state
  18559. */
  18560. reset(): void;
  18561. /**
  18562. * Allows the animatable to blend with current running animations
  18563. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18564. * @param blendingSpeed defines the blending speed to use
  18565. */
  18566. enableBlending(blendingSpeed: number): void;
  18567. /**
  18568. * Disable animation blending
  18569. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18570. */
  18571. disableBlending(): void;
  18572. /**
  18573. * Jump directly to a given frame
  18574. * @param frame defines the frame to jump to
  18575. */
  18576. goToFrame(frame: number): void;
  18577. /**
  18578. * Pause the animation
  18579. */
  18580. pause(): void;
  18581. /**
  18582. * Restart the animation
  18583. */
  18584. restart(): void;
  18585. private _raiseOnAnimationEnd;
  18586. /**
  18587. * Stop and delete the current animation
  18588. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18589. * @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)
  18590. */
  18591. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18592. /**
  18593. * Wait asynchronously for the animation to end
  18594. * @returns a promise which will be fullfilled when the animation ends
  18595. */
  18596. waitAsync(): Promise<Animatable>;
  18597. /** @hidden */
  18598. _animate(delay: number): boolean;
  18599. }
  18600. interface Scene {
  18601. /** @hidden */
  18602. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18603. /** @hidden */
  18604. _processLateAnimationBindingsForMatrices(holder: {
  18605. totalWeight: number;
  18606. animations: RuntimeAnimation[];
  18607. originalValue: Matrix;
  18608. }): any;
  18609. /** @hidden */
  18610. _processLateAnimationBindingsForQuaternions(holder: {
  18611. totalWeight: number;
  18612. animations: RuntimeAnimation[];
  18613. originalValue: Quaternion;
  18614. }, refQuaternion: Quaternion): Quaternion;
  18615. /** @hidden */
  18616. _processLateAnimationBindings(): void;
  18617. /**
  18618. * Will start the animation sequence of a given target
  18619. * @param target defines the target
  18620. * @param from defines from which frame should animation start
  18621. * @param to defines until which frame should animation run.
  18622. * @param weight defines the weight to apply to the animation (1.0 by default)
  18623. * @param loop defines if the animation loops
  18624. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18625. * @param onAnimationEnd defines the function to be executed when the animation ends
  18626. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18627. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18628. * @param onAnimationLoop defines the callback to call when an animation loops
  18629. * @returns the animatable object created for this animation
  18630. */
  18631. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18632. /**
  18633. * Will start the animation sequence of a given target
  18634. * @param target defines the target
  18635. * @param from defines from which frame should animation start
  18636. * @param to defines until which frame should animation run.
  18637. * @param loop defines if the animation loops
  18638. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18639. * @param onAnimationEnd defines the function to be executed when the animation ends
  18640. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18641. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18642. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18643. * @param onAnimationLoop defines the callback to call when an animation loops
  18644. * @returns the animatable object created for this animation
  18645. */
  18646. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18647. /**
  18648. * Will start the animation sequence of a given target and its hierarchy
  18649. * @param target defines the target
  18650. * @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.
  18651. * @param from defines from which frame should animation start
  18652. * @param to defines until which frame should animation run.
  18653. * @param loop defines if the animation loops
  18654. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18655. * @param onAnimationEnd defines the function to be executed when the animation ends
  18656. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18657. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18658. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18659. * @param onAnimationLoop defines the callback to call when an animation loops
  18660. * @returns the list of created animatables
  18661. */
  18662. 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[];
  18663. /**
  18664. * Begin a new animation on a given node
  18665. * @param target defines the target where the animation will take place
  18666. * @param animations defines the list of animations to start
  18667. * @param from defines the initial value
  18668. * @param to defines the final value
  18669. * @param loop defines if you want animation to loop (off by default)
  18670. * @param speedRatio defines the speed ratio to apply to all animations
  18671. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18672. * @param onAnimationLoop defines the callback to call when an animation loops
  18673. * @returns the list of created animatables
  18674. */
  18675. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18676. /**
  18677. * Begin a new animation on a given node and its hierarchy
  18678. * @param target defines the root node where the animation will take place
  18679. * @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.
  18680. * @param animations defines the list of animations to start
  18681. * @param from defines the initial value
  18682. * @param to defines the final value
  18683. * @param loop defines if you want animation to loop (off by default)
  18684. * @param speedRatio defines the speed ratio to apply to all animations
  18685. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18686. * @param onAnimationLoop defines the callback to call when an animation loops
  18687. * @returns the list of animatables created for all nodes
  18688. */
  18689. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18690. /**
  18691. * Gets the animatable associated with a specific target
  18692. * @param target defines the target of the animatable
  18693. * @returns the required animatable if found
  18694. */
  18695. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18696. /**
  18697. * Gets all animatables associated with a given target
  18698. * @param target defines the target to look animatables for
  18699. * @returns an array of Animatables
  18700. */
  18701. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18702. /**
  18703. * Will stop the animation of the given target
  18704. * @param target - the target
  18705. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18706. * @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)
  18707. */
  18708. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18709. /**
  18710. * Stops and removes all animations that have been applied to the scene
  18711. */
  18712. stopAllAnimations(): void;
  18713. }
  18714. interface Bone {
  18715. /**
  18716. * Copy an animation range from another bone
  18717. * @param source defines the source bone
  18718. * @param rangeName defines the range name to copy
  18719. * @param frameOffset defines the frame offset
  18720. * @param rescaleAsRequired defines if rescaling must be applied if required
  18721. * @param skelDimensionsRatio defines the scaling ratio
  18722. * @returns true if operation was successful
  18723. */
  18724. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18725. }
  18726. }
  18727. declare module BABYLON {
  18728. /**
  18729. * Class used to handle skinning animations
  18730. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18731. */
  18732. export class Skeleton implements IAnimatable {
  18733. /** defines the skeleton name */
  18734. name: string;
  18735. /** defines the skeleton Id */
  18736. id: string;
  18737. /**
  18738. * Defines the list of child bones
  18739. */
  18740. bones: Bone[];
  18741. /**
  18742. * Defines an estimate of the dimension of the skeleton at rest
  18743. */
  18744. dimensionsAtRest: Vector3;
  18745. /**
  18746. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18747. */
  18748. needInitialSkinMatrix: boolean;
  18749. /**
  18750. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18751. */
  18752. overrideMesh: Nullable<AbstractMesh>;
  18753. /**
  18754. * Gets the list of animations attached to this skeleton
  18755. */
  18756. animations: Array<Animation>;
  18757. private _scene;
  18758. private _isDirty;
  18759. private _transformMatrices;
  18760. private _transformMatrixTexture;
  18761. private _meshesWithPoseMatrix;
  18762. private _animatables;
  18763. private _identity;
  18764. private _synchronizedWithMesh;
  18765. private _ranges;
  18766. private _lastAbsoluteTransformsUpdateId;
  18767. private _canUseTextureForBones;
  18768. private _uniqueId;
  18769. /** @hidden */
  18770. _numBonesWithLinkedTransformNode: number;
  18771. /**
  18772. * Specifies if the skeleton should be serialized
  18773. */
  18774. doNotSerialize: boolean;
  18775. private _useTextureToStoreBoneMatrices;
  18776. /**
  18777. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18778. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18779. */
  18780. useTextureToStoreBoneMatrices: boolean;
  18781. private _animationPropertiesOverride;
  18782. /**
  18783. * Gets or sets the animation properties override
  18784. */
  18785. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18786. /**
  18787. * List of inspectable custom properties (used by the Inspector)
  18788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18789. */
  18790. inspectableCustomProperties: IInspectable[];
  18791. /**
  18792. * An observable triggered before computing the skeleton's matrices
  18793. */
  18794. onBeforeComputeObservable: Observable<Skeleton>;
  18795. /**
  18796. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18797. */
  18798. readonly isUsingTextureForMatrices: boolean;
  18799. /**
  18800. * Gets the unique ID of this skeleton
  18801. */
  18802. readonly uniqueId: number;
  18803. /**
  18804. * Creates a new skeleton
  18805. * @param name defines the skeleton name
  18806. * @param id defines the skeleton Id
  18807. * @param scene defines the hosting scene
  18808. */
  18809. constructor(
  18810. /** defines the skeleton name */
  18811. name: string,
  18812. /** defines the skeleton Id */
  18813. id: string, scene: Scene);
  18814. /**
  18815. * Gets the current object class name.
  18816. * @return the class name
  18817. */
  18818. getClassName(): string;
  18819. /**
  18820. * Returns an array containing the root bones
  18821. * @returns an array containing the root bones
  18822. */
  18823. getChildren(): Array<Bone>;
  18824. /**
  18825. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18826. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18827. * @returns a Float32Array containing matrices data
  18828. */
  18829. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18830. /**
  18831. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18832. * @returns a raw texture containing the data
  18833. */
  18834. getTransformMatrixTexture(): Nullable<RawTexture>;
  18835. /**
  18836. * Gets the current hosting scene
  18837. * @returns a scene object
  18838. */
  18839. getScene(): Scene;
  18840. /**
  18841. * Gets a string representing the current skeleton data
  18842. * @param fullDetails defines a boolean indicating if we want a verbose version
  18843. * @returns a string representing the current skeleton data
  18844. */
  18845. toString(fullDetails?: boolean): string;
  18846. /**
  18847. * Get bone's index searching by name
  18848. * @param name defines bone's name to search for
  18849. * @return the indice of the bone. Returns -1 if not found
  18850. */
  18851. getBoneIndexByName(name: string): number;
  18852. /**
  18853. * Creater a new animation range
  18854. * @param name defines the name of the range
  18855. * @param from defines the start key
  18856. * @param to defines the end key
  18857. */
  18858. createAnimationRange(name: string, from: number, to: number): void;
  18859. /**
  18860. * Delete a specific animation range
  18861. * @param name defines the name of the range
  18862. * @param deleteFrames defines if frames must be removed as well
  18863. */
  18864. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18865. /**
  18866. * Gets a specific animation range
  18867. * @param name defines the name of the range to look for
  18868. * @returns the requested animation range or null if not found
  18869. */
  18870. getAnimationRange(name: string): Nullable<AnimationRange>;
  18871. /**
  18872. * Gets the list of all animation ranges defined on this skeleton
  18873. * @returns an array
  18874. */
  18875. getAnimationRanges(): Nullable<AnimationRange>[];
  18876. /**
  18877. * Copy animation range from a source skeleton.
  18878. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18879. * @param source defines the source skeleton
  18880. * @param name defines the name of the range to copy
  18881. * @param rescaleAsRequired defines if rescaling must be applied if required
  18882. * @returns true if operation was successful
  18883. */
  18884. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18885. /**
  18886. * Forces the skeleton to go to rest pose
  18887. */
  18888. returnToRest(): void;
  18889. private _getHighestAnimationFrame;
  18890. /**
  18891. * Begin a specific animation range
  18892. * @param name defines the name of the range to start
  18893. * @param loop defines if looping must be turned on (false by default)
  18894. * @param speedRatio defines the speed ratio to apply (1 by default)
  18895. * @param onAnimationEnd defines a callback which will be called when animation will end
  18896. * @returns a new animatable
  18897. */
  18898. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18899. /** @hidden */
  18900. _markAsDirty(): void;
  18901. /** @hidden */
  18902. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18903. /** @hidden */
  18904. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18905. private _computeTransformMatrices;
  18906. /**
  18907. * Build all resources required to render a skeleton
  18908. */
  18909. prepare(): void;
  18910. /**
  18911. * Gets the list of animatables currently running for this skeleton
  18912. * @returns an array of animatables
  18913. */
  18914. getAnimatables(): IAnimatable[];
  18915. /**
  18916. * Clone the current skeleton
  18917. * @param name defines the name of the new skeleton
  18918. * @param id defines the id of the new skeleton
  18919. * @returns the new skeleton
  18920. */
  18921. clone(name: string, id: string): Skeleton;
  18922. /**
  18923. * Enable animation blending for this skeleton
  18924. * @param blendingSpeed defines the blending speed to apply
  18925. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18926. */
  18927. enableBlending(blendingSpeed?: number): void;
  18928. /**
  18929. * Releases all resources associated with the current skeleton
  18930. */
  18931. dispose(): void;
  18932. /**
  18933. * Serialize the skeleton in a JSON object
  18934. * @returns a JSON object
  18935. */
  18936. serialize(): any;
  18937. /**
  18938. * Creates a new skeleton from serialized data
  18939. * @param parsedSkeleton defines the serialized data
  18940. * @param scene defines the hosting scene
  18941. * @returns a new skeleton
  18942. */
  18943. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18944. /**
  18945. * Compute all node absolute transforms
  18946. * @param forceUpdate defines if computation must be done even if cache is up to date
  18947. */
  18948. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18949. /**
  18950. * Gets the root pose matrix
  18951. * @returns a matrix
  18952. */
  18953. getPoseMatrix(): Nullable<Matrix>;
  18954. /**
  18955. * Sorts bones per internal index
  18956. */
  18957. sortBones(): void;
  18958. private _sortBones;
  18959. }
  18960. }
  18961. declare module BABYLON {
  18962. /**
  18963. * Defines a target to use with MorphTargetManager
  18964. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18965. */
  18966. export class MorphTarget implements IAnimatable {
  18967. /** defines the name of the target */
  18968. name: string;
  18969. /**
  18970. * Gets or sets the list of animations
  18971. */
  18972. animations: Animation[];
  18973. private _scene;
  18974. private _positions;
  18975. private _normals;
  18976. private _tangents;
  18977. private _influence;
  18978. /**
  18979. * Observable raised when the influence changes
  18980. */
  18981. onInfluenceChanged: Observable<boolean>;
  18982. /** @hidden */
  18983. _onDataLayoutChanged: Observable<void>;
  18984. /**
  18985. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18986. */
  18987. influence: number;
  18988. /**
  18989. * Gets or sets the id of the morph Target
  18990. */
  18991. id: string;
  18992. private _animationPropertiesOverride;
  18993. /**
  18994. * Gets or sets the animation properties override
  18995. */
  18996. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18997. /**
  18998. * Creates a new MorphTarget
  18999. * @param name defines the name of the target
  19000. * @param influence defines the influence to use
  19001. * @param scene defines the scene the morphtarget belongs to
  19002. */
  19003. constructor(
  19004. /** defines the name of the target */
  19005. name: string, influence?: number, scene?: Nullable<Scene>);
  19006. /**
  19007. * Gets a boolean defining if the target contains position data
  19008. */
  19009. readonly hasPositions: boolean;
  19010. /**
  19011. * Gets a boolean defining if the target contains normal data
  19012. */
  19013. readonly hasNormals: boolean;
  19014. /**
  19015. * Gets a boolean defining if the target contains tangent data
  19016. */
  19017. readonly hasTangents: boolean;
  19018. /**
  19019. * Affects position data to this target
  19020. * @param data defines the position data to use
  19021. */
  19022. setPositions(data: Nullable<FloatArray>): void;
  19023. /**
  19024. * Gets the position data stored in this target
  19025. * @returns a FloatArray containing the position data (or null if not present)
  19026. */
  19027. getPositions(): Nullable<FloatArray>;
  19028. /**
  19029. * Affects normal data to this target
  19030. * @param data defines the normal data to use
  19031. */
  19032. setNormals(data: Nullable<FloatArray>): void;
  19033. /**
  19034. * Gets the normal data stored in this target
  19035. * @returns a FloatArray containing the normal data (or null if not present)
  19036. */
  19037. getNormals(): Nullable<FloatArray>;
  19038. /**
  19039. * Affects tangent data to this target
  19040. * @param data defines the tangent data to use
  19041. */
  19042. setTangents(data: Nullable<FloatArray>): void;
  19043. /**
  19044. * Gets the tangent data stored in this target
  19045. * @returns a FloatArray containing the tangent data (or null if not present)
  19046. */
  19047. getTangents(): Nullable<FloatArray>;
  19048. /**
  19049. * Serializes the current target into a Serialization object
  19050. * @returns the serialized object
  19051. */
  19052. serialize(): any;
  19053. /**
  19054. * Returns the string "MorphTarget"
  19055. * @returns "MorphTarget"
  19056. */
  19057. getClassName(): string;
  19058. /**
  19059. * Creates a new target from serialized data
  19060. * @param serializationObject defines the serialized data to use
  19061. * @returns a new MorphTarget
  19062. */
  19063. static Parse(serializationObject: any): MorphTarget;
  19064. /**
  19065. * Creates a MorphTarget from mesh data
  19066. * @param mesh defines the source mesh
  19067. * @param name defines the name to use for the new target
  19068. * @param influence defines the influence to attach to the target
  19069. * @returns a new MorphTarget
  19070. */
  19071. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19072. }
  19073. }
  19074. declare module BABYLON {
  19075. /**
  19076. * This class is used to deform meshes using morphing between different targets
  19077. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19078. */
  19079. export class MorphTargetManager {
  19080. private _targets;
  19081. private _targetInfluenceChangedObservers;
  19082. private _targetDataLayoutChangedObservers;
  19083. private _activeTargets;
  19084. private _scene;
  19085. private _influences;
  19086. private _supportsNormals;
  19087. private _supportsTangents;
  19088. private _vertexCount;
  19089. private _uniqueId;
  19090. private _tempInfluences;
  19091. /**
  19092. * Creates a new MorphTargetManager
  19093. * @param scene defines the current scene
  19094. */
  19095. constructor(scene?: Nullable<Scene>);
  19096. /**
  19097. * Gets the unique ID of this manager
  19098. */
  19099. readonly uniqueId: number;
  19100. /**
  19101. * Gets the number of vertices handled by this manager
  19102. */
  19103. readonly vertexCount: number;
  19104. /**
  19105. * Gets a boolean indicating if this manager supports morphing of normals
  19106. */
  19107. readonly supportsNormals: boolean;
  19108. /**
  19109. * Gets a boolean indicating if this manager supports morphing of tangents
  19110. */
  19111. readonly supportsTangents: boolean;
  19112. /**
  19113. * Gets the number of targets stored in this manager
  19114. */
  19115. readonly numTargets: number;
  19116. /**
  19117. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19118. */
  19119. readonly numInfluencers: number;
  19120. /**
  19121. * Gets the list of influences (one per target)
  19122. */
  19123. readonly influences: Float32Array;
  19124. /**
  19125. * Gets the active target at specified index. An active target is a target with an influence > 0
  19126. * @param index defines the index to check
  19127. * @returns the requested target
  19128. */
  19129. getActiveTarget(index: number): MorphTarget;
  19130. /**
  19131. * Gets the target at specified index
  19132. * @param index defines the index to check
  19133. * @returns the requested target
  19134. */
  19135. getTarget(index: number): MorphTarget;
  19136. /**
  19137. * Add a new target to this manager
  19138. * @param target defines the target to add
  19139. */
  19140. addTarget(target: MorphTarget): void;
  19141. /**
  19142. * Removes a target from the manager
  19143. * @param target defines the target to remove
  19144. */
  19145. removeTarget(target: MorphTarget): void;
  19146. /**
  19147. * Serializes the current manager into a Serialization object
  19148. * @returns the serialized object
  19149. */
  19150. serialize(): any;
  19151. private _syncActiveTargets;
  19152. /**
  19153. * Syncrhonize the targets with all the meshes using this morph target manager
  19154. */
  19155. synchronize(): void;
  19156. /**
  19157. * Creates a new MorphTargetManager from serialized data
  19158. * @param serializationObject defines the serialized data
  19159. * @param scene defines the hosting scene
  19160. * @returns the new MorphTargetManager
  19161. */
  19162. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19163. }
  19164. }
  19165. declare module BABYLON {
  19166. /**
  19167. * Mesh representing the gorund
  19168. */
  19169. export class GroundMesh extends Mesh {
  19170. /** If octree should be generated */
  19171. generateOctree: boolean;
  19172. private _heightQuads;
  19173. /** @hidden */
  19174. _subdivisionsX: number;
  19175. /** @hidden */
  19176. _subdivisionsY: number;
  19177. /** @hidden */
  19178. _width: number;
  19179. /** @hidden */
  19180. _height: number;
  19181. /** @hidden */
  19182. _minX: number;
  19183. /** @hidden */
  19184. _maxX: number;
  19185. /** @hidden */
  19186. _minZ: number;
  19187. /** @hidden */
  19188. _maxZ: number;
  19189. constructor(name: string, scene: Scene);
  19190. /**
  19191. * "GroundMesh"
  19192. * @returns "GroundMesh"
  19193. */
  19194. getClassName(): string;
  19195. /**
  19196. * The minimum of x and y subdivisions
  19197. */
  19198. readonly subdivisions: number;
  19199. /**
  19200. * X subdivisions
  19201. */
  19202. readonly subdivisionsX: number;
  19203. /**
  19204. * Y subdivisions
  19205. */
  19206. readonly subdivisionsY: number;
  19207. /**
  19208. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19209. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19210. * @param chunksCount the number of subdivisions for x and y
  19211. * @param octreeBlocksSize (Default: 32)
  19212. */
  19213. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19214. /**
  19215. * Returns a height (y) value in the Worl system :
  19216. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19217. * @param x x coordinate
  19218. * @param z z coordinate
  19219. * @returns the ground y position if (x, z) are outside the ground surface.
  19220. */
  19221. getHeightAtCoordinates(x: number, z: number): number;
  19222. /**
  19223. * Returns a normalized vector (Vector3) orthogonal to the ground
  19224. * at the ground coordinates (x, z) expressed in the World system.
  19225. * @param x x coordinate
  19226. * @param z z coordinate
  19227. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19228. */
  19229. getNormalAtCoordinates(x: number, z: number): Vector3;
  19230. /**
  19231. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19232. * at the ground coordinates (x, z) expressed in the World system.
  19233. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19234. * @param x x coordinate
  19235. * @param z z coordinate
  19236. * @param ref vector to store the result
  19237. * @returns the GroundMesh.
  19238. */
  19239. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19240. /**
  19241. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19242. * if the ground has been updated.
  19243. * This can be used in the render loop.
  19244. * @returns the GroundMesh.
  19245. */
  19246. updateCoordinateHeights(): GroundMesh;
  19247. private _getFacetAt;
  19248. private _initHeightQuads;
  19249. private _computeHeightQuads;
  19250. /**
  19251. * Serializes this ground mesh
  19252. * @param serializationObject object to write serialization to
  19253. */
  19254. serialize(serializationObject: any): void;
  19255. /**
  19256. * Parses a serialized ground mesh
  19257. * @param parsedMesh the serialized mesh
  19258. * @param scene the scene to create the ground mesh in
  19259. * @returns the created ground mesh
  19260. */
  19261. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19262. }
  19263. }
  19264. declare module BABYLON {
  19265. /**
  19266. * Interface for Physics-Joint data
  19267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19268. */
  19269. export interface PhysicsJointData {
  19270. /**
  19271. * The main pivot of the joint
  19272. */
  19273. mainPivot?: Vector3;
  19274. /**
  19275. * The connected pivot of the joint
  19276. */
  19277. connectedPivot?: Vector3;
  19278. /**
  19279. * The main axis of the joint
  19280. */
  19281. mainAxis?: Vector3;
  19282. /**
  19283. * The connected axis of the joint
  19284. */
  19285. connectedAxis?: Vector3;
  19286. /**
  19287. * The collision of the joint
  19288. */
  19289. collision?: boolean;
  19290. /**
  19291. * Native Oimo/Cannon/Energy data
  19292. */
  19293. nativeParams?: any;
  19294. }
  19295. /**
  19296. * This is a holder class for the physics joint created by the physics plugin
  19297. * It holds a set of functions to control the underlying joint
  19298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19299. */
  19300. export class PhysicsJoint {
  19301. /**
  19302. * The type of the physics joint
  19303. */
  19304. type: number;
  19305. /**
  19306. * The data for the physics joint
  19307. */
  19308. jointData: PhysicsJointData;
  19309. private _physicsJoint;
  19310. protected _physicsPlugin: IPhysicsEnginePlugin;
  19311. /**
  19312. * Initializes the physics joint
  19313. * @param type The type of the physics joint
  19314. * @param jointData The data for the physics joint
  19315. */
  19316. constructor(
  19317. /**
  19318. * The type of the physics joint
  19319. */
  19320. type: number,
  19321. /**
  19322. * The data for the physics joint
  19323. */
  19324. jointData: PhysicsJointData);
  19325. /**
  19326. * Gets the physics joint
  19327. */
  19328. /**
  19329. * Sets the physics joint
  19330. */
  19331. physicsJoint: any;
  19332. /**
  19333. * Sets the physics plugin
  19334. */
  19335. physicsPlugin: IPhysicsEnginePlugin;
  19336. /**
  19337. * Execute a function that is physics-plugin specific.
  19338. * @param {Function} func the function that will be executed.
  19339. * It accepts two parameters: the physics world and the physics joint
  19340. */
  19341. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19342. /**
  19343. * Distance-Joint type
  19344. */
  19345. static DistanceJoint: number;
  19346. /**
  19347. * Hinge-Joint type
  19348. */
  19349. static HingeJoint: number;
  19350. /**
  19351. * Ball-and-Socket joint type
  19352. */
  19353. static BallAndSocketJoint: number;
  19354. /**
  19355. * Wheel-Joint type
  19356. */
  19357. static WheelJoint: number;
  19358. /**
  19359. * Slider-Joint type
  19360. */
  19361. static SliderJoint: number;
  19362. /**
  19363. * Prismatic-Joint type
  19364. */
  19365. static PrismaticJoint: number;
  19366. /**
  19367. * Universal-Joint type
  19368. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19369. */
  19370. static UniversalJoint: number;
  19371. /**
  19372. * Hinge-Joint 2 type
  19373. */
  19374. static Hinge2Joint: number;
  19375. /**
  19376. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19377. */
  19378. static PointToPointJoint: number;
  19379. /**
  19380. * Spring-Joint type
  19381. */
  19382. static SpringJoint: number;
  19383. /**
  19384. * Lock-Joint type
  19385. */
  19386. static LockJoint: number;
  19387. }
  19388. /**
  19389. * A class representing a physics distance joint
  19390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19391. */
  19392. export class DistanceJoint extends PhysicsJoint {
  19393. /**
  19394. *
  19395. * @param jointData The data for the Distance-Joint
  19396. */
  19397. constructor(jointData: DistanceJointData);
  19398. /**
  19399. * Update the predefined distance.
  19400. * @param maxDistance The maximum preferred distance
  19401. * @param minDistance The minimum preferred distance
  19402. */
  19403. updateDistance(maxDistance: number, minDistance?: number): void;
  19404. }
  19405. /**
  19406. * Represents a Motor-Enabled Joint
  19407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19408. */
  19409. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19410. /**
  19411. * Initializes the Motor-Enabled Joint
  19412. * @param type The type of the joint
  19413. * @param jointData The physica joint data for the joint
  19414. */
  19415. constructor(type: number, jointData: PhysicsJointData);
  19416. /**
  19417. * Set the motor values.
  19418. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19419. * @param force the force to apply
  19420. * @param maxForce max force for this motor.
  19421. */
  19422. setMotor(force?: number, maxForce?: number): void;
  19423. /**
  19424. * Set the motor's limits.
  19425. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19426. * @param upperLimit The upper limit of the motor
  19427. * @param lowerLimit The lower limit of the motor
  19428. */
  19429. setLimit(upperLimit: number, lowerLimit?: number): void;
  19430. }
  19431. /**
  19432. * This class represents a single physics Hinge-Joint
  19433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19434. */
  19435. export class HingeJoint extends MotorEnabledJoint {
  19436. /**
  19437. * Initializes the Hinge-Joint
  19438. * @param jointData The joint data for the Hinge-Joint
  19439. */
  19440. constructor(jointData: PhysicsJointData);
  19441. /**
  19442. * Set the motor values.
  19443. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19444. * @param {number} force the force to apply
  19445. * @param {number} maxForce max force for this motor.
  19446. */
  19447. setMotor(force?: number, maxForce?: number): void;
  19448. /**
  19449. * Set the motor's limits.
  19450. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19451. * @param upperLimit The upper limit of the motor
  19452. * @param lowerLimit The lower limit of the motor
  19453. */
  19454. setLimit(upperLimit: number, lowerLimit?: number): void;
  19455. }
  19456. /**
  19457. * This class represents a dual hinge physics joint (same as wheel joint)
  19458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19459. */
  19460. export class Hinge2Joint extends MotorEnabledJoint {
  19461. /**
  19462. * Initializes the Hinge2-Joint
  19463. * @param jointData The joint data for the Hinge2-Joint
  19464. */
  19465. constructor(jointData: PhysicsJointData);
  19466. /**
  19467. * Set the motor values.
  19468. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19469. * @param {number} targetSpeed the speed the motor is to reach
  19470. * @param {number} maxForce max force for this motor.
  19471. * @param {motorIndex} the motor's index, 0 or 1.
  19472. */
  19473. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19474. /**
  19475. * Set the motor limits.
  19476. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19477. * @param {number} upperLimit the upper limit
  19478. * @param {number} lowerLimit lower limit
  19479. * @param {motorIndex} the motor's index, 0 or 1.
  19480. */
  19481. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19482. }
  19483. /**
  19484. * Interface for a motor enabled joint
  19485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19486. */
  19487. export interface IMotorEnabledJoint {
  19488. /**
  19489. * Physics joint
  19490. */
  19491. physicsJoint: any;
  19492. /**
  19493. * Sets the motor of the motor-enabled joint
  19494. * @param force The force of the motor
  19495. * @param maxForce The maximum force of the motor
  19496. * @param motorIndex The index of the motor
  19497. */
  19498. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19499. /**
  19500. * Sets the limit of the motor
  19501. * @param upperLimit The upper limit of the motor
  19502. * @param lowerLimit The lower limit of the motor
  19503. * @param motorIndex The index of the motor
  19504. */
  19505. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19506. }
  19507. /**
  19508. * Joint data for a Distance-Joint
  19509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19510. */
  19511. export interface DistanceJointData extends PhysicsJointData {
  19512. /**
  19513. * Max distance the 2 joint objects can be apart
  19514. */
  19515. maxDistance: number;
  19516. }
  19517. /**
  19518. * Joint data from a spring joint
  19519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19520. */
  19521. export interface SpringJointData extends PhysicsJointData {
  19522. /**
  19523. * Length of the spring
  19524. */
  19525. length: number;
  19526. /**
  19527. * Stiffness of the spring
  19528. */
  19529. stiffness: number;
  19530. /**
  19531. * Damping of the spring
  19532. */
  19533. damping: number;
  19534. /** this callback will be called when applying the force to the impostors. */
  19535. forceApplicationCallback: () => void;
  19536. }
  19537. }
  19538. declare module BABYLON {
  19539. /**
  19540. * Holds the data for the raycast result
  19541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19542. */
  19543. export class PhysicsRaycastResult {
  19544. private _hasHit;
  19545. private _hitDistance;
  19546. private _hitNormalWorld;
  19547. private _hitPointWorld;
  19548. private _rayFromWorld;
  19549. private _rayToWorld;
  19550. /**
  19551. * Gets if there was a hit
  19552. */
  19553. readonly hasHit: boolean;
  19554. /**
  19555. * Gets the distance from the hit
  19556. */
  19557. readonly hitDistance: number;
  19558. /**
  19559. * Gets the hit normal/direction in the world
  19560. */
  19561. readonly hitNormalWorld: Vector3;
  19562. /**
  19563. * Gets the hit point in the world
  19564. */
  19565. readonly hitPointWorld: Vector3;
  19566. /**
  19567. * Gets the ray "start point" of the ray in the world
  19568. */
  19569. readonly rayFromWorld: Vector3;
  19570. /**
  19571. * Gets the ray "end point" of the ray in the world
  19572. */
  19573. readonly rayToWorld: Vector3;
  19574. /**
  19575. * Sets the hit data (normal & point in world space)
  19576. * @param hitNormalWorld defines the normal in world space
  19577. * @param hitPointWorld defines the point in world space
  19578. */
  19579. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19580. /**
  19581. * Sets the distance from the start point to the hit point
  19582. * @param distance
  19583. */
  19584. setHitDistance(distance: number): void;
  19585. /**
  19586. * Calculates the distance manually
  19587. */
  19588. calculateHitDistance(): void;
  19589. /**
  19590. * Resets all the values to default
  19591. * @param from The from point on world space
  19592. * @param to The to point on world space
  19593. */
  19594. reset(from?: Vector3, to?: Vector3): void;
  19595. }
  19596. /**
  19597. * Interface for the size containing width and height
  19598. */
  19599. interface IXYZ {
  19600. /**
  19601. * X
  19602. */
  19603. x: number;
  19604. /**
  19605. * Y
  19606. */
  19607. y: number;
  19608. /**
  19609. * Z
  19610. */
  19611. z: number;
  19612. }
  19613. }
  19614. declare module BABYLON {
  19615. /**
  19616. * Interface used to describe a physics joint
  19617. */
  19618. export interface PhysicsImpostorJoint {
  19619. /** Defines the main impostor to which the joint is linked */
  19620. mainImpostor: PhysicsImpostor;
  19621. /** Defines the impostor that is connected to the main impostor using this joint */
  19622. connectedImpostor: PhysicsImpostor;
  19623. /** Defines the joint itself */
  19624. joint: PhysicsJoint;
  19625. }
  19626. /** @hidden */
  19627. export interface IPhysicsEnginePlugin {
  19628. world: any;
  19629. name: string;
  19630. setGravity(gravity: Vector3): void;
  19631. setTimeStep(timeStep: number): void;
  19632. getTimeStep(): number;
  19633. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19634. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19635. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19636. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19637. removePhysicsBody(impostor: PhysicsImpostor): void;
  19638. generateJoint(joint: PhysicsImpostorJoint): void;
  19639. removeJoint(joint: PhysicsImpostorJoint): void;
  19640. isSupported(): boolean;
  19641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19644. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19645. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19647. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19648. getBodyMass(impostor: PhysicsImpostor): number;
  19649. getBodyFriction(impostor: PhysicsImpostor): number;
  19650. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19651. getBodyRestitution(impostor: PhysicsImpostor): number;
  19652. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19653. getBodyPressure?(impostor: PhysicsImpostor): number;
  19654. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19655. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19656. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19657. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19658. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19659. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19660. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19661. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19662. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19663. sleepBody(impostor: PhysicsImpostor): void;
  19664. wakeUpBody(impostor: PhysicsImpostor): void;
  19665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19666. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19667. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19668. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19669. getRadius(impostor: PhysicsImpostor): number;
  19670. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19671. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19672. dispose(): void;
  19673. }
  19674. /**
  19675. * Interface used to define a physics engine
  19676. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19677. */
  19678. export interface IPhysicsEngine {
  19679. /**
  19680. * Gets the gravity vector used by the simulation
  19681. */
  19682. gravity: Vector3;
  19683. /**
  19684. * Sets the gravity vector used by the simulation
  19685. * @param gravity defines the gravity vector to use
  19686. */
  19687. setGravity(gravity: Vector3): void;
  19688. /**
  19689. * Set the time step of the physics engine.
  19690. * Default is 1/60.
  19691. * To slow it down, enter 1/600 for example.
  19692. * To speed it up, 1/30
  19693. * @param newTimeStep the new timestep to apply to this world.
  19694. */
  19695. setTimeStep(newTimeStep: number): void;
  19696. /**
  19697. * Get the time step of the physics engine.
  19698. * @returns the current time step
  19699. */
  19700. getTimeStep(): number;
  19701. /**
  19702. * Release all resources
  19703. */
  19704. dispose(): void;
  19705. /**
  19706. * Gets the name of the current physics plugin
  19707. * @returns the name of the plugin
  19708. */
  19709. getPhysicsPluginName(): string;
  19710. /**
  19711. * Adding a new impostor for the impostor tracking.
  19712. * This will be done by the impostor itself.
  19713. * @param impostor the impostor to add
  19714. */
  19715. addImpostor(impostor: PhysicsImpostor): void;
  19716. /**
  19717. * Remove an impostor from the engine.
  19718. * This impostor and its mesh will not longer be updated by the physics engine.
  19719. * @param impostor the impostor to remove
  19720. */
  19721. removeImpostor(impostor: PhysicsImpostor): void;
  19722. /**
  19723. * Add a joint to the physics engine
  19724. * @param mainImpostor defines the main impostor to which the joint is added.
  19725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19726. * @param joint defines the joint that will connect both impostors.
  19727. */
  19728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19729. /**
  19730. * Removes a joint from the simulation
  19731. * @param mainImpostor defines the impostor used with the joint
  19732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19733. * @param joint defines the joint to remove
  19734. */
  19735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19736. /**
  19737. * Gets the current plugin used to run the simulation
  19738. * @returns current plugin
  19739. */
  19740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19741. /**
  19742. * Gets the list of physic impostors
  19743. * @returns an array of PhysicsImpostor
  19744. */
  19745. getImpostors(): Array<PhysicsImpostor>;
  19746. /**
  19747. * Gets the impostor for a physics enabled object
  19748. * @param object defines the object impersonated by the impostor
  19749. * @returns the PhysicsImpostor or null if not found
  19750. */
  19751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19752. /**
  19753. * Gets the impostor for a physics body object
  19754. * @param body defines physics body used by the impostor
  19755. * @returns the PhysicsImpostor or null if not found
  19756. */
  19757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19758. /**
  19759. * Does a raycast in the physics world
  19760. * @param from when should the ray start?
  19761. * @param to when should the ray end?
  19762. * @returns PhysicsRaycastResult
  19763. */
  19764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19765. /**
  19766. * Called by the scene. No need to call it.
  19767. * @param delta defines the timespam between frames
  19768. */
  19769. _step(delta: number): void;
  19770. }
  19771. }
  19772. declare module BABYLON {
  19773. /**
  19774. * The interface for the physics imposter parameters
  19775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19776. */
  19777. export interface PhysicsImpostorParameters {
  19778. /**
  19779. * The mass of the physics imposter
  19780. */
  19781. mass: number;
  19782. /**
  19783. * The friction of the physics imposter
  19784. */
  19785. friction?: number;
  19786. /**
  19787. * The coefficient of restitution of the physics imposter
  19788. */
  19789. restitution?: number;
  19790. /**
  19791. * The native options of the physics imposter
  19792. */
  19793. nativeOptions?: any;
  19794. /**
  19795. * Specifies if the parent should be ignored
  19796. */
  19797. ignoreParent?: boolean;
  19798. /**
  19799. * Specifies if bi-directional transformations should be disabled
  19800. */
  19801. disableBidirectionalTransformation?: boolean;
  19802. /**
  19803. * The pressure inside the physics imposter, soft object only
  19804. */
  19805. pressure?: number;
  19806. /**
  19807. * The stiffness the physics imposter, soft object only
  19808. */
  19809. stiffness?: number;
  19810. /**
  19811. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19812. */
  19813. velocityIterations?: number;
  19814. /**
  19815. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19816. */
  19817. positionIterations?: number;
  19818. /**
  19819. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19820. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19821. * Add to fix multiple points
  19822. */
  19823. fixedPoints?: number;
  19824. /**
  19825. * The collision margin around a soft object
  19826. */
  19827. margin?: number;
  19828. /**
  19829. * The collision margin around a soft object
  19830. */
  19831. damping?: number;
  19832. /**
  19833. * The path for a rope based on an extrusion
  19834. */
  19835. path?: any;
  19836. /**
  19837. * The shape of an extrusion used for a rope based on an extrusion
  19838. */
  19839. shape?: any;
  19840. }
  19841. /**
  19842. * Interface for a physics-enabled object
  19843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19844. */
  19845. export interface IPhysicsEnabledObject {
  19846. /**
  19847. * The position of the physics-enabled object
  19848. */
  19849. position: Vector3;
  19850. /**
  19851. * The rotation of the physics-enabled object
  19852. */
  19853. rotationQuaternion: Nullable<Quaternion>;
  19854. /**
  19855. * The scale of the physics-enabled object
  19856. */
  19857. scaling: Vector3;
  19858. /**
  19859. * The rotation of the physics-enabled object
  19860. */
  19861. rotation?: Vector3;
  19862. /**
  19863. * The parent of the physics-enabled object
  19864. */
  19865. parent?: any;
  19866. /**
  19867. * The bounding info of the physics-enabled object
  19868. * @returns The bounding info of the physics-enabled object
  19869. */
  19870. getBoundingInfo(): BoundingInfo;
  19871. /**
  19872. * Computes the world matrix
  19873. * @param force Specifies if the world matrix should be computed by force
  19874. * @returns A world matrix
  19875. */
  19876. computeWorldMatrix(force: boolean): Matrix;
  19877. /**
  19878. * Gets the world matrix
  19879. * @returns A world matrix
  19880. */
  19881. getWorldMatrix?(): Matrix;
  19882. /**
  19883. * Gets the child meshes
  19884. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19885. * @returns An array of abstract meshes
  19886. */
  19887. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19888. /**
  19889. * Gets the vertex data
  19890. * @param kind The type of vertex data
  19891. * @returns A nullable array of numbers, or a float32 array
  19892. */
  19893. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19894. /**
  19895. * Gets the indices from the mesh
  19896. * @returns A nullable array of index arrays
  19897. */
  19898. getIndices?(): Nullable<IndicesArray>;
  19899. /**
  19900. * Gets the scene from the mesh
  19901. * @returns the indices array or null
  19902. */
  19903. getScene?(): Scene;
  19904. /**
  19905. * Gets the absolute position from the mesh
  19906. * @returns the absolute position
  19907. */
  19908. getAbsolutePosition(): Vector3;
  19909. /**
  19910. * Gets the absolute pivot point from the mesh
  19911. * @returns the absolute pivot point
  19912. */
  19913. getAbsolutePivotPoint(): Vector3;
  19914. /**
  19915. * Rotates the mesh
  19916. * @param axis The axis of rotation
  19917. * @param amount The amount of rotation
  19918. * @param space The space of the rotation
  19919. * @returns The rotation transform node
  19920. */
  19921. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19922. /**
  19923. * Translates the mesh
  19924. * @param axis The axis of translation
  19925. * @param distance The distance of translation
  19926. * @param space The space of the translation
  19927. * @returns The transform node
  19928. */
  19929. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19930. /**
  19931. * Sets the absolute position of the mesh
  19932. * @param absolutePosition The absolute position of the mesh
  19933. * @returns The transform node
  19934. */
  19935. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19936. /**
  19937. * Gets the class name of the mesh
  19938. * @returns The class name
  19939. */
  19940. getClassName(): string;
  19941. }
  19942. /**
  19943. * Represents a physics imposter
  19944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19945. */
  19946. export class PhysicsImpostor {
  19947. /**
  19948. * The physics-enabled object used as the physics imposter
  19949. */
  19950. object: IPhysicsEnabledObject;
  19951. /**
  19952. * The type of the physics imposter
  19953. */
  19954. type: number;
  19955. private _options;
  19956. private _scene?;
  19957. /**
  19958. * The default object size of the imposter
  19959. */
  19960. static DEFAULT_OBJECT_SIZE: Vector3;
  19961. /**
  19962. * The identity quaternion of the imposter
  19963. */
  19964. static IDENTITY_QUATERNION: Quaternion;
  19965. /** @hidden */
  19966. _pluginData: any;
  19967. private _physicsEngine;
  19968. private _physicsBody;
  19969. private _bodyUpdateRequired;
  19970. private _onBeforePhysicsStepCallbacks;
  19971. private _onAfterPhysicsStepCallbacks;
  19972. /** @hidden */
  19973. _onPhysicsCollideCallbacks: Array<{
  19974. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19975. otherImpostors: Array<PhysicsImpostor>;
  19976. }>;
  19977. private _deltaPosition;
  19978. private _deltaRotation;
  19979. private _deltaRotationConjugated;
  19980. /** hidden */
  19981. _isFromLine: boolean;
  19982. private _parent;
  19983. private _isDisposed;
  19984. private static _tmpVecs;
  19985. private static _tmpQuat;
  19986. /**
  19987. * Specifies if the physics imposter is disposed
  19988. */
  19989. readonly isDisposed: boolean;
  19990. /**
  19991. * Gets the mass of the physics imposter
  19992. */
  19993. mass: number;
  19994. /**
  19995. * Gets the coefficient of friction
  19996. */
  19997. /**
  19998. * Sets the coefficient of friction
  19999. */
  20000. friction: number;
  20001. /**
  20002. * Gets the coefficient of restitution
  20003. */
  20004. /**
  20005. * Sets the coefficient of restitution
  20006. */
  20007. restitution: number;
  20008. /**
  20009. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20010. */
  20011. /**
  20012. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20013. */
  20014. pressure: number;
  20015. /**
  20016. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20017. */
  20018. /**
  20019. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20020. */
  20021. stiffness: number;
  20022. /**
  20023. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20024. */
  20025. /**
  20026. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20027. */
  20028. velocityIterations: number;
  20029. /**
  20030. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20031. */
  20032. /**
  20033. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20034. */
  20035. positionIterations: number;
  20036. /**
  20037. * The unique id of the physics imposter
  20038. * set by the physics engine when adding this impostor to the array
  20039. */
  20040. uniqueId: number;
  20041. /**
  20042. * @hidden
  20043. */
  20044. soft: boolean;
  20045. /**
  20046. * @hidden
  20047. */
  20048. segments: number;
  20049. private _joints;
  20050. /**
  20051. * Initializes the physics imposter
  20052. * @param object The physics-enabled object used as the physics imposter
  20053. * @param type The type of the physics imposter
  20054. * @param _options The options for the physics imposter
  20055. * @param _scene The Babylon scene
  20056. */
  20057. constructor(
  20058. /**
  20059. * The physics-enabled object used as the physics imposter
  20060. */
  20061. object: IPhysicsEnabledObject,
  20062. /**
  20063. * The type of the physics imposter
  20064. */
  20065. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20066. /**
  20067. * This function will completly initialize this impostor.
  20068. * It will create a new body - but only if this mesh has no parent.
  20069. * If it has, this impostor will not be used other than to define the impostor
  20070. * of the child mesh.
  20071. * @hidden
  20072. */
  20073. _init(): void;
  20074. private _getPhysicsParent;
  20075. /**
  20076. * Should a new body be generated.
  20077. * @returns boolean specifying if body initialization is required
  20078. */
  20079. isBodyInitRequired(): boolean;
  20080. /**
  20081. * Sets the updated scaling
  20082. * @param updated Specifies if the scaling is updated
  20083. */
  20084. setScalingUpdated(): void;
  20085. /**
  20086. * Force a regeneration of this or the parent's impostor's body.
  20087. * Use under cautious - This will remove all joints already implemented.
  20088. */
  20089. forceUpdate(): void;
  20090. /**
  20091. * Gets the body that holds this impostor. Either its own, or its parent.
  20092. */
  20093. /**
  20094. * Set the physics body. Used mainly by the physics engine/plugin
  20095. */
  20096. physicsBody: any;
  20097. /**
  20098. * Get the parent of the physics imposter
  20099. * @returns Physics imposter or null
  20100. */
  20101. /**
  20102. * Sets the parent of the physics imposter
  20103. */
  20104. parent: Nullable<PhysicsImpostor>;
  20105. /**
  20106. * Resets the update flags
  20107. */
  20108. resetUpdateFlags(): void;
  20109. /**
  20110. * Gets the object extend size
  20111. * @returns the object extend size
  20112. */
  20113. getObjectExtendSize(): Vector3;
  20114. /**
  20115. * Gets the object center
  20116. * @returns The object center
  20117. */
  20118. getObjectCenter(): Vector3;
  20119. /**
  20120. * Get a specific parametes from the options parameter
  20121. * @param paramName The object parameter name
  20122. * @returns The object parameter
  20123. */
  20124. getParam(paramName: string): any;
  20125. /**
  20126. * Sets a specific parameter in the options given to the physics plugin
  20127. * @param paramName The parameter name
  20128. * @param value The value of the parameter
  20129. */
  20130. setParam(paramName: string, value: number): void;
  20131. /**
  20132. * Specifically change the body's mass option. Won't recreate the physics body object
  20133. * @param mass The mass of the physics imposter
  20134. */
  20135. setMass(mass: number): void;
  20136. /**
  20137. * Gets the linear velocity
  20138. * @returns linear velocity or null
  20139. */
  20140. getLinearVelocity(): Nullable<Vector3>;
  20141. /**
  20142. * Sets the linear velocity
  20143. * @param velocity linear velocity or null
  20144. */
  20145. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20146. /**
  20147. * Gets the angular velocity
  20148. * @returns angular velocity or null
  20149. */
  20150. getAngularVelocity(): Nullable<Vector3>;
  20151. /**
  20152. * Sets the angular velocity
  20153. * @param velocity The velocity or null
  20154. */
  20155. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20156. /**
  20157. * Execute a function with the physics plugin native code
  20158. * Provide a function the will have two variables - the world object and the physics body object
  20159. * @param func The function to execute with the physics plugin native code
  20160. */
  20161. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20162. /**
  20163. * Register a function that will be executed before the physics world is stepping forward
  20164. * @param func The function to execute before the physics world is stepped forward
  20165. */
  20166. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20167. /**
  20168. * Unregister a function that will be executed before the physics world is stepping forward
  20169. * @param func The function to execute before the physics world is stepped forward
  20170. */
  20171. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20172. /**
  20173. * Register a function that will be executed after the physics step
  20174. * @param func The function to execute after physics step
  20175. */
  20176. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20177. /**
  20178. * Unregisters a function that will be executed after the physics step
  20179. * @param func The function to execute after physics step
  20180. */
  20181. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20182. /**
  20183. * register a function that will be executed when this impostor collides against a different body
  20184. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20185. * @param func Callback that is executed on collision
  20186. */
  20187. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20188. /**
  20189. * Unregisters the physics imposter on contact
  20190. * @param collideAgainst The physics object to collide against
  20191. * @param func Callback to execute on collision
  20192. */
  20193. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20194. private _tmpQuat;
  20195. private _tmpQuat2;
  20196. /**
  20197. * Get the parent rotation
  20198. * @returns The parent rotation
  20199. */
  20200. getParentsRotation(): Quaternion;
  20201. /**
  20202. * this function is executed by the physics engine.
  20203. */
  20204. beforeStep: () => void;
  20205. /**
  20206. * this function is executed by the physics engine
  20207. */
  20208. afterStep: () => void;
  20209. /**
  20210. * Legacy collision detection event support
  20211. */
  20212. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20213. /**
  20214. * event and body object due to cannon's event-based architecture.
  20215. */
  20216. onCollide: (e: {
  20217. body: any;
  20218. }) => void;
  20219. /**
  20220. * Apply a force
  20221. * @param force The force to apply
  20222. * @param contactPoint The contact point for the force
  20223. * @returns The physics imposter
  20224. */
  20225. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20226. /**
  20227. * Apply an impulse
  20228. * @param force The impulse force
  20229. * @param contactPoint The contact point for the impulse force
  20230. * @returns The physics imposter
  20231. */
  20232. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20233. /**
  20234. * A help function to create a joint
  20235. * @param otherImpostor A physics imposter used to create a joint
  20236. * @param jointType The type of joint
  20237. * @param jointData The data for the joint
  20238. * @returns The physics imposter
  20239. */
  20240. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20241. /**
  20242. * Add a joint to this impostor with a different impostor
  20243. * @param otherImpostor A physics imposter used to add a joint
  20244. * @param joint The joint to add
  20245. * @returns The physics imposter
  20246. */
  20247. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20248. /**
  20249. * Add an anchor to a cloth impostor
  20250. * @param otherImpostor rigid impostor to anchor to
  20251. * @param width ratio across width from 0 to 1
  20252. * @param height ratio up height from 0 to 1
  20253. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20254. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20255. * @returns impostor the soft imposter
  20256. */
  20257. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20258. /**
  20259. * Add a hook to a rope impostor
  20260. * @param otherImpostor rigid impostor to anchor to
  20261. * @param length ratio across rope from 0 to 1
  20262. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20263. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20264. * @returns impostor the rope imposter
  20265. */
  20266. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20267. /**
  20268. * Will keep this body still, in a sleep mode.
  20269. * @returns the physics imposter
  20270. */
  20271. sleep(): PhysicsImpostor;
  20272. /**
  20273. * Wake the body up.
  20274. * @returns The physics imposter
  20275. */
  20276. wakeUp(): PhysicsImpostor;
  20277. /**
  20278. * Clones the physics imposter
  20279. * @param newObject The physics imposter clones to this physics-enabled object
  20280. * @returns A nullable physics imposter
  20281. */
  20282. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20283. /**
  20284. * Disposes the physics imposter
  20285. */
  20286. dispose(): void;
  20287. /**
  20288. * Sets the delta position
  20289. * @param position The delta position amount
  20290. */
  20291. setDeltaPosition(position: Vector3): void;
  20292. /**
  20293. * Sets the delta rotation
  20294. * @param rotation The delta rotation amount
  20295. */
  20296. setDeltaRotation(rotation: Quaternion): void;
  20297. /**
  20298. * Gets the box size of the physics imposter and stores the result in the input parameter
  20299. * @param result Stores the box size
  20300. * @returns The physics imposter
  20301. */
  20302. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20303. /**
  20304. * Gets the radius of the physics imposter
  20305. * @returns Radius of the physics imposter
  20306. */
  20307. getRadius(): number;
  20308. /**
  20309. * Sync a bone with this impostor
  20310. * @param bone The bone to sync to the impostor.
  20311. * @param boneMesh The mesh that the bone is influencing.
  20312. * @param jointPivot The pivot of the joint / bone in local space.
  20313. * @param distToJoint Optional distance from the impostor to the joint.
  20314. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20315. */
  20316. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20317. /**
  20318. * Sync impostor to a bone
  20319. * @param bone The bone that the impostor will be synced to.
  20320. * @param boneMesh The mesh that the bone is influencing.
  20321. * @param jointPivot The pivot of the joint / bone in local space.
  20322. * @param distToJoint Optional distance from the impostor to the joint.
  20323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20324. * @param boneAxis Optional vector3 axis the bone is aligned with
  20325. */
  20326. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20327. /**
  20328. * No-Imposter type
  20329. */
  20330. static NoImpostor: number;
  20331. /**
  20332. * Sphere-Imposter type
  20333. */
  20334. static SphereImpostor: number;
  20335. /**
  20336. * Box-Imposter type
  20337. */
  20338. static BoxImpostor: number;
  20339. /**
  20340. * Plane-Imposter type
  20341. */
  20342. static PlaneImpostor: number;
  20343. /**
  20344. * Mesh-imposter type
  20345. */
  20346. static MeshImpostor: number;
  20347. /**
  20348. * Cylinder-Imposter type
  20349. */
  20350. static CylinderImpostor: number;
  20351. /**
  20352. * Particle-Imposter type
  20353. */
  20354. static ParticleImpostor: number;
  20355. /**
  20356. * Heightmap-Imposter type
  20357. */
  20358. static HeightmapImpostor: number;
  20359. /**
  20360. * ConvexHull-Impostor type (Ammo.js plugin only)
  20361. */
  20362. static ConvexHullImpostor: number;
  20363. /**
  20364. * Rope-Imposter type
  20365. */
  20366. static RopeImpostor: number;
  20367. /**
  20368. * Cloth-Imposter type
  20369. */
  20370. static ClothImpostor: number;
  20371. /**
  20372. * Softbody-Imposter type
  20373. */
  20374. static SoftbodyImpostor: number;
  20375. }
  20376. }
  20377. declare module BABYLON {
  20378. /**
  20379. * Class used to represent a specific level of detail of a mesh
  20380. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20381. */
  20382. export class MeshLODLevel {
  20383. /** Defines the distance where this level should star being displayed */
  20384. distance: number;
  20385. /** Defines the mesh to use to render this level */
  20386. mesh: Nullable<Mesh>;
  20387. /**
  20388. * Creates a new LOD level
  20389. * @param distance defines the distance where this level should star being displayed
  20390. * @param mesh defines the mesh to use to render this level
  20391. */
  20392. constructor(
  20393. /** Defines the distance where this level should star being displayed */
  20394. distance: number,
  20395. /** Defines the mesh to use to render this level */
  20396. mesh: Nullable<Mesh>);
  20397. }
  20398. /**
  20399. * @hidden
  20400. **/
  20401. export class _CreationDataStorage {
  20402. closePath?: boolean;
  20403. closeArray?: boolean;
  20404. idx: number[];
  20405. dashSize: number;
  20406. gapSize: number;
  20407. path3D: Path3D;
  20408. pathArray: Vector3[][];
  20409. arc: number;
  20410. radius: number;
  20411. cap: number;
  20412. tessellation: number;
  20413. }
  20414. /**
  20415. * @hidden
  20416. **/
  20417. class _InstanceDataStorage {
  20418. visibleInstances: any;
  20419. batchCache: _InstancesBatch;
  20420. instancesBufferSize: number;
  20421. instancesBuffer: Nullable<Buffer>;
  20422. instancesData: Float32Array;
  20423. overridenInstanceCount: number;
  20424. isFrozen: boolean;
  20425. previousBatch: _InstancesBatch;
  20426. hardwareInstancedRendering: boolean;
  20427. sideOrientation: number;
  20428. }
  20429. /**
  20430. * @hidden
  20431. **/
  20432. export class _InstancesBatch {
  20433. mustReturn: boolean;
  20434. visibleInstances: Nullable<InstancedMesh[]>[];
  20435. renderSelf: boolean[];
  20436. hardwareInstancedRendering: boolean[];
  20437. }
  20438. /**
  20439. * Class used to represent renderable models
  20440. */
  20441. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20442. /**
  20443. * Mesh side orientation : usually the external or front surface
  20444. */
  20445. static readonly FRONTSIDE: number;
  20446. /**
  20447. * Mesh side orientation : usually the internal or back surface
  20448. */
  20449. static readonly BACKSIDE: number;
  20450. /**
  20451. * Mesh side orientation : both internal and external or front and back surfaces
  20452. */
  20453. static readonly DOUBLESIDE: number;
  20454. /**
  20455. * Mesh side orientation : by default, `FRONTSIDE`
  20456. */
  20457. static readonly DEFAULTSIDE: number;
  20458. /**
  20459. * Mesh cap setting : no cap
  20460. */
  20461. static readonly NO_CAP: number;
  20462. /**
  20463. * Mesh cap setting : one cap at the beginning of the mesh
  20464. */
  20465. static readonly CAP_START: number;
  20466. /**
  20467. * Mesh cap setting : one cap at the end of the mesh
  20468. */
  20469. static readonly CAP_END: number;
  20470. /**
  20471. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20472. */
  20473. static readonly CAP_ALL: number;
  20474. /**
  20475. * Gets the default side orientation.
  20476. * @param orientation the orientation to value to attempt to get
  20477. * @returns the default orientation
  20478. * @hidden
  20479. */
  20480. static _GetDefaultSideOrientation(orientation?: number): number;
  20481. private _onBeforeRenderObservable;
  20482. private _onBeforeBindObservable;
  20483. private _onAfterRenderObservable;
  20484. private _onBeforeDrawObservable;
  20485. /**
  20486. * An event triggered before rendering the mesh
  20487. */
  20488. readonly onBeforeRenderObservable: Observable<Mesh>;
  20489. /**
  20490. * An event triggered before binding the mesh
  20491. */
  20492. readonly onBeforeBindObservable: Observable<Mesh>;
  20493. /**
  20494. * An event triggered after rendering the mesh
  20495. */
  20496. readonly onAfterRenderObservable: Observable<Mesh>;
  20497. /**
  20498. * An event triggered before drawing the mesh
  20499. */
  20500. readonly onBeforeDrawObservable: Observable<Mesh>;
  20501. private _onBeforeDrawObserver;
  20502. /**
  20503. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20504. */
  20505. onBeforeDraw: () => void;
  20506. /**
  20507. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20508. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20509. */
  20510. delayLoadState: number;
  20511. /**
  20512. * Gets the list of instances created from this mesh
  20513. * it is not supposed to be modified manually.
  20514. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20515. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20516. */
  20517. instances: InstancedMesh[];
  20518. /**
  20519. * Gets the file containing delay loading data for this mesh
  20520. */
  20521. delayLoadingFile: string;
  20522. /** @hidden */
  20523. _binaryInfo: any;
  20524. private _LODLevels;
  20525. /**
  20526. * User defined function used to change how LOD level selection is done
  20527. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20528. */
  20529. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20530. private _morphTargetManager;
  20531. /**
  20532. * Gets or sets the morph target manager
  20533. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20534. */
  20535. morphTargetManager: Nullable<MorphTargetManager>;
  20536. /** @hidden */
  20537. _creationDataStorage: Nullable<_CreationDataStorage>;
  20538. /** @hidden */
  20539. _geometry: Nullable<Geometry>;
  20540. /** @hidden */
  20541. _delayInfo: Array<string>;
  20542. /** @hidden */
  20543. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20544. /** @hidden */
  20545. _instanceDataStorage: _InstanceDataStorage;
  20546. private _effectiveMaterial;
  20547. /** @hidden */
  20548. _shouldGenerateFlatShading: boolean;
  20549. private _preActivateId;
  20550. /** @hidden */
  20551. _originalBuilderSideOrientation: number;
  20552. /**
  20553. * Use this property to change the original side orientation defined at construction time
  20554. */
  20555. overrideMaterialSideOrientation: Nullable<number>;
  20556. private _areNormalsFrozen;
  20557. private _sourcePositions;
  20558. private _sourceNormals;
  20559. private _source;
  20560. private meshMap;
  20561. /**
  20562. * Gets the source mesh (the one used to clone this one from)
  20563. */
  20564. readonly source: Nullable<Mesh>;
  20565. /**
  20566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20567. */
  20568. isUnIndexed: boolean;
  20569. /**
  20570. * @constructor
  20571. * @param name The value used by scene.getMeshByName() to do a lookup.
  20572. * @param scene The scene to add this mesh to.
  20573. * @param parent The parent of this mesh, if it has one
  20574. * @param source An optional Mesh from which geometry is shared, cloned.
  20575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20576. * When false, achieved by calling a clone(), also passing False.
  20577. * This will make creation of children, recursive.
  20578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20579. */
  20580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20581. /**
  20582. * Gets the class name
  20583. * @returns the string "Mesh".
  20584. */
  20585. getClassName(): string;
  20586. /** @hidden */
  20587. readonly _isMesh: boolean;
  20588. /**
  20589. * Returns a description of this mesh
  20590. * @param fullDetails define if full details about this mesh must be used
  20591. * @returns a descriptive string representing this mesh
  20592. */
  20593. toString(fullDetails?: boolean): string;
  20594. /** @hidden */
  20595. _unBindEffect(): void;
  20596. /**
  20597. * Gets a boolean indicating if this mesh has LOD
  20598. */
  20599. readonly hasLODLevels: boolean;
  20600. /**
  20601. * Gets the list of MeshLODLevel associated with the current mesh
  20602. * @returns an array of MeshLODLevel
  20603. */
  20604. getLODLevels(): MeshLODLevel[];
  20605. private _sortLODLevels;
  20606. /**
  20607. * Add a mesh as LOD level triggered at the given distance.
  20608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20609. * @param distance The distance from the center of the object to show this level
  20610. * @param mesh The mesh to be added as LOD level (can be null)
  20611. * @return This mesh (for chaining)
  20612. */
  20613. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20614. /**
  20615. * Returns the LOD level mesh at the passed distance or null if not found.
  20616. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20617. * @param distance The distance from the center of the object to show this level
  20618. * @returns a Mesh or `null`
  20619. */
  20620. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20621. /**
  20622. * Remove a mesh from the LOD array
  20623. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20624. * @param mesh defines the mesh to be removed
  20625. * @return This mesh (for chaining)
  20626. */
  20627. removeLODLevel(mesh: Mesh): Mesh;
  20628. /**
  20629. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20630. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20631. * @param camera defines the camera to use to compute distance
  20632. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20633. * @return This mesh (for chaining)
  20634. */
  20635. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20636. /**
  20637. * Gets the mesh internal Geometry object
  20638. */
  20639. readonly geometry: Nullable<Geometry>;
  20640. /**
  20641. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20642. * @returns the total number of vertices
  20643. */
  20644. getTotalVertices(): number;
  20645. /**
  20646. * Returns the content of an associated vertex buffer
  20647. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20648. * - VertexBuffer.PositionKind
  20649. * - VertexBuffer.UVKind
  20650. * - VertexBuffer.UV2Kind
  20651. * - VertexBuffer.UV3Kind
  20652. * - VertexBuffer.UV4Kind
  20653. * - VertexBuffer.UV5Kind
  20654. * - VertexBuffer.UV6Kind
  20655. * - VertexBuffer.ColorKind
  20656. * - VertexBuffer.MatricesIndicesKind
  20657. * - VertexBuffer.MatricesIndicesExtraKind
  20658. * - VertexBuffer.MatricesWeightsKind
  20659. * - VertexBuffer.MatricesWeightsExtraKind
  20660. * @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
  20661. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20662. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20663. */
  20664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20665. /**
  20666. * Returns the mesh VertexBuffer object from the requested `kind`
  20667. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20668. * - VertexBuffer.PositionKind
  20669. * - VertexBuffer.UVKind
  20670. * - VertexBuffer.UV2Kind
  20671. * - VertexBuffer.UV3Kind
  20672. * - VertexBuffer.UV4Kind
  20673. * - VertexBuffer.UV5Kind
  20674. * - VertexBuffer.UV6Kind
  20675. * - VertexBuffer.ColorKind
  20676. * - VertexBuffer.MatricesIndicesKind
  20677. * - VertexBuffer.MatricesIndicesExtraKind
  20678. * - VertexBuffer.MatricesWeightsKind
  20679. * - VertexBuffer.MatricesWeightsExtraKind
  20680. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20681. */
  20682. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20683. /**
  20684. * Tests if a specific vertex buffer is associated with this mesh
  20685. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20686. * - VertexBuffer.PositionKind
  20687. * - VertexBuffer.UVKind
  20688. * - VertexBuffer.UV2Kind
  20689. * - VertexBuffer.UV3Kind
  20690. * - VertexBuffer.UV4Kind
  20691. * - VertexBuffer.UV5Kind
  20692. * - VertexBuffer.UV6Kind
  20693. * - VertexBuffer.ColorKind
  20694. * - VertexBuffer.MatricesIndicesKind
  20695. * - VertexBuffer.MatricesIndicesExtraKind
  20696. * - VertexBuffer.MatricesWeightsKind
  20697. * - VertexBuffer.MatricesWeightsExtraKind
  20698. * @returns a boolean
  20699. */
  20700. isVerticesDataPresent(kind: string): boolean;
  20701. /**
  20702. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20703. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20704. * - VertexBuffer.PositionKind
  20705. * - VertexBuffer.UVKind
  20706. * - VertexBuffer.UV2Kind
  20707. * - VertexBuffer.UV3Kind
  20708. * - VertexBuffer.UV4Kind
  20709. * - VertexBuffer.UV5Kind
  20710. * - VertexBuffer.UV6Kind
  20711. * - VertexBuffer.ColorKind
  20712. * - VertexBuffer.MatricesIndicesKind
  20713. * - VertexBuffer.MatricesIndicesExtraKind
  20714. * - VertexBuffer.MatricesWeightsKind
  20715. * - VertexBuffer.MatricesWeightsExtraKind
  20716. * @returns a boolean
  20717. */
  20718. isVertexBufferUpdatable(kind: string): boolean;
  20719. /**
  20720. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.UVKind
  20724. * - VertexBuffer.UV2Kind
  20725. * - VertexBuffer.UV3Kind
  20726. * - VertexBuffer.UV4Kind
  20727. * - VertexBuffer.UV5Kind
  20728. * - VertexBuffer.UV6Kind
  20729. * - VertexBuffer.ColorKind
  20730. * - VertexBuffer.MatricesIndicesKind
  20731. * - VertexBuffer.MatricesIndicesExtraKind
  20732. * - VertexBuffer.MatricesWeightsKind
  20733. * - VertexBuffer.MatricesWeightsExtraKind
  20734. * @returns an array of strings
  20735. */
  20736. getVerticesDataKinds(): string[];
  20737. /**
  20738. * Returns a positive integer : the total number of indices in this mesh geometry.
  20739. * @returns the numner of indices or zero if the mesh has no geometry.
  20740. */
  20741. getTotalIndices(): number;
  20742. /**
  20743. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20744. * @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.
  20745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20746. * @returns the indices array or an empty array if the mesh has no geometry
  20747. */
  20748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20749. readonly isBlocked: boolean;
  20750. /**
  20751. * Determine if the current mesh is ready to be rendered
  20752. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20753. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20754. * @returns true if all associated assets are ready (material, textures, shaders)
  20755. */
  20756. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20757. /**
  20758. * 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.
  20759. */
  20760. readonly areNormalsFrozen: boolean;
  20761. /**
  20762. * 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.
  20763. * @returns the current mesh
  20764. */
  20765. freezeNormals(): Mesh;
  20766. /**
  20767. * 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
  20768. * @returns the current mesh
  20769. */
  20770. unfreezeNormals(): Mesh;
  20771. /**
  20772. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20773. */
  20774. overridenInstanceCount: number;
  20775. /** @hidden */
  20776. _preActivate(): Mesh;
  20777. /** @hidden */
  20778. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20779. /** @hidden */
  20780. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20781. /**
  20782. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20783. * This means the mesh underlying bounding box and sphere are recomputed.
  20784. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20785. * @returns the current mesh
  20786. */
  20787. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20788. /** @hidden */
  20789. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20790. /**
  20791. * This function will subdivide the mesh into multiple submeshes
  20792. * @param count defines the expected number of submeshes
  20793. */
  20794. subdivide(count: number): void;
  20795. /**
  20796. * Copy a FloatArray into a specific associated vertex buffer
  20797. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20798. * - VertexBuffer.PositionKind
  20799. * - VertexBuffer.UVKind
  20800. * - VertexBuffer.UV2Kind
  20801. * - VertexBuffer.UV3Kind
  20802. * - VertexBuffer.UV4Kind
  20803. * - VertexBuffer.UV5Kind
  20804. * - VertexBuffer.UV6Kind
  20805. * - VertexBuffer.ColorKind
  20806. * - VertexBuffer.MatricesIndicesKind
  20807. * - VertexBuffer.MatricesIndicesExtraKind
  20808. * - VertexBuffer.MatricesWeightsKind
  20809. * - VertexBuffer.MatricesWeightsExtraKind
  20810. * @param data defines the data source
  20811. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20812. * @param stride defines the data stride size (can be null)
  20813. * @returns the current mesh
  20814. */
  20815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20816. /**
  20817. * Flags an associated vertex buffer as updatable
  20818. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20819. * - VertexBuffer.PositionKind
  20820. * - VertexBuffer.UVKind
  20821. * - VertexBuffer.UV2Kind
  20822. * - VertexBuffer.UV3Kind
  20823. * - VertexBuffer.UV4Kind
  20824. * - VertexBuffer.UV5Kind
  20825. * - VertexBuffer.UV6Kind
  20826. * - VertexBuffer.ColorKind
  20827. * - VertexBuffer.MatricesIndicesKind
  20828. * - VertexBuffer.MatricesIndicesExtraKind
  20829. * - VertexBuffer.MatricesWeightsKind
  20830. * - VertexBuffer.MatricesWeightsExtraKind
  20831. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20832. */
  20833. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20834. /**
  20835. * Sets the mesh global Vertex Buffer
  20836. * @param buffer defines the buffer to use
  20837. * @returns the current mesh
  20838. */
  20839. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20840. /**
  20841. * Update a specific associated vertex buffer
  20842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20843. * - VertexBuffer.PositionKind
  20844. * - VertexBuffer.UVKind
  20845. * - VertexBuffer.UV2Kind
  20846. * - VertexBuffer.UV3Kind
  20847. * - VertexBuffer.UV4Kind
  20848. * - VertexBuffer.UV5Kind
  20849. * - VertexBuffer.UV6Kind
  20850. * - VertexBuffer.ColorKind
  20851. * - VertexBuffer.MatricesIndicesKind
  20852. * - VertexBuffer.MatricesIndicesExtraKind
  20853. * - VertexBuffer.MatricesWeightsKind
  20854. * - VertexBuffer.MatricesWeightsExtraKind
  20855. * @param data defines the data source
  20856. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20857. * @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)
  20858. * @returns the current mesh
  20859. */
  20860. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20861. /**
  20862. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20863. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20864. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20865. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20866. * @returns the current mesh
  20867. */
  20868. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20869. /**
  20870. * Creates a un-shared specific occurence of the geometry for the mesh.
  20871. * @returns the current mesh
  20872. */
  20873. makeGeometryUnique(): Mesh;
  20874. /**
  20875. * Set the index buffer of this mesh
  20876. * @param indices defines the source data
  20877. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20878. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20879. * @returns the current mesh
  20880. */
  20881. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20882. /**
  20883. * Update the current index buffer
  20884. * @param indices defines the source data
  20885. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20886. * @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)
  20887. * @returns the current mesh
  20888. */
  20889. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20890. /**
  20891. * Invert the geometry to move from a right handed system to a left handed one.
  20892. * @returns the current mesh
  20893. */
  20894. toLeftHanded(): Mesh;
  20895. /** @hidden */
  20896. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20897. /** @hidden */
  20898. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20899. /**
  20900. * Registers for this mesh a javascript function called just before the rendering process
  20901. * @param func defines the function to call before rendering this mesh
  20902. * @returns the current mesh
  20903. */
  20904. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20905. /**
  20906. * Disposes a previously registered javascript function called before the rendering
  20907. * @param func defines the function to remove
  20908. * @returns the current mesh
  20909. */
  20910. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20911. /**
  20912. * Registers for this mesh a javascript function called just after the rendering is complete
  20913. * @param func defines the function to call after rendering this mesh
  20914. * @returns the current mesh
  20915. */
  20916. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20917. /**
  20918. * Disposes a previously registered javascript function called after the rendering.
  20919. * @param func defines the function to remove
  20920. * @returns the current mesh
  20921. */
  20922. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20923. /** @hidden */
  20924. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20925. /** @hidden */
  20926. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20927. /** @hidden */
  20928. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20929. /** @hidden */
  20930. _freeze(): void;
  20931. /** @hidden */
  20932. _unFreeze(): void;
  20933. /**
  20934. * 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
  20935. * @param subMesh defines the subMesh to render
  20936. * @param enableAlphaMode defines if alpha mode can be changed
  20937. * @returns the current mesh
  20938. */
  20939. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20940. private _onBeforeDraw;
  20941. /**
  20942. * Renormalize the mesh and patch it up if there are no weights
  20943. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20944. * However in the case of zero weights then we set just a single influence to 1.
  20945. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20946. */
  20947. cleanMatrixWeights(): void;
  20948. private normalizeSkinFourWeights;
  20949. private normalizeSkinWeightsAndExtra;
  20950. /**
  20951. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20952. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20953. * the user know there was an issue with importing the mesh
  20954. * @returns a validation object with skinned, valid and report string
  20955. */
  20956. validateSkinning(): {
  20957. skinned: boolean;
  20958. valid: boolean;
  20959. report: string;
  20960. };
  20961. /** @hidden */
  20962. _checkDelayState(): Mesh;
  20963. private _queueLoad;
  20964. /**
  20965. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20966. * A mesh is in the frustum if its bounding box intersects the frustum
  20967. * @param frustumPlanes defines the frustum to test
  20968. * @returns true if the mesh is in the frustum planes
  20969. */
  20970. isInFrustum(frustumPlanes: Plane[]): boolean;
  20971. /**
  20972. * Sets the mesh material by the material or multiMaterial `id` property
  20973. * @param id is a string identifying the material or the multiMaterial
  20974. * @returns the current mesh
  20975. */
  20976. setMaterialByID(id: string): Mesh;
  20977. /**
  20978. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20979. * @returns an array of IAnimatable
  20980. */
  20981. getAnimatables(): IAnimatable[];
  20982. /**
  20983. * Modifies the mesh geometry according to the passed transformation matrix.
  20984. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20985. * The mesh normals are modified using the same transformation.
  20986. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20987. * @param transform defines the transform matrix to use
  20988. * @see http://doc.babylonjs.com/resources/baking_transformations
  20989. * @returns the current mesh
  20990. */
  20991. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20992. /**
  20993. * Modifies the mesh geometry according to its own current World Matrix.
  20994. * The mesh World Matrix is then reset.
  20995. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20996. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20997. * @see http://doc.babylonjs.com/resources/baking_transformations
  20998. * @returns the current mesh
  20999. */
  21000. bakeCurrentTransformIntoVertices(): Mesh;
  21001. /** @hidden */
  21002. readonly _positions: Nullable<Vector3[]>;
  21003. /** @hidden */
  21004. _resetPointsArrayCache(): Mesh;
  21005. /** @hidden */
  21006. _generatePointsArray(): boolean;
  21007. /**
  21008. * Returns a new Mesh object generated from the current mesh properties.
  21009. * This method must not get confused with createInstance()
  21010. * @param name is a string, the name given to the new mesh
  21011. * @param newParent can be any Node object (default `null`)
  21012. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21013. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21014. * @returns a new mesh
  21015. */
  21016. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21017. /**
  21018. * Releases resources associated with this mesh.
  21019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21021. */
  21022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21023. /**
  21024. * Modifies the mesh geometry according to a displacement map.
  21025. * 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.
  21026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21027. * @param url is a string, the URL from the image file is to be downloaded.
  21028. * @param minHeight is the lower limit of the displacement.
  21029. * @param maxHeight is the upper limit of the displacement.
  21030. * @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.
  21031. * @param uvOffset is an optional vector2 used to offset UV.
  21032. * @param uvScale is an optional vector2 used to scale UV.
  21033. * @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.
  21034. * @returns the Mesh.
  21035. */
  21036. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21037. /**
  21038. * Modifies the mesh geometry according to a displacementMap buffer.
  21039. * 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.
  21040. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21041. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21042. * @param heightMapWidth is the width of the buffer image.
  21043. * @param heightMapHeight is the height of the buffer image.
  21044. * @param minHeight is the lower limit of the displacement.
  21045. * @param maxHeight is the upper limit of the displacement.
  21046. * @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.
  21047. * @param uvOffset is an optional vector2 used to offset UV.
  21048. * @param uvScale is an optional vector2 used to scale UV.
  21049. * @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.
  21050. * @returns the Mesh.
  21051. */
  21052. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21053. /**
  21054. * Modify the mesh to get a flat shading rendering.
  21055. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21056. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21057. * @returns current mesh
  21058. */
  21059. convertToFlatShadedMesh(): Mesh;
  21060. /**
  21061. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21062. * In other words, more vertices, no more indices and a single bigger VBO.
  21063. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21064. * @returns current mesh
  21065. */
  21066. convertToUnIndexedMesh(): Mesh;
  21067. /**
  21068. * Inverses facet orientations.
  21069. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21070. * @param flipNormals will also inverts the normals
  21071. * @returns current mesh
  21072. */
  21073. flipFaces(flipNormals?: boolean): Mesh;
  21074. /**
  21075. * Increase the number of facets and hence vertices in a mesh
  21076. * Vertex normals are interpolated from existing vertex normals
  21077. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21078. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21079. */
  21080. increaseVertices(numberPerEdge: number): void;
  21081. /**
  21082. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21083. * This will undo any application of covertToFlatShadedMesh
  21084. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21085. */
  21086. forceSharedVertices(): void;
  21087. /** @hidden */
  21088. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21089. /** @hidden */
  21090. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21091. /**
  21092. * Creates a new InstancedMesh object from the mesh model.
  21093. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21094. * @param name defines the name of the new instance
  21095. * @returns a new InstancedMesh
  21096. */
  21097. createInstance(name: string): InstancedMesh;
  21098. /**
  21099. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21100. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21101. * @returns the current mesh
  21102. */
  21103. synchronizeInstances(): Mesh;
  21104. /**
  21105. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21106. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21107. * This should be used together with the simplification to avoid disappearing triangles.
  21108. * @param successCallback an optional success callback to be called after the optimization finished.
  21109. * @returns the current mesh
  21110. */
  21111. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21112. /**
  21113. * Serialize current mesh
  21114. * @param serializationObject defines the object which will receive the serialization data
  21115. */
  21116. serialize(serializationObject: any): void;
  21117. /** @hidden */
  21118. _syncGeometryWithMorphTargetManager(): void;
  21119. /** @hidden */
  21120. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21121. /**
  21122. * Returns a new Mesh object parsed from the source provided.
  21123. * @param parsedMesh is the source
  21124. * @param scene defines the hosting scene
  21125. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21126. * @returns a new Mesh
  21127. */
  21128. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21129. /**
  21130. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21132. * @param name defines the name of the mesh to create
  21133. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21134. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21135. * @param closePath creates a seam between the first and the last points of each path of the path array
  21136. * @param offset is taken in account only if the `pathArray` is containing a single path
  21137. * @param scene defines the hosting scene
  21138. * @param updatable defines if the mesh must be flagged as updatable
  21139. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21140. * @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)
  21141. * @returns a new Mesh
  21142. */
  21143. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21144. /**
  21145. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21146. * @param name defines the name of the mesh to create
  21147. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21148. * @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
  21149. * @param scene defines the hosting scene
  21150. * @param updatable defines if the mesh must be flagged as updatable
  21151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21152. * @returns a new Mesh
  21153. */
  21154. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21155. /**
  21156. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21157. * @param name defines the name of the mesh to create
  21158. * @param size sets the size (float) of each box side (default 1)
  21159. * @param scene defines the hosting scene
  21160. * @param updatable defines if the mesh must be flagged as updatable
  21161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21162. * @returns a new Mesh
  21163. */
  21164. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21165. /**
  21166. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21167. * @param name defines the name of the mesh to create
  21168. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21169. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21170. * @param scene defines the hosting scene
  21171. * @param updatable defines if the mesh must be flagged as updatable
  21172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21173. * @returns a new Mesh
  21174. */
  21175. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21176. /**
  21177. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21178. * @param name defines the name of the mesh to create
  21179. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21180. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21181. * @param scene defines the hosting scene
  21182. * @returns a new Mesh
  21183. */
  21184. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21185. /**
  21186. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21187. * @param name defines the name of the mesh to create
  21188. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21189. * @param diameterTop set the top cap diameter (floats, default 1)
  21190. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21191. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21192. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21193. * @param scene defines the hosting scene
  21194. * @param updatable defines if the mesh must be flagged as updatable
  21195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21196. * @returns a new Mesh
  21197. */
  21198. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21199. /**
  21200. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21201. * @param name defines the name of the mesh to create
  21202. * @param diameter sets the diameter size (float) of the torus (default 1)
  21203. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21204. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21205. * @param scene defines the hosting scene
  21206. * @param updatable defines if the mesh must be flagged as updatable
  21207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21208. * @returns a new Mesh
  21209. */
  21210. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21211. /**
  21212. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21213. * @param name defines the name of the mesh to create
  21214. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21215. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21216. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21217. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21218. * @param p the number of windings on X axis (positive integers, default 2)
  21219. * @param q the number of windings on Y axis (positive integers, default 3)
  21220. * @param scene defines the hosting scene
  21221. * @param updatable defines if the mesh must be flagged as updatable
  21222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21223. * @returns a new Mesh
  21224. */
  21225. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21226. /**
  21227. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21228. * @param name defines the name of the mesh to create
  21229. * @param points is an array successive Vector3
  21230. * @param scene defines the hosting scene
  21231. * @param updatable defines if the mesh must be flagged as updatable
  21232. * @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).
  21233. * @returns a new Mesh
  21234. */
  21235. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21236. /**
  21237. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21238. * @param name defines the name of the mesh to create
  21239. * @param points is an array successive Vector3
  21240. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21241. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21242. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21243. * @param scene defines the hosting scene
  21244. * @param updatable defines if the mesh must be flagged as updatable
  21245. * @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)
  21246. * @returns a new Mesh
  21247. */
  21248. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21249. /**
  21250. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21251. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21252. * 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.
  21253. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21254. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21255. * Remember you can only change the shape positions, not their number when updating a polygon.
  21256. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21257. * @param name defines the name of the mesh to create
  21258. * @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
  21259. * @param scene defines the hosting scene
  21260. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21261. * @param updatable defines if the mesh must be flagged as updatable
  21262. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21263. * @param earcutInjection can be used to inject your own earcut reference
  21264. * @returns a new Mesh
  21265. */
  21266. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21267. /**
  21268. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21269. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21270. * @param name defines the name of the mesh to create
  21271. * @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
  21272. * @param depth defines the height of extrusion
  21273. * @param scene defines the hosting scene
  21274. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21277. * @param earcutInjection can be used to inject your own earcut reference
  21278. * @returns a new Mesh
  21279. */
  21280. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21281. /**
  21282. * Creates an extruded shape mesh.
  21283. * 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
  21284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21285. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21286. * @param name defines the name of the mesh to create
  21287. * @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
  21288. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21289. * @param scale is the value to scale the shape
  21290. * @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
  21291. * @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
  21292. * @param scene defines the hosting scene
  21293. * @param updatable defines if the mesh must be flagged as updatable
  21294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21295. * @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)
  21296. * @returns a new Mesh
  21297. */
  21298. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21299. /**
  21300. * Creates an custom extruded shape mesh.
  21301. * The custom extrusion is a parametric shape.
  21302. * It has no predefined shape. Its final shape will depend on the input parameters.
  21303. * Please consider using the same method from the MeshBuilder class instead
  21304. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21305. * @param name defines the name of the mesh to create
  21306. * @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
  21307. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21308. * @param scaleFunction is a custom Javascript function called on each path point
  21309. * @param rotationFunction is a custom Javascript function called on each path point
  21310. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21311. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21312. * @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
  21313. * @param scene defines the hosting scene
  21314. * @param updatable defines if the mesh must be flagged as updatable
  21315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21316. * @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)
  21317. * @returns a new Mesh
  21318. */
  21319. 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;
  21320. /**
  21321. * Creates lathe mesh.
  21322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21323. * Please consider using the same method from the MeshBuilder class instead
  21324. * @param name defines the name of the mesh to create
  21325. * @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
  21326. * @param radius is the radius value of the lathe
  21327. * @param tessellation is the side number of the lathe.
  21328. * @param scene defines the hosting scene
  21329. * @param updatable defines if the mesh must be flagged as updatable
  21330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21331. * @returns a new Mesh
  21332. */
  21333. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21334. /**
  21335. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21336. * @param name defines the name of the mesh to create
  21337. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21338. * @param scene defines the hosting scene
  21339. * @param updatable defines if the mesh must be flagged as updatable
  21340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21341. * @returns a new Mesh
  21342. */
  21343. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21344. /**
  21345. * Creates a ground mesh.
  21346. * Please consider using the same method from the MeshBuilder class instead
  21347. * @param name defines the name of the mesh to create
  21348. * @param width set the width of the ground
  21349. * @param height set the height of the ground
  21350. * @param subdivisions sets the number of subdivisions per side
  21351. * @param scene defines the hosting scene
  21352. * @param updatable defines if the mesh must be flagged as updatable
  21353. * @returns a new Mesh
  21354. */
  21355. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21356. /**
  21357. * Creates a tiled ground mesh.
  21358. * Please consider using the same method from the MeshBuilder class instead
  21359. * @param name defines the name of the mesh to create
  21360. * @param xmin set the ground minimum X coordinate
  21361. * @param zmin set the ground minimum Y coordinate
  21362. * @param xmax set the ground maximum X coordinate
  21363. * @param zmax set the ground maximum Z coordinate
  21364. * @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
  21365. * @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
  21366. * @param scene defines the hosting scene
  21367. * @param updatable defines if the mesh must be flagged as updatable
  21368. * @returns a new Mesh
  21369. */
  21370. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21371. w: number;
  21372. h: number;
  21373. }, precision: {
  21374. w: number;
  21375. h: number;
  21376. }, scene: Scene, updatable?: boolean): Mesh;
  21377. /**
  21378. * Creates a ground mesh from a height map.
  21379. * Please consider using the same method from the MeshBuilder class instead
  21380. * @see http://doc.babylonjs.com/babylon101/height_map
  21381. * @param name defines the name of the mesh to create
  21382. * @param url sets the URL of the height map image resource
  21383. * @param width set the ground width size
  21384. * @param height set the ground height size
  21385. * @param subdivisions sets the number of subdivision per side
  21386. * @param minHeight is the minimum altitude on the ground
  21387. * @param maxHeight is the maximum altitude on the ground
  21388. * @param scene defines the hosting scene
  21389. * @param updatable defines if the mesh must be flagged as updatable
  21390. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21391. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21392. * @returns a new Mesh
  21393. */
  21394. 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;
  21395. /**
  21396. * Creates a tube mesh.
  21397. * The tube is a parametric shape.
  21398. * It has no predefined shape. Its final shape will depend on the input parameters.
  21399. * Please consider using the same method from the MeshBuilder class instead
  21400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21401. * @param name defines the name of the mesh to create
  21402. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21403. * @param radius sets the tube radius size
  21404. * @param tessellation is the number of sides on the tubular surface
  21405. * @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
  21406. * @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
  21407. * @param scene defines the hosting scene
  21408. * @param updatable defines if the mesh must be flagged as updatable
  21409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21410. * @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)
  21411. * @returns a new Mesh
  21412. */
  21413. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21414. (i: number, distance: number): number;
  21415. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21416. /**
  21417. * Creates a polyhedron mesh.
  21418. * Please consider using the same method from the MeshBuilder class instead.
  21419. * * 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
  21420. * * The parameter `size` (positive float, default 1) sets the polygon size
  21421. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21422. * * 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`
  21423. * * 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
  21424. * * 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)`)
  21425. * * 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
  21426. * * 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
  21427. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21428. * * 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
  21429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21430. * @param name defines the name of the mesh to create
  21431. * @param options defines the options used to create the mesh
  21432. * @param scene defines the hosting scene
  21433. * @returns a new Mesh
  21434. */
  21435. static CreatePolyhedron(name: string, options: {
  21436. type?: number;
  21437. size?: number;
  21438. sizeX?: number;
  21439. sizeY?: number;
  21440. sizeZ?: number;
  21441. custom?: any;
  21442. faceUV?: Vector4[];
  21443. faceColors?: Color4[];
  21444. updatable?: boolean;
  21445. sideOrientation?: number;
  21446. }, scene: Scene): Mesh;
  21447. /**
  21448. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21449. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21450. * * 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`)
  21451. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21452. * * 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
  21453. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21454. * * 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
  21455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21456. * @param name defines the name of the mesh
  21457. * @param options defines the options used to create the mesh
  21458. * @param scene defines the hosting scene
  21459. * @returns a new Mesh
  21460. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21461. */
  21462. static CreateIcoSphere(name: string, options: {
  21463. radius?: number;
  21464. flat?: boolean;
  21465. subdivisions?: number;
  21466. sideOrientation?: number;
  21467. updatable?: boolean;
  21468. }, scene: Scene): Mesh;
  21469. /**
  21470. * Creates a decal mesh.
  21471. * Please consider using the same method from the MeshBuilder class instead.
  21472. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21473. * @param name defines the name of the mesh
  21474. * @param sourceMesh defines the mesh receiving the decal
  21475. * @param position sets the position of the decal in world coordinates
  21476. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21477. * @param size sets the decal scaling
  21478. * @param angle sets the angle to rotate the decal
  21479. * @returns a new Mesh
  21480. */
  21481. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21482. /**
  21483. * Prepare internal position array for software CPU skinning
  21484. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21485. */
  21486. setPositionsForCPUSkinning(): Float32Array;
  21487. /**
  21488. * Prepare internal normal array for software CPU skinning
  21489. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21490. */
  21491. setNormalsForCPUSkinning(): Float32Array;
  21492. /**
  21493. * Updates the vertex buffer by applying transformation from the bones
  21494. * @param skeleton defines the skeleton to apply to current mesh
  21495. * @returns the current mesh
  21496. */
  21497. applySkeleton(skeleton: Skeleton): Mesh;
  21498. /**
  21499. * 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
  21500. * @param meshes defines the list of meshes to scan
  21501. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21502. */
  21503. static MinMax(meshes: AbstractMesh[]): {
  21504. min: Vector3;
  21505. max: Vector3;
  21506. };
  21507. /**
  21508. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21509. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21510. * @returns a vector3
  21511. */
  21512. static Center(meshesOrMinMaxVector: {
  21513. min: Vector3;
  21514. max: Vector3;
  21515. } | AbstractMesh[]): Vector3;
  21516. /**
  21517. * Merge the array of meshes into a single mesh for performance reasons.
  21518. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21519. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21520. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21521. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21522. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21523. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21524. * @returns a new mesh
  21525. */
  21526. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21527. /** @hidden */
  21528. addInstance(instance: InstancedMesh): void;
  21529. /** @hidden */
  21530. removeInstance(instance: InstancedMesh): void;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * Base class for the main features of a material in Babylon.js
  21536. */
  21537. export class Material implements IAnimatable {
  21538. /**
  21539. * Returns the triangle fill mode
  21540. */
  21541. static readonly TriangleFillMode: number;
  21542. /**
  21543. * Returns the wireframe mode
  21544. */
  21545. static readonly WireFrameFillMode: number;
  21546. /**
  21547. * Returns the point fill mode
  21548. */
  21549. static readonly PointFillMode: number;
  21550. /**
  21551. * Returns the point list draw mode
  21552. */
  21553. static readonly PointListDrawMode: number;
  21554. /**
  21555. * Returns the line list draw mode
  21556. */
  21557. static readonly LineListDrawMode: number;
  21558. /**
  21559. * Returns the line loop draw mode
  21560. */
  21561. static readonly LineLoopDrawMode: number;
  21562. /**
  21563. * Returns the line strip draw mode
  21564. */
  21565. static readonly LineStripDrawMode: number;
  21566. /**
  21567. * Returns the triangle strip draw mode
  21568. */
  21569. static readonly TriangleStripDrawMode: number;
  21570. /**
  21571. * Returns the triangle fan draw mode
  21572. */
  21573. static readonly TriangleFanDrawMode: number;
  21574. /**
  21575. * Stores the clock-wise side orientation
  21576. */
  21577. static readonly ClockWiseSideOrientation: number;
  21578. /**
  21579. * Stores the counter clock-wise side orientation
  21580. */
  21581. static readonly CounterClockWiseSideOrientation: number;
  21582. /**
  21583. * The dirty texture flag value
  21584. */
  21585. static readonly TextureDirtyFlag: number;
  21586. /**
  21587. * The dirty light flag value
  21588. */
  21589. static readonly LightDirtyFlag: number;
  21590. /**
  21591. * The dirty fresnel flag value
  21592. */
  21593. static readonly FresnelDirtyFlag: number;
  21594. /**
  21595. * The dirty attribute flag value
  21596. */
  21597. static readonly AttributesDirtyFlag: number;
  21598. /**
  21599. * The dirty misc flag value
  21600. */
  21601. static readonly MiscDirtyFlag: number;
  21602. /**
  21603. * The all dirty flag value
  21604. */
  21605. static readonly AllDirtyFlag: number;
  21606. /**
  21607. * The ID of the material
  21608. */
  21609. id: string;
  21610. /**
  21611. * Gets or sets the unique id of the material
  21612. */
  21613. uniqueId: number;
  21614. /**
  21615. * The name of the material
  21616. */
  21617. name: string;
  21618. /**
  21619. * Gets or sets user defined metadata
  21620. */
  21621. metadata: any;
  21622. /**
  21623. * For internal use only. Please do not use.
  21624. */
  21625. reservedDataStore: any;
  21626. /**
  21627. * Specifies if the ready state should be checked on each call
  21628. */
  21629. checkReadyOnEveryCall: boolean;
  21630. /**
  21631. * Specifies if the ready state should be checked once
  21632. */
  21633. checkReadyOnlyOnce: boolean;
  21634. /**
  21635. * The state of the material
  21636. */
  21637. state: string;
  21638. /**
  21639. * The alpha value of the material
  21640. */
  21641. protected _alpha: number;
  21642. /**
  21643. * List of inspectable custom properties (used by the Inspector)
  21644. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21645. */
  21646. inspectableCustomProperties: IInspectable[];
  21647. /**
  21648. * Sets the alpha value of the material
  21649. */
  21650. /**
  21651. * Gets the alpha value of the material
  21652. */
  21653. alpha: number;
  21654. /**
  21655. * Specifies if back face culling is enabled
  21656. */
  21657. protected _backFaceCulling: boolean;
  21658. /**
  21659. * Sets the back-face culling state
  21660. */
  21661. /**
  21662. * Gets the back-face culling state
  21663. */
  21664. backFaceCulling: boolean;
  21665. /**
  21666. * Stores the value for side orientation
  21667. */
  21668. sideOrientation: number;
  21669. /**
  21670. * Callback triggered when the material is compiled
  21671. */
  21672. onCompiled: Nullable<(effect: Effect) => void>;
  21673. /**
  21674. * Callback triggered when an error occurs
  21675. */
  21676. onError: Nullable<(effect: Effect, errors: string) => void>;
  21677. /**
  21678. * Callback triggered to get the render target textures
  21679. */
  21680. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21681. /**
  21682. * Gets a boolean indicating that current material needs to register RTT
  21683. */
  21684. readonly hasRenderTargetTextures: boolean;
  21685. /**
  21686. * Specifies if the material should be serialized
  21687. */
  21688. doNotSerialize: boolean;
  21689. /**
  21690. * @hidden
  21691. */
  21692. _storeEffectOnSubMeshes: boolean;
  21693. /**
  21694. * Stores the animations for the material
  21695. */
  21696. animations: Nullable<Array<Animation>>;
  21697. /**
  21698. * An event triggered when the material is disposed
  21699. */
  21700. onDisposeObservable: Observable<Material>;
  21701. /**
  21702. * An observer which watches for dispose events
  21703. */
  21704. private _onDisposeObserver;
  21705. private _onUnBindObservable;
  21706. /**
  21707. * Called during a dispose event
  21708. */
  21709. onDispose: () => void;
  21710. private _onBindObservable;
  21711. /**
  21712. * An event triggered when the material is bound
  21713. */
  21714. readonly onBindObservable: Observable<AbstractMesh>;
  21715. /**
  21716. * An observer which watches for bind events
  21717. */
  21718. private _onBindObserver;
  21719. /**
  21720. * Called during a bind event
  21721. */
  21722. onBind: (Mesh: AbstractMesh) => void;
  21723. /**
  21724. * An event triggered when the material is unbound
  21725. */
  21726. readonly onUnBindObservable: Observable<Material>;
  21727. /**
  21728. * Stores the value of the alpha mode
  21729. */
  21730. private _alphaMode;
  21731. /**
  21732. * Sets the value of the alpha mode.
  21733. *
  21734. * | Value | Type | Description |
  21735. * | --- | --- | --- |
  21736. * | 0 | ALPHA_DISABLE | |
  21737. * | 1 | ALPHA_ADD | |
  21738. * | 2 | ALPHA_COMBINE | |
  21739. * | 3 | ALPHA_SUBTRACT | |
  21740. * | 4 | ALPHA_MULTIPLY | |
  21741. * | 5 | ALPHA_MAXIMIZED | |
  21742. * | 6 | ALPHA_ONEONE | |
  21743. * | 7 | ALPHA_PREMULTIPLIED | |
  21744. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21745. * | 9 | ALPHA_INTERPOLATE | |
  21746. * | 10 | ALPHA_SCREENMODE | |
  21747. *
  21748. */
  21749. /**
  21750. * Gets the value of the alpha mode
  21751. */
  21752. alphaMode: number;
  21753. /**
  21754. * Stores the state of the need depth pre-pass value
  21755. */
  21756. private _needDepthPrePass;
  21757. /**
  21758. * Sets the need depth pre-pass value
  21759. */
  21760. /**
  21761. * Gets the depth pre-pass value
  21762. */
  21763. needDepthPrePass: boolean;
  21764. /**
  21765. * Specifies if depth writing should be disabled
  21766. */
  21767. disableDepthWrite: boolean;
  21768. /**
  21769. * Specifies if depth writing should be forced
  21770. */
  21771. forceDepthWrite: boolean;
  21772. /**
  21773. * Specifies if there should be a separate pass for culling
  21774. */
  21775. separateCullingPass: boolean;
  21776. /**
  21777. * Stores the state specifing if fog should be enabled
  21778. */
  21779. private _fogEnabled;
  21780. /**
  21781. * Sets the state for enabling fog
  21782. */
  21783. /**
  21784. * Gets the value of the fog enabled state
  21785. */
  21786. fogEnabled: boolean;
  21787. /**
  21788. * Stores the size of points
  21789. */
  21790. pointSize: number;
  21791. /**
  21792. * Stores the z offset value
  21793. */
  21794. zOffset: number;
  21795. /**
  21796. * Gets a value specifying if wireframe mode is enabled
  21797. */
  21798. /**
  21799. * Sets the state of wireframe mode
  21800. */
  21801. wireframe: boolean;
  21802. /**
  21803. * Gets the value specifying if point clouds are enabled
  21804. */
  21805. /**
  21806. * Sets the state of point cloud mode
  21807. */
  21808. pointsCloud: boolean;
  21809. /**
  21810. * Gets the material fill mode
  21811. */
  21812. /**
  21813. * Sets the material fill mode
  21814. */
  21815. fillMode: number;
  21816. /**
  21817. * @hidden
  21818. * Stores the effects for the material
  21819. */
  21820. _effect: Nullable<Effect>;
  21821. /**
  21822. * @hidden
  21823. * Specifies if the material was previously ready
  21824. */
  21825. _wasPreviouslyReady: boolean;
  21826. /**
  21827. * Specifies if uniform buffers should be used
  21828. */
  21829. private _useUBO;
  21830. /**
  21831. * Stores a reference to the scene
  21832. */
  21833. private _scene;
  21834. /**
  21835. * Stores the fill mode state
  21836. */
  21837. private _fillMode;
  21838. /**
  21839. * Specifies if the depth write state should be cached
  21840. */
  21841. private _cachedDepthWriteState;
  21842. /**
  21843. * Stores the uniform buffer
  21844. */
  21845. protected _uniformBuffer: UniformBuffer;
  21846. /** @hidden */
  21847. _indexInSceneMaterialArray: number;
  21848. /** @hidden */
  21849. meshMap: Nullable<{
  21850. [id: string]: AbstractMesh | undefined;
  21851. }>;
  21852. /**
  21853. * Creates a material instance
  21854. * @param name defines the name of the material
  21855. * @param scene defines the scene to reference
  21856. * @param doNotAdd specifies if the material should be added to the scene
  21857. */
  21858. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21859. /**
  21860. * Returns a string representation of the current material
  21861. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21862. * @returns a string with material information
  21863. */
  21864. toString(fullDetails?: boolean): string;
  21865. /**
  21866. * Gets the class name of the material
  21867. * @returns a string with the class name of the material
  21868. */
  21869. getClassName(): string;
  21870. /**
  21871. * Specifies if updates for the material been locked
  21872. */
  21873. readonly isFrozen: boolean;
  21874. /**
  21875. * Locks updates for the material
  21876. */
  21877. freeze(): void;
  21878. /**
  21879. * Unlocks updates for the material
  21880. */
  21881. unfreeze(): void;
  21882. /**
  21883. * Specifies if the material is ready to be used
  21884. * @param mesh defines the mesh to check
  21885. * @param useInstances specifies if instances should be used
  21886. * @returns a boolean indicating if the material is ready to be used
  21887. */
  21888. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21889. /**
  21890. * Specifies that the submesh is ready to be used
  21891. * @param mesh defines the mesh to check
  21892. * @param subMesh defines which submesh to check
  21893. * @param useInstances specifies that instances should be used
  21894. * @returns a boolean indicating that the submesh is ready or not
  21895. */
  21896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21897. /**
  21898. * Returns the material effect
  21899. * @returns the effect associated with the material
  21900. */
  21901. getEffect(): Nullable<Effect>;
  21902. /**
  21903. * Returns the current scene
  21904. * @returns a Scene
  21905. */
  21906. getScene(): Scene;
  21907. /**
  21908. * Specifies if the material will require alpha blending
  21909. * @returns a boolean specifying if alpha blending is needed
  21910. */
  21911. needAlphaBlending(): boolean;
  21912. /**
  21913. * Specifies if the mesh will require alpha blending
  21914. * @param mesh defines the mesh to check
  21915. * @returns a boolean specifying if alpha blending is needed for the mesh
  21916. */
  21917. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21918. /**
  21919. * Specifies if this material should be rendered in alpha test mode
  21920. * @returns a boolean specifying if an alpha test is needed.
  21921. */
  21922. needAlphaTesting(): boolean;
  21923. /**
  21924. * Gets the texture used for the alpha test
  21925. * @returns the texture to use for alpha testing
  21926. */
  21927. getAlphaTestTexture(): Nullable<BaseTexture>;
  21928. /**
  21929. * Marks the material to indicate that it needs to be re-calculated
  21930. */
  21931. markDirty(): void;
  21932. /** @hidden */
  21933. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21934. /**
  21935. * Binds the material to the mesh
  21936. * @param world defines the world transformation matrix
  21937. * @param mesh defines the mesh to bind the material to
  21938. */
  21939. bind(world: Matrix, mesh?: Mesh): void;
  21940. /**
  21941. * Binds the submesh to the material
  21942. * @param world defines the world transformation matrix
  21943. * @param mesh defines the mesh containing the submesh
  21944. * @param subMesh defines the submesh to bind the material to
  21945. */
  21946. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21947. /**
  21948. * Binds the world matrix to the material
  21949. * @param world defines the world transformation matrix
  21950. */
  21951. bindOnlyWorldMatrix(world: Matrix): void;
  21952. /**
  21953. * Binds the scene's uniform buffer to the effect.
  21954. * @param effect defines the effect to bind to the scene uniform buffer
  21955. * @param sceneUbo defines the uniform buffer storing scene data
  21956. */
  21957. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21958. /**
  21959. * Binds the view matrix to the effect
  21960. * @param effect defines the effect to bind the view matrix to
  21961. */
  21962. bindView(effect: Effect): void;
  21963. /**
  21964. * Binds the view projection matrix to the effect
  21965. * @param effect defines the effect to bind the view projection matrix to
  21966. */
  21967. bindViewProjection(effect: Effect): void;
  21968. /**
  21969. * Specifies if material alpha testing should be turned on for the mesh
  21970. * @param mesh defines the mesh to check
  21971. */
  21972. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21973. /**
  21974. * Processes to execute after binding the material to a mesh
  21975. * @param mesh defines the rendered mesh
  21976. */
  21977. protected _afterBind(mesh?: Mesh): void;
  21978. /**
  21979. * Unbinds the material from the mesh
  21980. */
  21981. unbind(): void;
  21982. /**
  21983. * Gets the active textures from the material
  21984. * @returns an array of textures
  21985. */
  21986. getActiveTextures(): BaseTexture[];
  21987. /**
  21988. * Specifies if the material uses a texture
  21989. * @param texture defines the texture to check against the material
  21990. * @returns a boolean specifying if the material uses the texture
  21991. */
  21992. hasTexture(texture: BaseTexture): boolean;
  21993. /**
  21994. * Makes a duplicate of the material, and gives it a new name
  21995. * @param name defines the new name for the duplicated material
  21996. * @returns the cloned material
  21997. */
  21998. clone(name: string): Nullable<Material>;
  21999. /**
  22000. * Gets the meshes bound to the material
  22001. * @returns an array of meshes bound to the material
  22002. */
  22003. getBindedMeshes(): AbstractMesh[];
  22004. /**
  22005. * Force shader compilation
  22006. * @param mesh defines the mesh associated with this material
  22007. * @param onCompiled defines a function to execute once the material is compiled
  22008. * @param options defines the options to configure the compilation
  22009. */
  22010. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22011. clipPlane: boolean;
  22012. }>): void;
  22013. /**
  22014. * Force shader compilation
  22015. * @param mesh defines the mesh that will use this material
  22016. * @param options defines additional options for compiling the shaders
  22017. * @returns a promise that resolves when the compilation completes
  22018. */
  22019. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22020. clipPlane: boolean;
  22021. }>): Promise<void>;
  22022. private static readonly _ImageProcessingDirtyCallBack;
  22023. private static readonly _TextureDirtyCallBack;
  22024. private static readonly _FresnelDirtyCallBack;
  22025. private static readonly _MiscDirtyCallBack;
  22026. private static readonly _LightsDirtyCallBack;
  22027. private static readonly _AttributeDirtyCallBack;
  22028. private static _FresnelAndMiscDirtyCallBack;
  22029. private static _TextureAndMiscDirtyCallBack;
  22030. private static readonly _DirtyCallbackArray;
  22031. private static readonly _RunDirtyCallBacks;
  22032. /**
  22033. * Marks a define in the material to indicate that it needs to be re-computed
  22034. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22035. */
  22036. markAsDirty(flag: number): void;
  22037. /**
  22038. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22039. * @param func defines a function which checks material defines against the submeshes
  22040. */
  22041. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22042. /**
  22043. * Indicates that image processing needs to be re-calculated for all submeshes
  22044. */
  22045. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22046. /**
  22047. * Indicates that textures need to be re-calculated for all submeshes
  22048. */
  22049. protected _markAllSubMeshesAsTexturesDirty(): void;
  22050. /**
  22051. * Indicates that fresnel needs to be re-calculated for all submeshes
  22052. */
  22053. protected _markAllSubMeshesAsFresnelDirty(): void;
  22054. /**
  22055. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22056. */
  22057. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22058. /**
  22059. * Indicates that lights need to be re-calculated for all submeshes
  22060. */
  22061. protected _markAllSubMeshesAsLightsDirty(): void;
  22062. /**
  22063. * Indicates that attributes need to be re-calculated for all submeshes
  22064. */
  22065. protected _markAllSubMeshesAsAttributesDirty(): void;
  22066. /**
  22067. * Indicates that misc needs to be re-calculated for all submeshes
  22068. */
  22069. protected _markAllSubMeshesAsMiscDirty(): void;
  22070. /**
  22071. * Indicates that textures and misc need to be re-calculated for all submeshes
  22072. */
  22073. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22074. /**
  22075. * Disposes the material
  22076. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22077. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22078. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22079. */
  22080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22081. /** @hidden */
  22082. private releaseVertexArrayObject;
  22083. /**
  22084. * Serializes this material
  22085. * @returns the serialized material object
  22086. */
  22087. serialize(): any;
  22088. /**
  22089. * Creates a material from parsed material data
  22090. * @param parsedMaterial defines parsed material data
  22091. * @param scene defines the hosting scene
  22092. * @param rootUrl defines the root URL to use to load textures
  22093. * @returns a new material
  22094. */
  22095. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22096. }
  22097. }
  22098. declare module BABYLON {
  22099. /**
  22100. * Base class for submeshes
  22101. */
  22102. export class BaseSubMesh {
  22103. /** @hidden */
  22104. _materialDefines: Nullable<MaterialDefines>;
  22105. /** @hidden */
  22106. _materialEffect: Nullable<Effect>;
  22107. /**
  22108. * Gets associated effect
  22109. */
  22110. readonly effect: Nullable<Effect>;
  22111. /**
  22112. * Sets associated effect (effect used to render this submesh)
  22113. * @param effect defines the effect to associate with
  22114. * @param defines defines the set of defines used to compile this effect
  22115. */
  22116. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22117. }
  22118. /**
  22119. * Defines a subdivision inside a mesh
  22120. */
  22121. export class SubMesh extends BaseSubMesh implements ICullable {
  22122. /** the material index to use */
  22123. materialIndex: number;
  22124. /** vertex index start */
  22125. verticesStart: number;
  22126. /** vertices count */
  22127. verticesCount: number;
  22128. /** index start */
  22129. indexStart: number;
  22130. /** indices count */
  22131. indexCount: number;
  22132. /** @hidden */
  22133. _linesIndexCount: number;
  22134. private _mesh;
  22135. private _renderingMesh;
  22136. private _boundingInfo;
  22137. private _linesIndexBuffer;
  22138. /** @hidden */
  22139. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22140. /** @hidden */
  22141. _trianglePlanes: Plane[];
  22142. /** @hidden */
  22143. _lastColliderTransformMatrix: Nullable<Matrix>;
  22144. /** @hidden */
  22145. _renderId: number;
  22146. /** @hidden */
  22147. _alphaIndex: number;
  22148. /** @hidden */
  22149. _distanceToCamera: number;
  22150. /** @hidden */
  22151. _id: number;
  22152. private _currentMaterial;
  22153. /**
  22154. * Add a new submesh to a mesh
  22155. * @param materialIndex defines the material index to use
  22156. * @param verticesStart defines vertex index start
  22157. * @param verticesCount defines vertices count
  22158. * @param indexStart defines index start
  22159. * @param indexCount defines indices count
  22160. * @param mesh defines the parent mesh
  22161. * @param renderingMesh defines an optional rendering mesh
  22162. * @param createBoundingBox defines if bounding box should be created for this submesh
  22163. * @returns the new submesh
  22164. */
  22165. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22166. /**
  22167. * Creates a new submesh
  22168. * @param materialIndex defines the material index to use
  22169. * @param verticesStart defines vertex index start
  22170. * @param verticesCount defines vertices count
  22171. * @param indexStart defines index start
  22172. * @param indexCount defines indices count
  22173. * @param mesh defines the parent mesh
  22174. * @param renderingMesh defines an optional rendering mesh
  22175. * @param createBoundingBox defines if bounding box should be created for this submesh
  22176. */
  22177. constructor(
  22178. /** the material index to use */
  22179. materialIndex: number,
  22180. /** vertex index start */
  22181. verticesStart: number,
  22182. /** vertices count */
  22183. verticesCount: number,
  22184. /** index start */
  22185. indexStart: number,
  22186. /** indices count */
  22187. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22188. /**
  22189. * Returns true if this submesh covers the entire parent mesh
  22190. * @ignorenaming
  22191. */
  22192. readonly IsGlobal: boolean;
  22193. /**
  22194. * Returns the submesh BoudingInfo object
  22195. * @returns current bounding info (or mesh's one if the submesh is global)
  22196. */
  22197. getBoundingInfo(): BoundingInfo;
  22198. /**
  22199. * Sets the submesh BoundingInfo
  22200. * @param boundingInfo defines the new bounding info to use
  22201. * @returns the SubMesh
  22202. */
  22203. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22204. /**
  22205. * Returns the mesh of the current submesh
  22206. * @return the parent mesh
  22207. */
  22208. getMesh(): AbstractMesh;
  22209. /**
  22210. * Returns the rendering mesh of the submesh
  22211. * @returns the rendering mesh (could be different from parent mesh)
  22212. */
  22213. getRenderingMesh(): Mesh;
  22214. /**
  22215. * Returns the submesh material
  22216. * @returns null or the current material
  22217. */
  22218. getMaterial(): Nullable<Material>;
  22219. /**
  22220. * Sets a new updated BoundingInfo object to the submesh
  22221. * @returns the SubMesh
  22222. */
  22223. refreshBoundingInfo(): SubMesh;
  22224. /** @hidden */
  22225. _checkCollision(collider: Collider): boolean;
  22226. /**
  22227. * Updates the submesh BoundingInfo
  22228. * @param world defines the world matrix to use to update the bounding info
  22229. * @returns the submesh
  22230. */
  22231. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22232. /**
  22233. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22234. * @param frustumPlanes defines the frustum planes
  22235. * @returns true if the submesh is intersecting with the frustum
  22236. */
  22237. isInFrustum(frustumPlanes: Plane[]): boolean;
  22238. /**
  22239. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22240. * @param frustumPlanes defines the frustum planes
  22241. * @returns true if the submesh is inside the frustum
  22242. */
  22243. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22244. /**
  22245. * Renders the submesh
  22246. * @param enableAlphaMode defines if alpha needs to be used
  22247. * @returns the submesh
  22248. */
  22249. render(enableAlphaMode: boolean): SubMesh;
  22250. /**
  22251. * @hidden
  22252. */
  22253. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22254. /**
  22255. * Checks if the submesh intersects with a ray
  22256. * @param ray defines the ray to test
  22257. * @returns true is the passed ray intersects the submesh bounding box
  22258. */
  22259. canIntersects(ray: Ray): boolean;
  22260. /**
  22261. * Intersects current submesh with a ray
  22262. * @param ray defines the ray to test
  22263. * @param positions defines mesh's positions array
  22264. * @param indices defines mesh's indices array
  22265. * @param fastCheck defines if only bounding info should be used
  22266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22267. * @returns intersection info or null if no intersection
  22268. */
  22269. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22270. /** @hidden */
  22271. private _intersectLines;
  22272. /** @hidden */
  22273. private _intersectTriangles;
  22274. /** @hidden */
  22275. _rebuild(): void;
  22276. /**
  22277. * Creates a new submesh from the passed mesh
  22278. * @param newMesh defines the new hosting mesh
  22279. * @param newRenderingMesh defines an optional rendering mesh
  22280. * @returns the new submesh
  22281. */
  22282. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22283. /**
  22284. * Release associated resources
  22285. */
  22286. dispose(): void;
  22287. /**
  22288. * Gets the class name
  22289. * @returns the string "SubMesh".
  22290. */
  22291. getClassName(): string;
  22292. /**
  22293. * Creates a new submesh from indices data
  22294. * @param materialIndex the index of the main mesh material
  22295. * @param startIndex the index where to start the copy in the mesh indices array
  22296. * @param indexCount the number of indices to copy then from the startIndex
  22297. * @param mesh the main mesh to create the submesh from
  22298. * @param renderingMesh the optional rendering mesh
  22299. * @returns a new submesh
  22300. */
  22301. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22302. }
  22303. }
  22304. declare module BABYLON {
  22305. /**
  22306. * Class used to store geometry data (vertex buffers + index buffer)
  22307. */
  22308. export class Geometry implements IGetSetVerticesData {
  22309. /**
  22310. * Gets or sets the ID of the geometry
  22311. */
  22312. id: string;
  22313. /**
  22314. * Gets or sets the unique ID of the geometry
  22315. */
  22316. uniqueId: number;
  22317. /**
  22318. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22319. */
  22320. delayLoadState: number;
  22321. /**
  22322. * Gets the file containing the data to load when running in delay load state
  22323. */
  22324. delayLoadingFile: Nullable<string>;
  22325. /**
  22326. * Callback called when the geometry is updated
  22327. */
  22328. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22329. private _scene;
  22330. private _engine;
  22331. private _meshes;
  22332. private _totalVertices;
  22333. /** @hidden */
  22334. _indices: IndicesArray;
  22335. /** @hidden */
  22336. _vertexBuffers: {
  22337. [key: string]: VertexBuffer;
  22338. };
  22339. private _isDisposed;
  22340. private _extend;
  22341. private _boundingBias;
  22342. /** @hidden */
  22343. _delayInfo: Array<string>;
  22344. private _indexBuffer;
  22345. private _indexBufferIsUpdatable;
  22346. /** @hidden */
  22347. _boundingInfo: Nullable<BoundingInfo>;
  22348. /** @hidden */
  22349. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22350. /** @hidden */
  22351. _softwareSkinningFrameId: number;
  22352. private _vertexArrayObjects;
  22353. private _updatable;
  22354. /** @hidden */
  22355. _positions: Nullable<Vector3[]>;
  22356. /**
  22357. * 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
  22358. */
  22359. /**
  22360. * 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
  22361. */
  22362. boundingBias: Vector2;
  22363. /**
  22364. * Static function used to attach a new empty geometry to a mesh
  22365. * @param mesh defines the mesh to attach the geometry to
  22366. * @returns the new Geometry
  22367. */
  22368. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22369. /**
  22370. * Creates a new geometry
  22371. * @param id defines the unique ID
  22372. * @param scene defines the hosting scene
  22373. * @param vertexData defines the VertexData used to get geometry data
  22374. * @param updatable defines if geometry must be updatable (false by default)
  22375. * @param mesh defines the mesh that will be associated with the geometry
  22376. */
  22377. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22378. /**
  22379. * Gets the current extend of the geometry
  22380. */
  22381. readonly extend: {
  22382. minimum: Vector3;
  22383. maximum: Vector3;
  22384. };
  22385. /**
  22386. * Gets the hosting scene
  22387. * @returns the hosting Scene
  22388. */
  22389. getScene(): Scene;
  22390. /**
  22391. * Gets the hosting engine
  22392. * @returns the hosting Engine
  22393. */
  22394. getEngine(): Engine;
  22395. /**
  22396. * Defines if the geometry is ready to use
  22397. * @returns true if the geometry is ready to be used
  22398. */
  22399. isReady(): boolean;
  22400. /**
  22401. * Gets a value indicating that the geometry should not be serialized
  22402. */
  22403. readonly doNotSerialize: boolean;
  22404. /** @hidden */
  22405. _rebuild(): void;
  22406. /**
  22407. * Affects all geometry data in one call
  22408. * @param vertexData defines the geometry data
  22409. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22410. */
  22411. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22412. /**
  22413. * Set specific vertex data
  22414. * @param kind defines the data kind (Position, normal, etc...)
  22415. * @param data defines the vertex data to use
  22416. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22417. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22418. */
  22419. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22420. /**
  22421. * Removes a specific vertex data
  22422. * @param kind defines the data kind (Position, normal, etc...)
  22423. */
  22424. removeVerticesData(kind: string): void;
  22425. /**
  22426. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22427. * @param buffer defines the vertex buffer to use
  22428. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22429. */
  22430. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22431. /**
  22432. * Update a specific vertex buffer
  22433. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22434. * It will do nothing if the buffer is not updatable
  22435. * @param kind defines the data kind (Position, normal, etc...)
  22436. * @param data defines the data to use
  22437. * @param offset defines the offset in the target buffer where to store the data
  22438. * @param useBytes set to true if the offset is in bytes
  22439. */
  22440. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22441. /**
  22442. * Update a specific vertex buffer
  22443. * This function will create a new buffer if the current one is not updatable
  22444. * @param kind defines the data kind (Position, normal, etc...)
  22445. * @param data defines the data to use
  22446. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22447. */
  22448. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22449. private _updateBoundingInfo;
  22450. /** @hidden */
  22451. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22452. /**
  22453. * Gets total number of vertices
  22454. * @returns the total number of vertices
  22455. */
  22456. getTotalVertices(): number;
  22457. /**
  22458. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22462. * @returns a float array containing vertex data
  22463. */
  22464. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22465. /**
  22466. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @returns true if the vertex buffer with the specified kind is updatable
  22469. */
  22470. isVertexBufferUpdatable(kind: string): boolean;
  22471. /**
  22472. * Gets a specific vertex buffer
  22473. * @param kind defines the data kind (Position, normal, etc...)
  22474. * @returns a VertexBuffer
  22475. */
  22476. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22477. /**
  22478. * Returns all vertex buffers
  22479. * @return an object holding all vertex buffers indexed by kind
  22480. */
  22481. getVertexBuffers(): Nullable<{
  22482. [key: string]: VertexBuffer;
  22483. }>;
  22484. /**
  22485. * Gets a boolean indicating if specific vertex buffer is present
  22486. * @param kind defines the data kind (Position, normal, etc...)
  22487. * @returns true if data is present
  22488. */
  22489. isVerticesDataPresent(kind: string): boolean;
  22490. /**
  22491. * Gets a list of all attached data kinds (Position, normal, etc...)
  22492. * @returns a list of string containing all kinds
  22493. */
  22494. getVerticesDataKinds(): string[];
  22495. /**
  22496. * Update index buffer
  22497. * @param indices defines the indices to store in the index buffer
  22498. * @param offset defines the offset in the target buffer where to store the data
  22499. * @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)
  22500. */
  22501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22502. /**
  22503. * Creates a new index buffer
  22504. * @param indices defines the indices to store in the index buffer
  22505. * @param totalVertices defines the total number of vertices (could be null)
  22506. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22507. */
  22508. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22509. /**
  22510. * Return the total number of indices
  22511. * @returns the total number of indices
  22512. */
  22513. getTotalIndices(): number;
  22514. /**
  22515. * Gets the index buffer array
  22516. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22517. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22518. * @returns the index buffer array
  22519. */
  22520. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22521. /**
  22522. * Gets the index buffer
  22523. * @return the index buffer
  22524. */
  22525. getIndexBuffer(): Nullable<WebGLBuffer>;
  22526. /** @hidden */
  22527. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22528. /**
  22529. * Release the associated resources for a specific mesh
  22530. * @param mesh defines the source mesh
  22531. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22532. */
  22533. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22534. /**
  22535. * Apply current geometry to a given mesh
  22536. * @param mesh defines the mesh to apply geometry to
  22537. */
  22538. applyToMesh(mesh: Mesh): void;
  22539. private _updateExtend;
  22540. private _applyToMesh;
  22541. private notifyUpdate;
  22542. /**
  22543. * Load the geometry if it was flagged as delay loaded
  22544. * @param scene defines the hosting scene
  22545. * @param onLoaded defines a callback called when the geometry is loaded
  22546. */
  22547. load(scene: Scene, onLoaded?: () => void): void;
  22548. private _queueLoad;
  22549. /**
  22550. * Invert the geometry to move from a right handed system to a left handed one.
  22551. */
  22552. toLeftHanded(): void;
  22553. /** @hidden */
  22554. _resetPointsArrayCache(): void;
  22555. /** @hidden */
  22556. _generatePointsArray(): boolean;
  22557. /**
  22558. * Gets a value indicating if the geometry is disposed
  22559. * @returns true if the geometry was disposed
  22560. */
  22561. isDisposed(): boolean;
  22562. private _disposeVertexArrayObjects;
  22563. /**
  22564. * Free all associated resources
  22565. */
  22566. dispose(): void;
  22567. /**
  22568. * Clone the current geometry into a new geometry
  22569. * @param id defines the unique ID of the new geometry
  22570. * @returns a new geometry object
  22571. */
  22572. copy(id: string): Geometry;
  22573. /**
  22574. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22575. * @return a JSON representation of the current geometry data (without the vertices data)
  22576. */
  22577. serialize(): any;
  22578. private toNumberArray;
  22579. /**
  22580. * Serialize all vertices data into a JSON oject
  22581. * @returns a JSON representation of the current geometry data
  22582. */
  22583. serializeVerticeData(): any;
  22584. /**
  22585. * Extracts a clone of a mesh geometry
  22586. * @param mesh defines the source mesh
  22587. * @param id defines the unique ID of the new geometry object
  22588. * @returns the new geometry object
  22589. */
  22590. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22591. /**
  22592. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22593. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22594. * Be aware Math.random() could cause collisions, but:
  22595. * "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"
  22596. * @returns a string containing a new GUID
  22597. */
  22598. static RandomId(): string;
  22599. /** @hidden */
  22600. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22601. private static _CleanMatricesWeights;
  22602. /**
  22603. * Create a new geometry from persisted data (Using .babylon file format)
  22604. * @param parsedVertexData defines the persisted data
  22605. * @param scene defines the hosting scene
  22606. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22607. * @returns the new geometry object
  22608. */
  22609. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22610. }
  22611. }
  22612. declare module BABYLON {
  22613. /**
  22614. * Define an interface for all classes that will get and set the data on vertices
  22615. */
  22616. export interface IGetSetVerticesData {
  22617. /**
  22618. * Gets a boolean indicating if specific vertex data is present
  22619. * @param kind defines the vertex data kind to use
  22620. * @returns true is data kind is present
  22621. */
  22622. isVerticesDataPresent(kind: string): boolean;
  22623. /**
  22624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22625. * @param kind defines the data kind (Position, normal, etc...)
  22626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22628. * @returns a float array containing vertex data
  22629. */
  22630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22631. /**
  22632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22633. * @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.
  22634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22635. * @returns the indices array or an empty array if the mesh has no geometry
  22636. */
  22637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22638. /**
  22639. * Set specific vertex data
  22640. * @param kind defines the data kind (Position, normal, etc...)
  22641. * @param data defines the vertex data to use
  22642. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22643. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22644. */
  22645. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22646. /**
  22647. * Update a specific associated vertex buffer
  22648. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22649. * - VertexBuffer.PositionKind
  22650. * - VertexBuffer.UVKind
  22651. * - VertexBuffer.UV2Kind
  22652. * - VertexBuffer.UV3Kind
  22653. * - VertexBuffer.UV4Kind
  22654. * - VertexBuffer.UV5Kind
  22655. * - VertexBuffer.UV6Kind
  22656. * - VertexBuffer.ColorKind
  22657. * - VertexBuffer.MatricesIndicesKind
  22658. * - VertexBuffer.MatricesIndicesExtraKind
  22659. * - VertexBuffer.MatricesWeightsKind
  22660. * - VertexBuffer.MatricesWeightsExtraKind
  22661. * @param data defines the data source
  22662. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22663. * @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)
  22664. */
  22665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22666. /**
  22667. * Creates a new index buffer
  22668. * @param indices defines the indices to store in the index buffer
  22669. * @param totalVertices defines the total number of vertices (could be null)
  22670. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22671. */
  22672. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22673. }
  22674. /**
  22675. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22676. */
  22677. export class VertexData {
  22678. /**
  22679. * Mesh side orientation : usually the external or front surface
  22680. */
  22681. static readonly FRONTSIDE: number;
  22682. /**
  22683. * Mesh side orientation : usually the internal or back surface
  22684. */
  22685. static readonly BACKSIDE: number;
  22686. /**
  22687. * Mesh side orientation : both internal and external or front and back surfaces
  22688. */
  22689. static readonly DOUBLESIDE: number;
  22690. /**
  22691. * Mesh side orientation : by default, `FRONTSIDE`
  22692. */
  22693. static readonly DEFAULTSIDE: number;
  22694. /**
  22695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22696. */
  22697. positions: Nullable<FloatArray>;
  22698. /**
  22699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22700. */
  22701. normals: Nullable<FloatArray>;
  22702. /**
  22703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22704. */
  22705. tangents: Nullable<FloatArray>;
  22706. /**
  22707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22708. */
  22709. uvs: Nullable<FloatArray>;
  22710. /**
  22711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22712. */
  22713. uvs2: Nullable<FloatArray>;
  22714. /**
  22715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22716. */
  22717. uvs3: Nullable<FloatArray>;
  22718. /**
  22719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22720. */
  22721. uvs4: Nullable<FloatArray>;
  22722. /**
  22723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22724. */
  22725. uvs5: Nullable<FloatArray>;
  22726. /**
  22727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22728. */
  22729. uvs6: Nullable<FloatArray>;
  22730. /**
  22731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22732. */
  22733. colors: Nullable<FloatArray>;
  22734. /**
  22735. * 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).
  22736. */
  22737. matricesIndices: Nullable<FloatArray>;
  22738. /**
  22739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22740. */
  22741. matricesWeights: Nullable<FloatArray>;
  22742. /**
  22743. * An array extending the number of possible indices
  22744. */
  22745. matricesIndicesExtra: Nullable<FloatArray>;
  22746. /**
  22747. * An array extending the number of possible weights when the number of indices is extended
  22748. */
  22749. matricesWeightsExtra: Nullable<FloatArray>;
  22750. /**
  22751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22752. */
  22753. indices: Nullable<IndicesArray>;
  22754. /**
  22755. * Uses the passed data array to set the set the values for the specified kind of data
  22756. * @param data a linear array of floating numbers
  22757. * @param kind the type of data that is being set, eg positions, colors etc
  22758. */
  22759. set(data: FloatArray, kind: string): void;
  22760. /**
  22761. * Associates the vertexData to the passed Mesh.
  22762. * Sets it as updatable or not (default `false`)
  22763. * @param mesh the mesh the vertexData is applied to
  22764. * @param updatable when used and having the value true allows new data to update the vertexData
  22765. * @returns the VertexData
  22766. */
  22767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22768. /**
  22769. * Associates the vertexData to the passed Geometry.
  22770. * Sets it as updatable or not (default `false`)
  22771. * @param geometry the geometry the vertexData is applied to
  22772. * @param updatable when used and having the value true allows new data to update the vertexData
  22773. * @returns VertexData
  22774. */
  22775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22776. /**
  22777. * Updates the associated mesh
  22778. * @param mesh the mesh to be updated
  22779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22780. * @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
  22781. * @returns VertexData
  22782. */
  22783. updateMesh(mesh: Mesh): VertexData;
  22784. /**
  22785. * Updates the associated geometry
  22786. * @param geometry the geometry to be updated
  22787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22788. * @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
  22789. * @returns VertexData.
  22790. */
  22791. updateGeometry(geometry: Geometry): VertexData;
  22792. private _applyTo;
  22793. private _update;
  22794. /**
  22795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22796. * @param matrix the transforming matrix
  22797. * @returns the VertexData
  22798. */
  22799. transform(matrix: Matrix): VertexData;
  22800. /**
  22801. * Merges the passed VertexData into the current one
  22802. * @param other the VertexData to be merged into the current one
  22803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22804. * @returns the modified VertexData
  22805. */
  22806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22807. private _mergeElement;
  22808. private _validate;
  22809. /**
  22810. * Serializes the VertexData
  22811. * @returns a serialized object
  22812. */
  22813. serialize(): any;
  22814. /**
  22815. * Extracts the vertexData from a mesh
  22816. * @param mesh the mesh from which to extract the VertexData
  22817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22819. * @returns the object VertexData associated to the passed mesh
  22820. */
  22821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22822. /**
  22823. * Extracts the vertexData from the geometry
  22824. * @param geometry the geometry from which to extract the VertexData
  22825. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22827. * @returns the object VertexData associated to the passed mesh
  22828. */
  22829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22830. private static _ExtractFrom;
  22831. /**
  22832. * Creates the VertexData for a Ribbon
  22833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22834. * * pathArray array of paths, each of which an array of successive Vector3
  22835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22837. * * 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
  22838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22839. * * 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)
  22840. * * 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)
  22841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22844. * @returns the VertexData of the ribbon
  22845. */
  22846. static CreateRibbon(options: {
  22847. pathArray: Vector3[][];
  22848. closeArray?: boolean;
  22849. closePath?: boolean;
  22850. offset?: number;
  22851. sideOrientation?: number;
  22852. frontUVs?: Vector4;
  22853. backUVs?: Vector4;
  22854. invertUV?: boolean;
  22855. uvs?: Vector2[];
  22856. colors?: Color4[];
  22857. }): VertexData;
  22858. /**
  22859. * Creates the VertexData for a box
  22860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22868. * * 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)
  22869. * * 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)
  22870. * @returns the VertexData of the box
  22871. */
  22872. static CreateBox(options: {
  22873. size?: number;
  22874. width?: number;
  22875. height?: number;
  22876. depth?: number;
  22877. faceUV?: Vector4[];
  22878. faceColors?: Color4[];
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22886. * * segments sets the number of horizontal strips optional, default 32
  22887. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22888. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22889. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22890. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22891. * * 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
  22892. * * 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
  22893. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22894. * * 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)
  22895. * * 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)
  22896. * @returns the VertexData of the ellipsoid
  22897. */
  22898. static CreateSphere(options: {
  22899. segments?: number;
  22900. diameter?: number;
  22901. diameterX?: number;
  22902. diameterY?: number;
  22903. diameterZ?: number;
  22904. arc?: number;
  22905. slice?: number;
  22906. sideOrientation?: number;
  22907. frontUVs?: Vector4;
  22908. backUVs?: Vector4;
  22909. }): VertexData;
  22910. /**
  22911. * Creates the VertexData for a cylinder, cone or prism
  22912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22913. * * height sets the height (y direction) of the cylinder, optional, default 2
  22914. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22915. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22916. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22917. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22918. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22919. * * 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
  22920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22922. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22923. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22924. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22925. * * 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)
  22926. * * 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)
  22927. * @returns the VertexData of the cylinder, cone or prism
  22928. */
  22929. static CreateCylinder(options: {
  22930. height?: number;
  22931. diameterTop?: number;
  22932. diameterBottom?: number;
  22933. diameter?: number;
  22934. tessellation?: number;
  22935. subdivisions?: number;
  22936. arc?: number;
  22937. faceColors?: Color4[];
  22938. faceUV?: Vector4[];
  22939. hasRings?: boolean;
  22940. enclose?: boolean;
  22941. sideOrientation?: number;
  22942. frontUVs?: Vector4;
  22943. backUVs?: Vector4;
  22944. }): VertexData;
  22945. /**
  22946. * Creates the VertexData for a torus
  22947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22948. * * diameter the diameter of the torus, optional default 1
  22949. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22952. * * 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)
  22953. * * 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)
  22954. * @returns the VertexData of the torus
  22955. */
  22956. static CreateTorus(options: {
  22957. diameter?: number;
  22958. thickness?: number;
  22959. tessellation?: number;
  22960. sideOrientation?: number;
  22961. frontUVs?: Vector4;
  22962. backUVs?: Vector4;
  22963. }): VertexData;
  22964. /**
  22965. * Creates the VertexData of the LineSystem
  22966. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22967. * - lines an array of lines, each line being an array of successive Vector3
  22968. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22969. * @returns the VertexData of the LineSystem
  22970. */
  22971. static CreateLineSystem(options: {
  22972. lines: Vector3[][];
  22973. colors?: Nullable<Color4[][]>;
  22974. }): VertexData;
  22975. /**
  22976. * Create the VertexData for a DashedLines
  22977. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22978. * - points an array successive Vector3
  22979. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22980. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22981. * - dashNb the intended total number of dashes, optional, default 200
  22982. * @returns the VertexData for the DashedLines
  22983. */
  22984. static CreateDashedLines(options: {
  22985. points: Vector3[];
  22986. dashSize?: number;
  22987. gapSize?: number;
  22988. dashNb?: number;
  22989. }): VertexData;
  22990. /**
  22991. * Creates the VertexData for a Ground
  22992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22993. * - width the width (x direction) of the ground, optional, default 1
  22994. * - height the height (z direction) of the ground, optional, default 1
  22995. * - subdivisions the number of subdivisions per side, optional, default 1
  22996. * @returns the VertexData of the Ground
  22997. */
  22998. static CreateGround(options: {
  22999. width?: number;
  23000. height?: number;
  23001. subdivisions?: number;
  23002. subdivisionsX?: number;
  23003. subdivisionsY?: number;
  23004. }): VertexData;
  23005. /**
  23006. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23007. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23008. * * xmin the ground minimum X coordinate, optional, default -1
  23009. * * zmin the ground minimum Z coordinate, optional, default -1
  23010. * * xmax the ground maximum X coordinate, optional, default 1
  23011. * * zmax the ground maximum Z coordinate, optional, default 1
  23012. * * 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}
  23013. * * 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}
  23014. * @returns the VertexData of the TiledGround
  23015. */
  23016. static CreateTiledGround(options: {
  23017. xmin: number;
  23018. zmin: number;
  23019. xmax: number;
  23020. zmax: number;
  23021. subdivisions?: {
  23022. w: number;
  23023. h: number;
  23024. };
  23025. precision?: {
  23026. w: number;
  23027. h: number;
  23028. };
  23029. }): VertexData;
  23030. /**
  23031. * Creates the VertexData of the Ground designed from a heightmap
  23032. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23033. * * width the width (x direction) of the ground
  23034. * * height the height (z direction) of the ground
  23035. * * subdivisions the number of subdivisions per side
  23036. * * minHeight the minimum altitude on the ground, optional, default 0
  23037. * * maxHeight the maximum altitude on the ground, optional default 1
  23038. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23039. * * buffer the array holding the image color data
  23040. * * bufferWidth the width of image
  23041. * * bufferHeight the height of image
  23042. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23043. * @returns the VertexData of the Ground designed from a heightmap
  23044. */
  23045. static CreateGroundFromHeightMap(options: {
  23046. width: number;
  23047. height: number;
  23048. subdivisions: number;
  23049. minHeight: number;
  23050. maxHeight: number;
  23051. colorFilter: Color3;
  23052. buffer: Uint8Array;
  23053. bufferWidth: number;
  23054. bufferHeight: number;
  23055. alphaFilter: number;
  23056. }): VertexData;
  23057. /**
  23058. * Creates the VertexData for a Plane
  23059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23060. * * size sets the width and height of the plane to the value of size, optional default 1
  23061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23063. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23064. * * 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)
  23065. * * 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)
  23066. * @returns the VertexData of the box
  23067. */
  23068. static CreatePlane(options: {
  23069. size?: number;
  23070. width?: number;
  23071. height?: number;
  23072. sideOrientation?: number;
  23073. frontUVs?: Vector4;
  23074. backUVs?: Vector4;
  23075. }): VertexData;
  23076. /**
  23077. * Creates the VertexData of the Disc or regular Polygon
  23078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23079. * * radius the radius of the disc, optional default 0.5
  23080. * * tessellation the number of polygon sides, optional, default 64
  23081. * * 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
  23082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23083. * * 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)
  23084. * * 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)
  23085. * @returns the VertexData of the box
  23086. */
  23087. static CreateDisc(options: {
  23088. radius?: number;
  23089. tessellation?: number;
  23090. arc?: number;
  23091. sideOrientation?: number;
  23092. frontUVs?: Vector4;
  23093. backUVs?: Vector4;
  23094. }): VertexData;
  23095. /**
  23096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23098. * @param polygon a mesh built from polygonTriangulation.build()
  23099. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23102. * @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)
  23103. * @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)
  23104. * @returns the VertexData of the Polygon
  23105. */
  23106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23107. /**
  23108. * Creates the VertexData of the IcoSphere
  23109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23110. * * radius the radius of the IcoSphere, optional default 1
  23111. * * radiusX allows stretching in the x direction, optional, default radius
  23112. * * radiusY allows stretching in the y direction, optional, default radius
  23113. * * radiusZ allows stretching in the z direction, optional, default radius
  23114. * * flat when true creates a flat shaded mesh, optional, default true
  23115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23117. * * 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)
  23118. * * 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)
  23119. * @returns the VertexData of the IcoSphere
  23120. */
  23121. static CreateIcoSphere(options: {
  23122. radius?: number;
  23123. radiusX?: number;
  23124. radiusY?: number;
  23125. radiusZ?: number;
  23126. flat?: boolean;
  23127. subdivisions?: number;
  23128. sideOrientation?: number;
  23129. frontUVs?: Vector4;
  23130. backUVs?: Vector4;
  23131. }): VertexData;
  23132. /**
  23133. * Creates the VertexData for a Polyhedron
  23134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23135. * * type provided types are:
  23136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23137. * * 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)
  23138. * * size the size of the IcoSphere, optional default 1
  23139. * * sizeX allows stretching in the x direction, optional, default size
  23140. * * sizeY allows stretching in the y direction, optional, default size
  23141. * * sizeZ allows stretching in the z direction, optional, default size
  23142. * * 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
  23143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23145. * * flat when true creates a flat shaded mesh, optional, default true
  23146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23148. * * 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)
  23149. * * 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)
  23150. * @returns the VertexData of the Polyhedron
  23151. */
  23152. static CreatePolyhedron(options: {
  23153. type?: number;
  23154. size?: number;
  23155. sizeX?: number;
  23156. sizeY?: number;
  23157. sizeZ?: number;
  23158. custom?: any;
  23159. faceUV?: Vector4[];
  23160. faceColors?: Color4[];
  23161. flat?: boolean;
  23162. sideOrientation?: number;
  23163. frontUVs?: Vector4;
  23164. backUVs?: Vector4;
  23165. }): VertexData;
  23166. /**
  23167. * Creates the VertexData for a TorusKnot
  23168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23169. * * radius the radius of the torus knot, optional, default 2
  23170. * * tube the thickness of the tube, optional, default 0.5
  23171. * * radialSegments the number of sides on each tube segments, optional, default 32
  23172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23173. * * p the number of windings around the z axis, optional, default 2
  23174. * * q the number of windings around the x axis, optional, default 3
  23175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23176. * * 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)
  23177. * * 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)
  23178. * @returns the VertexData of the Torus Knot
  23179. */
  23180. static CreateTorusKnot(options: {
  23181. radius?: number;
  23182. tube?: number;
  23183. radialSegments?: number;
  23184. tubularSegments?: number;
  23185. p?: number;
  23186. q?: number;
  23187. sideOrientation?: number;
  23188. frontUVs?: Vector4;
  23189. backUVs?: Vector4;
  23190. }): VertexData;
  23191. /**
  23192. * Compute normals for given positions and indices
  23193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23197. * * facetNormals : optional array of facet normals (vector3)
  23198. * * facetPositions : optional array of facet positions (vector3)
  23199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23201. * * bInfo : optional bounding info, required for facetPartitioning computation
  23202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23204. * * useRightHandedSystem: optional boolean to for right handed system computation
  23205. * * depthSort : optional boolean to enable the facet depth sort computation
  23206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23208. */
  23209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23210. facetNormals?: any;
  23211. facetPositions?: any;
  23212. facetPartitioning?: any;
  23213. ratio?: number;
  23214. bInfo?: any;
  23215. bbSize?: Vector3;
  23216. subDiv?: any;
  23217. useRightHandedSystem?: boolean;
  23218. depthSort?: boolean;
  23219. distanceTo?: Vector3;
  23220. depthSortedFacets?: any;
  23221. }): void;
  23222. /** @hidden */
  23223. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23224. /**
  23225. * Applies VertexData created from the imported parameters to the geometry
  23226. * @param parsedVertexData the parsed data from an imported file
  23227. * @param geometry the geometry to apply the VertexData to
  23228. */
  23229. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /**
  23234. * Class containing static functions to help procedurally build meshes
  23235. */
  23236. export class DiscBuilder {
  23237. /**
  23238. * Creates a plane polygonal mesh. By default, this is a disc
  23239. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23240. * * 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
  23241. * * 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
  23242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23243. * * 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
  23244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23245. * @param name defines the name of the mesh
  23246. * @param options defines the options used to create the mesh
  23247. * @param scene defines the hosting scene
  23248. * @returns the plane polygonal mesh
  23249. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23250. */
  23251. static CreateDisc(name: string, options: {
  23252. radius?: number;
  23253. tessellation?: number;
  23254. arc?: number;
  23255. updatable?: boolean;
  23256. sideOrientation?: number;
  23257. frontUVs?: Vector4;
  23258. backUVs?: Vector4;
  23259. }, scene?: Nullable<Scene>): Mesh;
  23260. }
  23261. }
  23262. declare module BABYLON {
  23263. /**
  23264. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23265. *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.
  23266. * The SPS is also a particle system. It provides some methods to manage the particles.
  23267. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23268. *
  23269. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23270. */
  23271. export class SolidParticleSystem implements IDisposable {
  23272. /**
  23273. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23274. * Example : var p = SPS.particles[i];
  23275. */
  23276. particles: SolidParticle[];
  23277. /**
  23278. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23279. */
  23280. nbParticles: number;
  23281. /**
  23282. * If the particles must ever face the camera (default false). Useful for planar particles.
  23283. */
  23284. billboard: boolean;
  23285. /**
  23286. * Recompute normals when adding a shape
  23287. */
  23288. recomputeNormals: boolean;
  23289. /**
  23290. * This a counter ofr your own usage. It's not set by any SPS functions.
  23291. */
  23292. counter: number;
  23293. /**
  23294. * The SPS name. This name is also given to the underlying mesh.
  23295. */
  23296. name: string;
  23297. /**
  23298. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23299. */
  23300. mesh: Mesh;
  23301. /**
  23302. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23303. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23304. */
  23305. vars: any;
  23306. /**
  23307. * This array is populated when the SPS is set as 'pickable'.
  23308. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23309. * Each element of this array is an object `{idx: int, faceId: int}`.
  23310. * `idx` is the picked particle index in the `SPS.particles` array
  23311. * `faceId` is the picked face index counted within this particle.
  23312. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23313. */
  23314. pickedParticles: {
  23315. idx: number;
  23316. faceId: number;
  23317. }[];
  23318. /**
  23319. * This array is populated when `enableDepthSort` is set to true.
  23320. * Each element of this array is an instance of the class DepthSortedParticle.
  23321. */
  23322. depthSortedParticles: DepthSortedParticle[];
  23323. /**
  23324. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23325. * @hidden
  23326. */
  23327. _bSphereOnly: boolean;
  23328. /**
  23329. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23330. * @hidden
  23331. */
  23332. _bSphereRadiusFactor: number;
  23333. private _scene;
  23334. private _positions;
  23335. private _indices;
  23336. private _normals;
  23337. private _colors;
  23338. private _uvs;
  23339. private _indices32;
  23340. private _positions32;
  23341. private _normals32;
  23342. private _fixedNormal32;
  23343. private _colors32;
  23344. private _uvs32;
  23345. private _index;
  23346. private _updatable;
  23347. private _pickable;
  23348. private _isVisibilityBoxLocked;
  23349. private _alwaysVisible;
  23350. private _depthSort;
  23351. private _shapeCounter;
  23352. private _copy;
  23353. private _color;
  23354. private _computeParticleColor;
  23355. private _computeParticleTexture;
  23356. private _computeParticleRotation;
  23357. private _computeParticleVertex;
  23358. private _computeBoundingBox;
  23359. private _depthSortParticles;
  23360. private _camera;
  23361. private _mustUnrotateFixedNormals;
  23362. private _particlesIntersect;
  23363. private _needs32Bits;
  23364. /**
  23365. * Creates a SPS (Solid Particle System) object.
  23366. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23367. * @param scene (Scene) is the scene in which the SPS is added.
  23368. * @param options defines the options of the sps e.g.
  23369. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23370. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23371. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23372. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23373. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23374. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23375. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23376. */
  23377. constructor(name: string, scene: Scene, options?: {
  23378. updatable?: boolean;
  23379. isPickable?: boolean;
  23380. enableDepthSort?: boolean;
  23381. particleIntersection?: boolean;
  23382. boundingSphereOnly?: boolean;
  23383. bSphereRadiusFactor?: number;
  23384. });
  23385. /**
  23386. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23387. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23388. * @returns the created mesh
  23389. */
  23390. buildMesh(): Mesh;
  23391. /**
  23392. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23393. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23394. * Thus the particles generated from `digest()` have their property `position` set yet.
  23395. * @param mesh ( Mesh ) is the mesh to be digested
  23396. * @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
  23397. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23398. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23399. * @returns the current SPS
  23400. */
  23401. digest(mesh: Mesh, options?: {
  23402. facetNb?: number;
  23403. number?: number;
  23404. delta?: number;
  23405. }): SolidParticleSystem;
  23406. private _unrotateFixedNormals;
  23407. private _resetCopy;
  23408. private _meshBuilder;
  23409. private _posToShape;
  23410. private _uvsToShapeUV;
  23411. private _addParticle;
  23412. /**
  23413. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23414. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23415. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23416. * @param nb (positive integer) the number of particles to be created from this model
  23417. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23418. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23419. * @returns the number of shapes in the system
  23420. */
  23421. addShape(mesh: Mesh, nb: number, options?: {
  23422. positionFunction?: any;
  23423. vertexFunction?: any;
  23424. }): number;
  23425. private _rebuildParticle;
  23426. /**
  23427. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23428. * @returns the SPS.
  23429. */
  23430. rebuildMesh(): SolidParticleSystem;
  23431. /**
  23432. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23433. * This method calls `updateParticle()` for each particle of the SPS.
  23434. * For an animated SPS, it is usually called within the render loop.
  23435. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23436. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23437. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23438. * @returns the SPS.
  23439. */
  23440. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23441. /**
  23442. * Disposes the SPS.
  23443. */
  23444. dispose(): void;
  23445. /**
  23446. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23447. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23448. * @returns the SPS.
  23449. */
  23450. refreshVisibleSize(): SolidParticleSystem;
  23451. /**
  23452. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23453. * @param size the size (float) of the visibility box
  23454. * note : this doesn't lock the SPS mesh bounding box.
  23455. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23456. */
  23457. setVisibilityBox(size: number): void;
  23458. /**
  23459. * Gets whether the SPS as always visible or not
  23460. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23461. */
  23462. /**
  23463. * Sets the SPS as always visible or not
  23464. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23465. */
  23466. isAlwaysVisible: boolean;
  23467. /**
  23468. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23470. */
  23471. /**
  23472. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23473. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23474. */
  23475. isVisibilityBoxLocked: boolean;
  23476. /**
  23477. * Tells to `setParticles()` to compute the particle rotations or not.
  23478. * Default value : true. The SPS is faster when it's set to false.
  23479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23480. */
  23481. /**
  23482. * Gets if `setParticles()` computes the particle rotations or not.
  23483. * Default value : true. The SPS is faster when it's set to false.
  23484. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23485. */
  23486. computeParticleRotation: boolean;
  23487. /**
  23488. * Tells to `setParticles()` to compute the particle colors or not.
  23489. * Default value : true. The SPS is faster when it's set to false.
  23490. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23491. */
  23492. /**
  23493. * Gets if `setParticles()` computes the particle colors or not.
  23494. * Default value : true. The SPS is faster when it's set to false.
  23495. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23496. */
  23497. computeParticleColor: boolean;
  23498. /**
  23499. * Gets if `setParticles()` computes the particle textures or not.
  23500. * Default value : true. The SPS is faster when it's set to false.
  23501. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23502. */
  23503. computeParticleTexture: boolean;
  23504. /**
  23505. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23506. * Default value : false. The SPS is faster when it's set to false.
  23507. * Note : the particle custom vertex positions aren't stored values.
  23508. */
  23509. /**
  23510. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23511. * Default value : false. The SPS is faster when it's set to false.
  23512. * Note : the particle custom vertex positions aren't stored values.
  23513. */
  23514. computeParticleVertex: boolean;
  23515. /**
  23516. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23517. */
  23518. /**
  23519. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23520. */
  23521. computeBoundingBox: boolean;
  23522. /**
  23523. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23525. * Default : `true`
  23526. */
  23527. /**
  23528. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23529. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23530. * Default : `true`
  23531. */
  23532. depthSortParticles: boolean;
  23533. /**
  23534. * This function does nothing. It may be overwritten to set all the particle first values.
  23535. * The SPS doesn't call this function, you may have to call it by your own.
  23536. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23537. */
  23538. initParticles(): void;
  23539. /**
  23540. * This function does nothing. It may be overwritten to recycle a particle.
  23541. * The SPS doesn't call this function, you may have to call it by your own.
  23542. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23543. * @param particle The particle to recycle
  23544. * @returns the recycled particle
  23545. */
  23546. recycleParticle(particle: SolidParticle): SolidParticle;
  23547. /**
  23548. * Updates a particle : this function should be overwritten by the user.
  23549. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23550. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23551. * @example : just set a particle position or velocity and recycle conditions
  23552. * @param particle The particle to update
  23553. * @returns the updated particle
  23554. */
  23555. updateParticle(particle: SolidParticle): SolidParticle;
  23556. /**
  23557. * Updates a vertex of a particle : it can be overwritten by the user.
  23558. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23559. * @param particle the current particle
  23560. * @param vertex the current index of the current particle
  23561. * @param pt the index of the current vertex in the particle shape
  23562. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23563. * @example : just set a vertex particle position
  23564. * @returns the updated vertex
  23565. */
  23566. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23567. /**
  23568. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23569. * This does nothing and may be overwritten by the user.
  23570. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23571. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23572. * @param update the boolean update value actually passed to setParticles()
  23573. */
  23574. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23575. /**
  23576. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23577. * This will be passed three parameters.
  23578. * This does nothing and may be overwritten by the user.
  23579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23581. * @param update the boolean update value actually passed to setParticles()
  23582. */
  23583. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23584. }
  23585. }
  23586. declare module BABYLON {
  23587. /**
  23588. * Represents one particle of a solid particle system.
  23589. */
  23590. export class SolidParticle {
  23591. /**
  23592. * particle global index
  23593. */
  23594. idx: number;
  23595. /**
  23596. * The color of the particle
  23597. */
  23598. color: Nullable<Color4>;
  23599. /**
  23600. * The world space position of the particle.
  23601. */
  23602. position: Vector3;
  23603. /**
  23604. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23605. */
  23606. rotation: Vector3;
  23607. /**
  23608. * The world space rotation quaternion of the particle.
  23609. */
  23610. rotationQuaternion: Nullable<Quaternion>;
  23611. /**
  23612. * The scaling of the particle.
  23613. */
  23614. scaling: Vector3;
  23615. /**
  23616. * The uvs of the particle.
  23617. */
  23618. uvs: Vector4;
  23619. /**
  23620. * The current speed of the particle.
  23621. */
  23622. velocity: Vector3;
  23623. /**
  23624. * The pivot point in the particle local space.
  23625. */
  23626. pivot: Vector3;
  23627. /**
  23628. * Must the particle be translated from its pivot point in its local space ?
  23629. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23630. * Default : false
  23631. */
  23632. translateFromPivot: boolean;
  23633. /**
  23634. * Is the particle active or not ?
  23635. */
  23636. alive: boolean;
  23637. /**
  23638. * Is the particle visible or not ?
  23639. */
  23640. isVisible: boolean;
  23641. /**
  23642. * Index of this particle in the global "positions" array (Internal use)
  23643. * @hidden
  23644. */
  23645. _pos: number;
  23646. /**
  23647. * @hidden Index of this particle in the global "indices" array (Internal use)
  23648. */
  23649. _ind: number;
  23650. /**
  23651. * @hidden ModelShape of this particle (Internal use)
  23652. */
  23653. _model: ModelShape;
  23654. /**
  23655. * ModelShape id of this particle
  23656. */
  23657. shapeId: number;
  23658. /**
  23659. * Index of the particle in its shape id (Internal use)
  23660. */
  23661. idxInShape: number;
  23662. /**
  23663. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23664. */
  23665. _modelBoundingInfo: BoundingInfo;
  23666. /**
  23667. * @hidden Particle BoundingInfo object (Internal use)
  23668. */
  23669. _boundingInfo: BoundingInfo;
  23670. /**
  23671. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23672. */
  23673. _sps: SolidParticleSystem;
  23674. /**
  23675. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23676. */
  23677. _stillInvisible: boolean;
  23678. /**
  23679. * @hidden Last computed particle rotation matrix
  23680. */
  23681. _rotationMatrix: number[];
  23682. /**
  23683. * Parent particle Id, if any.
  23684. * Default null.
  23685. */
  23686. parentId: Nullable<number>;
  23687. /**
  23688. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23689. * The possible values are :
  23690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23694. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23695. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23696. * */
  23697. cullingStrategy: number;
  23698. /**
  23699. * @hidden Internal global position in the SPS.
  23700. */
  23701. _globalPosition: Vector3;
  23702. /**
  23703. * Creates a Solid Particle object.
  23704. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23705. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23706. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23707. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23708. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23709. * @param shapeId (integer) is the model shape identifier in the SPS.
  23710. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23711. * @param sps defines the sps it is associated to
  23712. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23713. */
  23714. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23715. /**
  23716. * Legacy support, changed scale to scaling
  23717. */
  23718. /**
  23719. * Legacy support, changed scale to scaling
  23720. */
  23721. scale: Vector3;
  23722. /**
  23723. * Legacy support, changed quaternion to rotationQuaternion
  23724. */
  23725. /**
  23726. * Legacy support, changed quaternion to rotationQuaternion
  23727. */
  23728. quaternion: Nullable<Quaternion>;
  23729. /**
  23730. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23731. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23732. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23733. * @returns true if it intersects
  23734. */
  23735. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23736. /**
  23737. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23738. * A particle is in the frustum if its bounding box intersects the frustum
  23739. * @param frustumPlanes defines the frustum to test
  23740. * @returns true if the particle is in the frustum planes
  23741. */
  23742. isInFrustum(frustumPlanes: Plane[]): boolean;
  23743. /**
  23744. * get the rotation matrix of the particle
  23745. * @hidden
  23746. */
  23747. getRotationMatrix(m: Matrix): void;
  23748. }
  23749. /**
  23750. * Represents the shape of the model used by one particle of a solid particle system.
  23751. * SPS internal tool, don't use it manually.
  23752. */
  23753. export class ModelShape {
  23754. /**
  23755. * The shape id
  23756. * @hidden
  23757. */
  23758. shapeID: number;
  23759. /**
  23760. * flat array of model positions (internal use)
  23761. * @hidden
  23762. */
  23763. _shape: Vector3[];
  23764. /**
  23765. * flat array of model UVs (internal use)
  23766. * @hidden
  23767. */
  23768. _shapeUV: number[];
  23769. /**
  23770. * length of the shape in the model indices array (internal use)
  23771. * @hidden
  23772. */
  23773. _indicesLength: number;
  23774. /**
  23775. * Custom position function (internal use)
  23776. * @hidden
  23777. */
  23778. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23779. /**
  23780. * Custom vertex function (internal use)
  23781. * @hidden
  23782. */
  23783. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23784. /**
  23785. * 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.
  23786. * SPS internal tool, don't use it manually.
  23787. * @hidden
  23788. */
  23789. 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>);
  23790. }
  23791. /**
  23792. * Represents a Depth Sorted Particle in the solid particle system.
  23793. */
  23794. export class DepthSortedParticle {
  23795. /**
  23796. * Index of the particle in the "indices" array
  23797. */
  23798. ind: number;
  23799. /**
  23800. * Length of the particle shape in the "indices" array
  23801. */
  23802. indicesLength: number;
  23803. /**
  23804. * Squared distance from the particle to the camera
  23805. */
  23806. sqDistance: number;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /**
  23811. * Class used to store all common mesh properties
  23812. */
  23813. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23814. /** No occlusion */
  23815. static OCCLUSION_TYPE_NONE: number;
  23816. /** Occlusion set to optimisitic */
  23817. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23818. /** Occlusion set to strict */
  23819. static OCCLUSION_TYPE_STRICT: number;
  23820. /** Use an accurante occlusion algorithm */
  23821. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23822. /** Use a conservative occlusion algorithm */
  23823. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23824. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23825. * Test order :
  23826. * Is the bounding sphere outside the frustum ?
  23827. * If not, are the bounding box vertices outside the frustum ?
  23828. * It not, then the cullable object is in the frustum.
  23829. */
  23830. static readonly CULLINGSTRATEGY_STANDARD: number;
  23831. /** Culling strategy : Bounding Sphere Only.
  23832. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23833. * It's also less accurate than the standard because some not visible objects can still be selected.
  23834. * Test : is the bounding sphere outside the frustum ?
  23835. * If not, then the cullable object is in the frustum.
  23836. */
  23837. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23838. /** Culling strategy : Optimistic Inclusion.
  23839. * This in an inclusion test first, then the standard exclusion test.
  23840. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23841. * 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.
  23842. * Anyway, it's as accurate as the standard strategy.
  23843. * Test :
  23844. * Is the cullable object bounding sphere center in the frustum ?
  23845. * If not, apply the default culling strategy.
  23846. */
  23847. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23848. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23849. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23850. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23851. * 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.
  23852. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23853. * Test :
  23854. * Is the cullable object bounding sphere center in the frustum ?
  23855. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23856. */
  23857. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23858. /**
  23859. * No billboard
  23860. */
  23861. static readonly BILLBOARDMODE_NONE: number;
  23862. /** Billboard on X axis */
  23863. static readonly BILLBOARDMODE_X: number;
  23864. /** Billboard on Y axis */
  23865. static readonly BILLBOARDMODE_Y: number;
  23866. /** Billboard on Z axis */
  23867. static readonly BILLBOARDMODE_Z: number;
  23868. /** Billboard on all axes */
  23869. static readonly BILLBOARDMODE_ALL: number;
  23870. private _facetData;
  23871. /**
  23872. * The culling strategy to use to check whether the mesh must be rendered or not.
  23873. * This value can be changed at any time and will be used on the next render mesh selection.
  23874. * The possible values are :
  23875. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23876. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23878. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23879. * Please read each static variable documentation to get details about the culling process.
  23880. * */
  23881. cullingStrategy: number;
  23882. /**
  23883. * Gets the number of facets in the mesh
  23884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23885. */
  23886. readonly facetNb: number;
  23887. /**
  23888. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23890. */
  23891. partitioningSubdivisions: number;
  23892. /**
  23893. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23894. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23896. */
  23897. partitioningBBoxRatio: number;
  23898. /**
  23899. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23900. * Works only for updatable meshes.
  23901. * Doesn't work with multi-materials
  23902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23903. */
  23904. mustDepthSortFacets: boolean;
  23905. /**
  23906. * The location (Vector3) where the facet depth sort must be computed from.
  23907. * By default, the active camera position.
  23908. * Used only when facet depth sort is enabled
  23909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23910. */
  23911. facetDepthSortFrom: Vector3;
  23912. /**
  23913. * gets a boolean indicating if facetData is enabled
  23914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23915. */
  23916. readonly isFacetDataEnabled: boolean;
  23917. /** @hidden */
  23918. _updateNonUniformScalingState(value: boolean): boolean;
  23919. /**
  23920. * An event triggered when this mesh collides with another one
  23921. */
  23922. onCollideObservable: Observable<AbstractMesh>;
  23923. private _onCollideObserver;
  23924. /** Set a function to call when this mesh collides with another one */
  23925. onCollide: () => void;
  23926. /**
  23927. * An event triggered when the collision's position changes
  23928. */
  23929. onCollisionPositionChangeObservable: Observable<Vector3>;
  23930. private _onCollisionPositionChangeObserver;
  23931. /** Set a function to call when the collision's position changes */
  23932. onCollisionPositionChange: () => void;
  23933. /**
  23934. * An event triggered when material is changed
  23935. */
  23936. onMaterialChangedObservable: Observable<AbstractMesh>;
  23937. /**
  23938. * Gets or sets the orientation for POV movement & rotation
  23939. */
  23940. definedFacingForward: boolean;
  23941. /** @hidden */
  23942. _occlusionQuery: Nullable<WebGLQuery>;
  23943. private _visibility;
  23944. /** @hidden */
  23945. _isActive: boolean;
  23946. /** @hidden */
  23947. _renderingGroup: Nullable<RenderingGroup>;
  23948. /**
  23949. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23950. */
  23951. /**
  23952. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23953. */
  23954. visibility: number;
  23955. /** Gets or sets the alpha index used to sort transparent meshes
  23956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23957. */
  23958. alphaIndex: number;
  23959. /**
  23960. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23961. */
  23962. isVisible: boolean;
  23963. /**
  23964. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23965. */
  23966. isPickable: boolean;
  23967. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23968. showSubMeshesBoundingBox: boolean;
  23969. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23971. */
  23972. isBlocker: boolean;
  23973. /**
  23974. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23975. */
  23976. enablePointerMoveEvents: boolean;
  23977. /**
  23978. * Specifies the rendering group id for this mesh (0 by default)
  23979. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23980. */
  23981. renderingGroupId: number;
  23982. private _material;
  23983. /** Gets or sets current material */
  23984. material: Nullable<Material>;
  23985. private _receiveShadows;
  23986. /**
  23987. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23988. * @see http://doc.babylonjs.com/babylon101/shadows
  23989. */
  23990. receiveShadows: boolean;
  23991. /** Defines color to use when rendering outline */
  23992. outlineColor: Color3;
  23993. /** Define width to use when rendering outline */
  23994. outlineWidth: number;
  23995. /** Defines color to use when rendering overlay */
  23996. overlayColor: Color3;
  23997. /** Defines alpha to use when rendering overlay */
  23998. overlayAlpha: number;
  23999. private _hasVertexAlpha;
  24000. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24001. hasVertexAlpha: boolean;
  24002. private _useVertexColors;
  24003. /** 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) */
  24004. useVertexColors: boolean;
  24005. private _computeBonesUsingShaders;
  24006. /**
  24007. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24008. */
  24009. computeBonesUsingShaders: boolean;
  24010. private _numBoneInfluencers;
  24011. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24012. numBoneInfluencers: number;
  24013. private _applyFog;
  24014. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24015. applyFog: boolean;
  24016. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24017. useOctreeForRenderingSelection: boolean;
  24018. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24019. useOctreeForPicking: boolean;
  24020. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24021. useOctreeForCollisions: boolean;
  24022. private _layerMask;
  24023. /**
  24024. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24025. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24026. */
  24027. layerMask: number;
  24028. /**
  24029. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24030. */
  24031. alwaysSelectAsActiveMesh: boolean;
  24032. /**
  24033. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24034. */
  24035. doNotSyncBoundingInfo: boolean;
  24036. /**
  24037. * Gets or sets the current action manager
  24038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24039. */
  24040. actionManager: Nullable<AbstractActionManager>;
  24041. private _checkCollisions;
  24042. private _collisionMask;
  24043. private _collisionGroup;
  24044. /**
  24045. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24046. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24047. */
  24048. ellipsoid: Vector3;
  24049. /**
  24050. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24051. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24052. */
  24053. ellipsoidOffset: Vector3;
  24054. private _collider;
  24055. private _oldPositionForCollisions;
  24056. private _diffPositionForCollisions;
  24057. /**
  24058. * Gets or sets a collision mask used to mask collisions (default is -1).
  24059. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24060. */
  24061. collisionMask: number;
  24062. /**
  24063. * Gets or sets the current collision group mask (-1 by default).
  24064. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24065. */
  24066. collisionGroup: number;
  24067. /**
  24068. * Defines edge width used when edgesRenderer is enabled
  24069. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24070. */
  24071. edgesWidth: number;
  24072. /**
  24073. * Defines edge color used when edgesRenderer is enabled
  24074. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24075. */
  24076. edgesColor: Color4;
  24077. /** @hidden */
  24078. _edgesRenderer: Nullable<IEdgesRenderer>;
  24079. /** @hidden */
  24080. _masterMesh: Nullable<AbstractMesh>;
  24081. /** @hidden */
  24082. _boundingInfo: Nullable<BoundingInfo>;
  24083. /** @hidden */
  24084. _renderId: number;
  24085. /**
  24086. * Gets or sets the list of subMeshes
  24087. * @see http://doc.babylonjs.com/how_to/multi_materials
  24088. */
  24089. subMeshes: SubMesh[];
  24090. /** @hidden */
  24091. _intersectionsInProgress: AbstractMesh[];
  24092. /** @hidden */
  24093. _unIndexed: boolean;
  24094. /** @hidden */
  24095. _lightSources: Light[];
  24096. /** @hidden */
  24097. readonly _positions: Nullable<Vector3[]>;
  24098. /** @hidden */
  24099. _waitingActions: Nullable<any>;
  24100. /** @hidden */
  24101. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24102. private _skeleton;
  24103. /** @hidden */
  24104. _bonesTransformMatrices: Nullable<Float32Array>;
  24105. /**
  24106. * Gets or sets a skeleton to apply skining transformations
  24107. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24108. */
  24109. skeleton: Nullable<Skeleton>;
  24110. /**
  24111. * An event triggered when the mesh is rebuilt.
  24112. */
  24113. onRebuildObservable: Observable<AbstractMesh>;
  24114. /**
  24115. * Creates a new AbstractMesh
  24116. * @param name defines the name of the mesh
  24117. * @param scene defines the hosting scene
  24118. */
  24119. constructor(name: string, scene?: Nullable<Scene>);
  24120. /**
  24121. * Returns the string "AbstractMesh"
  24122. * @returns "AbstractMesh"
  24123. */
  24124. getClassName(): string;
  24125. /**
  24126. * Gets a string representation of the current mesh
  24127. * @param fullDetails defines a boolean indicating if full details must be included
  24128. * @returns a string representation of the current mesh
  24129. */
  24130. toString(fullDetails?: boolean): string;
  24131. /**
  24132. * @hidden
  24133. */
  24134. protected _getEffectiveParent(): Nullable<Node>;
  24135. /** @hidden */
  24136. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24137. /** @hidden */
  24138. _rebuild(): void;
  24139. /** @hidden */
  24140. _resyncLightSources(): void;
  24141. /** @hidden */
  24142. _resyncLighSource(light: Light): void;
  24143. /** @hidden */
  24144. _unBindEffect(): void;
  24145. /** @hidden */
  24146. _removeLightSource(light: Light): void;
  24147. private _markSubMeshesAsDirty;
  24148. /** @hidden */
  24149. _markSubMeshesAsLightDirty(): void;
  24150. /** @hidden */
  24151. _markSubMeshesAsAttributesDirty(): void;
  24152. /** @hidden */
  24153. _markSubMeshesAsMiscDirty(): void;
  24154. /**
  24155. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24156. */
  24157. scaling: Vector3;
  24158. /**
  24159. * Returns true if the mesh is blocked. Implemented by child classes
  24160. */
  24161. readonly isBlocked: boolean;
  24162. /**
  24163. * Returns the mesh itself by default. Implemented by child classes
  24164. * @param camera defines the camera to use to pick the right LOD level
  24165. * @returns the currentAbstractMesh
  24166. */
  24167. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24168. /**
  24169. * Returns 0 by default. Implemented by child classes
  24170. * @returns an integer
  24171. */
  24172. getTotalVertices(): number;
  24173. /**
  24174. * Returns a positive integer : the total number of indices in this mesh geometry.
  24175. * @returns the numner of indices or zero if the mesh has no geometry.
  24176. */
  24177. getTotalIndices(): number;
  24178. /**
  24179. * Returns null by default. Implemented by child classes
  24180. * @returns null
  24181. */
  24182. getIndices(): Nullable<IndicesArray>;
  24183. /**
  24184. * Returns the array of the requested vertex data kind. Implemented by child classes
  24185. * @param kind defines the vertex data kind to use
  24186. * @returns null
  24187. */
  24188. getVerticesData(kind: string): Nullable<FloatArray>;
  24189. /**
  24190. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24191. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24192. * Note that a new underlying VertexBuffer object is created each call.
  24193. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24194. * @param kind defines vertex data kind:
  24195. * * VertexBuffer.PositionKind
  24196. * * VertexBuffer.UVKind
  24197. * * VertexBuffer.UV2Kind
  24198. * * VertexBuffer.UV3Kind
  24199. * * VertexBuffer.UV4Kind
  24200. * * VertexBuffer.UV5Kind
  24201. * * VertexBuffer.UV6Kind
  24202. * * VertexBuffer.ColorKind
  24203. * * VertexBuffer.MatricesIndicesKind
  24204. * * VertexBuffer.MatricesIndicesExtraKind
  24205. * * VertexBuffer.MatricesWeightsKind
  24206. * * VertexBuffer.MatricesWeightsExtraKind
  24207. * @param data defines the data source
  24208. * @param updatable defines if the data must be flagged as updatable (or static)
  24209. * @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
  24210. * @returns the current mesh
  24211. */
  24212. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24213. /**
  24214. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24215. * If the mesh has no geometry, it is simply returned as it is.
  24216. * @param kind defines vertex data kind:
  24217. * * VertexBuffer.PositionKind
  24218. * * VertexBuffer.UVKind
  24219. * * VertexBuffer.UV2Kind
  24220. * * VertexBuffer.UV3Kind
  24221. * * VertexBuffer.UV4Kind
  24222. * * VertexBuffer.UV5Kind
  24223. * * VertexBuffer.UV6Kind
  24224. * * VertexBuffer.ColorKind
  24225. * * VertexBuffer.MatricesIndicesKind
  24226. * * VertexBuffer.MatricesIndicesExtraKind
  24227. * * VertexBuffer.MatricesWeightsKind
  24228. * * VertexBuffer.MatricesWeightsExtraKind
  24229. * @param data defines the data source
  24230. * @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
  24231. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24232. * @returns the current mesh
  24233. */
  24234. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24235. /**
  24236. * Sets the mesh indices,
  24237. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24238. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24239. * @param totalVertices Defines the total number of vertices
  24240. * @returns the current mesh
  24241. */
  24242. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24243. /**
  24244. * Gets a boolean indicating if specific vertex data is present
  24245. * @param kind defines the vertex data kind to use
  24246. * @returns true is data kind is present
  24247. */
  24248. isVerticesDataPresent(kind: string): boolean;
  24249. /**
  24250. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24251. * @returns a BoundingInfo
  24252. */
  24253. getBoundingInfo(): BoundingInfo;
  24254. /**
  24255. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24256. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24257. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24258. * @returns the current mesh
  24259. */
  24260. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24261. /**
  24262. * Overwrite the current bounding info
  24263. * @param boundingInfo defines the new bounding info
  24264. * @returns the current mesh
  24265. */
  24266. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24267. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24268. readonly useBones: boolean;
  24269. /** @hidden */
  24270. _preActivate(): void;
  24271. /** @hidden */
  24272. _preActivateForIntermediateRendering(renderId: number): void;
  24273. /** @hidden */
  24274. _activate(renderId: number): boolean;
  24275. /** @hidden */
  24276. _freeze(): void;
  24277. /** @hidden */
  24278. _unFreeze(): void;
  24279. /**
  24280. * Gets the current world matrix
  24281. * @returns a Matrix
  24282. */
  24283. getWorldMatrix(): Matrix;
  24284. /** @hidden */
  24285. _getWorldMatrixDeterminant(): number;
  24286. /**
  24287. * Perform relative position change from the point of view of behind the front of the mesh.
  24288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24289. * Supports definition of mesh facing forward or backward
  24290. * @param amountRight defines the distance on the right axis
  24291. * @param amountUp defines the distance on the up axis
  24292. * @param amountForward defines the distance on the forward axis
  24293. * @returns the current mesh
  24294. */
  24295. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24296. /**
  24297. * Calculate relative position change from the point of view of behind the front of the mesh.
  24298. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24299. * Supports definition of mesh facing forward or backward
  24300. * @param amountRight defines the distance on the right axis
  24301. * @param amountUp defines the distance on the up axis
  24302. * @param amountForward defines the distance on the forward axis
  24303. * @returns the new displacement vector
  24304. */
  24305. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24306. /**
  24307. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24308. * Supports definition of mesh facing forward or backward
  24309. * @param flipBack defines the flip
  24310. * @param twirlClockwise defines the twirl
  24311. * @param tiltRight defines the tilt
  24312. * @returns the current mesh
  24313. */
  24314. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24315. /**
  24316. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24317. * Supports definition of mesh facing forward or backward.
  24318. * @param flipBack defines the flip
  24319. * @param twirlClockwise defines the twirl
  24320. * @param tiltRight defines the tilt
  24321. * @returns the new rotation vector
  24322. */
  24323. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24324. /**
  24325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24326. * This means the mesh underlying bounding box and sphere are recomputed.
  24327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24328. * @returns the current mesh
  24329. */
  24330. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24331. /** @hidden */
  24332. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24333. /** @hidden */
  24334. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24335. /** @hidden */
  24336. _updateBoundingInfo(): AbstractMesh;
  24337. /** @hidden */
  24338. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24339. /** @hidden */
  24340. protected _afterComputeWorldMatrix(): void;
  24341. /** @hidden */
  24342. readonly _effectiveMesh: AbstractMesh;
  24343. /**
  24344. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24345. * A mesh is in the frustum if its bounding box intersects the frustum
  24346. * @param frustumPlanes defines the frustum to test
  24347. * @returns true if the mesh is in the frustum planes
  24348. */
  24349. isInFrustum(frustumPlanes: Plane[]): boolean;
  24350. /**
  24351. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24352. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24353. * @param frustumPlanes defines the frustum to test
  24354. * @returns true if the mesh is completely in the frustum planes
  24355. */
  24356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24357. /**
  24358. * True if the mesh intersects another mesh or a SolidParticle object
  24359. * @param mesh defines a target mesh or SolidParticle to test
  24360. * @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)
  24361. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24362. * @returns true if there is an intersection
  24363. */
  24364. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24365. /**
  24366. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24367. * @param point defines the point to test
  24368. * @returns true if there is an intersection
  24369. */
  24370. intersectsPoint(point: Vector3): boolean;
  24371. /**
  24372. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24374. */
  24375. checkCollisions: boolean;
  24376. /**
  24377. * Gets Collider object used to compute collisions (not physics)
  24378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24379. */
  24380. readonly collider: Nullable<Collider>;
  24381. /**
  24382. * Move the mesh using collision engine
  24383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24384. * @param displacement defines the requested displacement vector
  24385. * @returns the current mesh
  24386. */
  24387. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24388. private _onCollisionPositionChange;
  24389. /** @hidden */
  24390. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24391. /** @hidden */
  24392. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24393. /** @hidden */
  24394. _checkCollision(collider: Collider): AbstractMesh;
  24395. /** @hidden */
  24396. _generatePointsArray(): boolean;
  24397. /**
  24398. * Checks if the passed Ray intersects with the mesh
  24399. * @param ray defines the ray to use
  24400. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24402. * @returns the picking info
  24403. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24404. */
  24405. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24406. /**
  24407. * Clones the current mesh
  24408. * @param name defines the mesh name
  24409. * @param newParent defines the new mesh parent
  24410. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24411. * @returns the new mesh
  24412. */
  24413. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24414. /**
  24415. * Disposes all the submeshes of the current meshnp
  24416. * @returns the current mesh
  24417. */
  24418. releaseSubMeshes(): AbstractMesh;
  24419. /**
  24420. * Releases resources associated with this abstract mesh.
  24421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24423. */
  24424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24425. /**
  24426. * Adds the passed mesh as a child to the current mesh
  24427. * @param mesh defines the child mesh
  24428. * @returns the current mesh
  24429. */
  24430. addChild(mesh: AbstractMesh): AbstractMesh;
  24431. /**
  24432. * Removes the passed mesh from the current mesh children list
  24433. * @param mesh defines the child mesh
  24434. * @returns the current mesh
  24435. */
  24436. removeChild(mesh: AbstractMesh): AbstractMesh;
  24437. /** @hidden */
  24438. private _initFacetData;
  24439. /**
  24440. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24441. * This method can be called within the render loop.
  24442. * 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
  24443. * @returns the current mesh
  24444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24445. */
  24446. updateFacetData(): AbstractMesh;
  24447. /**
  24448. * Returns the facetLocalNormals array.
  24449. * The normals are expressed in the mesh local spac
  24450. * @returns an array of Vector3
  24451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24452. */
  24453. getFacetLocalNormals(): Vector3[];
  24454. /**
  24455. * Returns the facetLocalPositions array.
  24456. * The facet positions are expressed in the mesh local space
  24457. * @returns an array of Vector3
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getFacetLocalPositions(): Vector3[];
  24461. /**
  24462. * Returns the facetLocalPartioning array
  24463. * @returns an array of array of numbers
  24464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24465. */
  24466. getFacetLocalPartitioning(): number[][];
  24467. /**
  24468. * Returns the i-th facet position in the world system.
  24469. * This method allocates a new Vector3 per call
  24470. * @param i defines the facet index
  24471. * @returns a new Vector3
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24473. */
  24474. getFacetPosition(i: number): Vector3;
  24475. /**
  24476. * Sets the reference Vector3 with the i-th facet position in the world system
  24477. * @param i defines the facet index
  24478. * @param ref defines the target vector
  24479. * @returns the current mesh
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24481. */
  24482. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24483. /**
  24484. * Returns the i-th facet normal in the world system.
  24485. * This method allocates a new Vector3 per call
  24486. * @param i defines the facet index
  24487. * @returns a new Vector3
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getFacetNormal(i: number): Vector3;
  24491. /**
  24492. * Sets the reference Vector3 with the i-th facet normal in the world system
  24493. * @param i defines the facet index
  24494. * @param ref defines the target vector
  24495. * @returns the current mesh
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24497. */
  24498. getFacetNormalToRef(i: number, ref: Vector3): this;
  24499. /**
  24500. * 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)
  24501. * @param x defines x coordinate
  24502. * @param y defines y coordinate
  24503. * @param z defines z coordinate
  24504. * @returns the array of facet indexes
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24506. */
  24507. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24508. /**
  24509. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24510. * @param projected sets as the (x,y,z) world projection on the facet
  24511. * @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
  24512. * @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
  24513. * @param x defines x coordinate
  24514. * @param y defines y coordinate
  24515. * @param z defines z coordinate
  24516. * @returns the face index if found (or null instead)
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24520. /**
  24521. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24522. * @param projected sets as the (x,y,z) local projection on the facet
  24523. * @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
  24524. * @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
  24525. * @param x defines x coordinate
  24526. * @param y defines y coordinate
  24527. * @param z defines z coordinate
  24528. * @returns the face index if found (or null instead)
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24530. */
  24531. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24532. /**
  24533. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24534. * @returns the parameters
  24535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24536. */
  24537. getFacetDataParameters(): any;
  24538. /**
  24539. * Disables the feature FacetData and frees the related memory
  24540. * @returns the current mesh
  24541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24542. */
  24543. disableFacetData(): AbstractMesh;
  24544. /**
  24545. * Updates the AbstractMesh indices array
  24546. * @param indices defines the data source
  24547. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24548. * @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)
  24549. * @returns the current mesh
  24550. */
  24551. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24552. /**
  24553. * Creates new normals data for the mesh
  24554. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24555. * @returns the current mesh
  24556. */
  24557. createNormals(updatable: boolean): AbstractMesh;
  24558. /**
  24559. * Align the mesh with a normal
  24560. * @param normal defines the normal to use
  24561. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24562. * @returns the current mesh
  24563. */
  24564. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24565. /** @hidden */
  24566. _checkOcclusionQuery(): boolean;
  24567. }
  24568. }
  24569. declare module BABYLON {
  24570. /**
  24571. * Interface used to define ActionEvent
  24572. */
  24573. export interface IActionEvent {
  24574. /** The mesh or sprite that triggered the action */
  24575. source: any;
  24576. /** The X mouse cursor position at the time of the event */
  24577. pointerX: number;
  24578. /** The Y mouse cursor position at the time of the event */
  24579. pointerY: number;
  24580. /** The mesh that is currently pointed at (can be null) */
  24581. meshUnderPointer: Nullable<AbstractMesh>;
  24582. /** the original (browser) event that triggered the ActionEvent */
  24583. sourceEvent?: any;
  24584. /** additional data for the event */
  24585. additionalData?: any;
  24586. }
  24587. /**
  24588. * ActionEvent is the event being sent when an action is triggered.
  24589. */
  24590. export class ActionEvent implements IActionEvent {
  24591. /** The mesh or sprite that triggered the action */
  24592. source: any;
  24593. /** The X mouse cursor position at the time of the event */
  24594. pointerX: number;
  24595. /** The Y mouse cursor position at the time of the event */
  24596. pointerY: number;
  24597. /** The mesh that is currently pointed at (can be null) */
  24598. meshUnderPointer: Nullable<AbstractMesh>;
  24599. /** the original (browser) event that triggered the ActionEvent */
  24600. sourceEvent?: any;
  24601. /** additional data for the event */
  24602. additionalData?: any;
  24603. /**
  24604. * Creates a new ActionEvent
  24605. * @param source The mesh or sprite that triggered the action
  24606. * @param pointerX The X mouse cursor position at the time of the event
  24607. * @param pointerY The Y mouse cursor position at the time of the event
  24608. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24609. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24610. * @param additionalData additional data for the event
  24611. */
  24612. constructor(
  24613. /** The mesh or sprite that triggered the action */
  24614. source: any,
  24615. /** The X mouse cursor position at the time of the event */
  24616. pointerX: number,
  24617. /** The Y mouse cursor position at the time of the event */
  24618. pointerY: number,
  24619. /** The mesh that is currently pointed at (can be null) */
  24620. meshUnderPointer: Nullable<AbstractMesh>,
  24621. /** the original (browser) event that triggered the ActionEvent */
  24622. sourceEvent?: any,
  24623. /** additional data for the event */
  24624. additionalData?: any);
  24625. /**
  24626. * Helper function to auto-create an ActionEvent from a source mesh.
  24627. * @param source The source mesh that triggered the event
  24628. * @param evt The original (browser) event
  24629. * @param additionalData additional data for the event
  24630. * @returns the new ActionEvent
  24631. */
  24632. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24633. /**
  24634. * Helper function to auto-create an ActionEvent from a source sprite
  24635. * @param source The source sprite that triggered the event
  24636. * @param scene Scene associated with the sprite
  24637. * @param evt The original (browser) event
  24638. * @param additionalData additional data for the event
  24639. * @returns the new ActionEvent
  24640. */
  24641. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24642. /**
  24643. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24644. * @param scene the scene where the event occurred
  24645. * @param evt The original (browser) event
  24646. * @returns the new ActionEvent
  24647. */
  24648. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24649. /**
  24650. * Helper function to auto-create an ActionEvent from a primitive
  24651. * @param prim defines the target primitive
  24652. * @param pointerPos defines the pointer position
  24653. * @param evt The original (browser) event
  24654. * @param additionalData additional data for the event
  24655. * @returns the new ActionEvent
  24656. */
  24657. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24658. }
  24659. }
  24660. declare module BABYLON {
  24661. /**
  24662. * Abstract class used to decouple action Manager from scene and meshes.
  24663. * Do not instantiate.
  24664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24665. */
  24666. export abstract class AbstractActionManager implements IDisposable {
  24667. /** Gets the list of active triggers */
  24668. static Triggers: {
  24669. [key: string]: number;
  24670. };
  24671. /** Gets the cursor to use when hovering items */
  24672. hoverCursor: string;
  24673. /** Gets the list of actions */
  24674. actions: IAction[];
  24675. /**
  24676. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24677. */
  24678. isRecursive: boolean;
  24679. /**
  24680. * Releases all associated resources
  24681. */
  24682. abstract dispose(): void;
  24683. /**
  24684. * Does this action manager has pointer triggers
  24685. */
  24686. abstract readonly hasPointerTriggers: boolean;
  24687. /**
  24688. * Does this action manager has pick triggers
  24689. */
  24690. abstract readonly hasPickTriggers: boolean;
  24691. /**
  24692. * Process a specific trigger
  24693. * @param trigger defines the trigger to process
  24694. * @param evt defines the event details to be processed
  24695. */
  24696. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24697. /**
  24698. * Does this action manager handles actions of any of the given triggers
  24699. * @param triggers defines the triggers to be tested
  24700. * @return a boolean indicating whether one (or more) of the triggers is handled
  24701. */
  24702. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24703. /**
  24704. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24705. * speed.
  24706. * @param triggerA defines the trigger to be tested
  24707. * @param triggerB defines the trigger to be tested
  24708. * @return a boolean indicating whether one (or more) of the triggers is handled
  24709. */
  24710. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24711. /**
  24712. * Does this action manager handles actions of a given trigger
  24713. * @param trigger defines the trigger to be tested
  24714. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24715. * @return whether the trigger is handled
  24716. */
  24717. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24718. /**
  24719. * Serialize this manager to a JSON object
  24720. * @param name defines the property name to store this manager
  24721. * @returns a JSON representation of this manager
  24722. */
  24723. abstract serialize(name: string): any;
  24724. /**
  24725. * Registers an action to this action manager
  24726. * @param action defines the action to be registered
  24727. * @return the action amended (prepared) after registration
  24728. */
  24729. abstract registerAction(action: IAction): Nullable<IAction>;
  24730. /**
  24731. * Unregisters an action to this action manager
  24732. * @param action defines the action to be unregistered
  24733. * @return a boolean indicating whether the action has been unregistered
  24734. */
  24735. abstract unregisterAction(action: IAction): Boolean;
  24736. /**
  24737. * Does exist one action manager with at least one trigger
  24738. **/
  24739. static readonly HasTriggers: boolean;
  24740. /**
  24741. * Does exist one action manager with at least one pick trigger
  24742. **/
  24743. static readonly HasPickTriggers: boolean;
  24744. /**
  24745. * Does exist one action manager that handles actions of a given trigger
  24746. * @param trigger defines the trigger to be tested
  24747. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24748. **/
  24749. static HasSpecificTrigger(trigger: number): boolean;
  24750. }
  24751. }
  24752. declare module BABYLON {
  24753. /**
  24754. * Defines how a node can be built from a string name.
  24755. */
  24756. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24757. /**
  24758. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24759. */
  24760. export class Node implements IBehaviorAware<Node> {
  24761. /** @hidden */
  24762. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24763. private static _NodeConstructors;
  24764. /**
  24765. * Add a new node constructor
  24766. * @param type defines the type name of the node to construct
  24767. * @param constructorFunc defines the constructor function
  24768. */
  24769. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24770. /**
  24771. * Returns a node constructor based on type name
  24772. * @param type defines the type name
  24773. * @param name defines the new node name
  24774. * @param scene defines the hosting scene
  24775. * @param options defines optional options to transmit to constructors
  24776. * @returns the new constructor or null
  24777. */
  24778. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24779. /**
  24780. * Gets or sets the name of the node
  24781. */
  24782. name: string;
  24783. /**
  24784. * Gets or sets the id of the node
  24785. */
  24786. id: string;
  24787. /**
  24788. * Gets or sets the unique id of the node
  24789. */
  24790. uniqueId: number;
  24791. /**
  24792. * Gets or sets a string used to store user defined state for the node
  24793. */
  24794. state: string;
  24795. /**
  24796. * Gets or sets an object used to store user defined information for the node
  24797. */
  24798. metadata: any;
  24799. /**
  24800. * For internal use only. Please do not use.
  24801. */
  24802. reservedDataStore: any;
  24803. /**
  24804. * List of inspectable custom properties (used by the Inspector)
  24805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24806. */
  24807. inspectableCustomProperties: IInspectable[];
  24808. /**
  24809. * Gets or sets a boolean used to define if the node must be serialized
  24810. */
  24811. doNotSerialize: boolean;
  24812. /** @hidden */
  24813. _isDisposed: boolean;
  24814. /**
  24815. * Gets a list of Animations associated with the node
  24816. */
  24817. animations: Animation[];
  24818. protected _ranges: {
  24819. [name: string]: Nullable<AnimationRange>;
  24820. };
  24821. /**
  24822. * Callback raised when the node is ready to be used
  24823. */
  24824. onReady: Nullable<(node: Node) => void>;
  24825. private _isEnabled;
  24826. private _isParentEnabled;
  24827. private _isReady;
  24828. /** @hidden */
  24829. _currentRenderId: number;
  24830. private _parentUpdateId;
  24831. /** @hidden */
  24832. _childUpdateId: number;
  24833. /** @hidden */
  24834. _waitingParentId: Nullable<string>;
  24835. /** @hidden */
  24836. _scene: Scene;
  24837. /** @hidden */
  24838. _cache: any;
  24839. private _parentNode;
  24840. private _children;
  24841. /** @hidden */
  24842. _worldMatrix: Matrix;
  24843. /** @hidden */
  24844. _worldMatrixDeterminant: number;
  24845. /** @hidden */
  24846. _worldMatrixDeterminantIsDirty: boolean;
  24847. /** @hidden */
  24848. private _sceneRootNodesIndex;
  24849. /**
  24850. * Gets a boolean indicating if the node has been disposed
  24851. * @returns true if the node was disposed
  24852. */
  24853. isDisposed(): boolean;
  24854. /**
  24855. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24856. * @see https://doc.babylonjs.com/how_to/parenting
  24857. */
  24858. parent: Nullable<Node>;
  24859. private addToSceneRootNodes;
  24860. private removeFromSceneRootNodes;
  24861. private _animationPropertiesOverride;
  24862. /**
  24863. * Gets or sets the animation properties override
  24864. */
  24865. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24866. /**
  24867. * Gets a string idenfifying the name of the class
  24868. * @returns "Node" string
  24869. */
  24870. getClassName(): string;
  24871. /** @hidden */
  24872. readonly _isNode: boolean;
  24873. /**
  24874. * An event triggered when the mesh is disposed
  24875. */
  24876. onDisposeObservable: Observable<Node>;
  24877. private _onDisposeObserver;
  24878. /**
  24879. * Sets a callback that will be raised when the node will be disposed
  24880. */
  24881. onDispose: () => void;
  24882. /**
  24883. * Creates a new Node
  24884. * @param name the name and id to be given to this node
  24885. * @param scene the scene this node will be added to
  24886. * @param addToRootNodes the node will be added to scene.rootNodes
  24887. */
  24888. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24889. /**
  24890. * Gets the scene of the node
  24891. * @returns a scene
  24892. */
  24893. getScene(): Scene;
  24894. /**
  24895. * Gets the engine of the node
  24896. * @returns a Engine
  24897. */
  24898. getEngine(): Engine;
  24899. private _behaviors;
  24900. /**
  24901. * Attach a behavior to the node
  24902. * @see http://doc.babylonjs.com/features/behaviour
  24903. * @param behavior defines the behavior to attach
  24904. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24905. * @returns the current Node
  24906. */
  24907. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24908. /**
  24909. * Remove an attached behavior
  24910. * @see http://doc.babylonjs.com/features/behaviour
  24911. * @param behavior defines the behavior to attach
  24912. * @returns the current Node
  24913. */
  24914. removeBehavior(behavior: Behavior<Node>): Node;
  24915. /**
  24916. * Gets the list of attached behaviors
  24917. * @see http://doc.babylonjs.com/features/behaviour
  24918. */
  24919. readonly behaviors: Behavior<Node>[];
  24920. /**
  24921. * Gets an attached behavior by name
  24922. * @param name defines the name of the behavior to look for
  24923. * @see http://doc.babylonjs.com/features/behaviour
  24924. * @returns null if behavior was not found else the requested behavior
  24925. */
  24926. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24927. /**
  24928. * Returns the latest update of the World matrix
  24929. * @returns a Matrix
  24930. */
  24931. getWorldMatrix(): Matrix;
  24932. /** @hidden */
  24933. _getWorldMatrixDeterminant(): number;
  24934. /**
  24935. * Returns directly the latest state of the mesh World matrix.
  24936. * A Matrix is returned.
  24937. */
  24938. readonly worldMatrixFromCache: Matrix;
  24939. /** @hidden */
  24940. _initCache(): void;
  24941. /** @hidden */
  24942. updateCache(force?: boolean): void;
  24943. /** @hidden */
  24944. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24945. /** @hidden */
  24946. _updateCache(ignoreParentClass?: boolean): void;
  24947. /** @hidden */
  24948. _isSynchronized(): boolean;
  24949. /** @hidden */
  24950. _markSyncedWithParent(): void;
  24951. /** @hidden */
  24952. isSynchronizedWithParent(): boolean;
  24953. /** @hidden */
  24954. isSynchronized(): boolean;
  24955. /**
  24956. * Is this node ready to be used/rendered
  24957. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24958. * @return true if the node is ready
  24959. */
  24960. isReady(completeCheck?: boolean): boolean;
  24961. /**
  24962. * Is this node enabled?
  24963. * 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
  24964. * @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
  24965. * @return whether this node (and its parent) is enabled
  24966. */
  24967. isEnabled(checkAncestors?: boolean): boolean;
  24968. /** @hidden */
  24969. protected _syncParentEnabledState(): void;
  24970. /**
  24971. * Set the enabled state of this node
  24972. * @param value defines the new enabled state
  24973. */
  24974. setEnabled(value: boolean): void;
  24975. /**
  24976. * Is this node a descendant of the given node?
  24977. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24978. * @param ancestor defines the parent node to inspect
  24979. * @returns a boolean indicating if this node is a descendant of the given node
  24980. */
  24981. isDescendantOf(ancestor: Node): boolean;
  24982. /** @hidden */
  24983. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24984. /**
  24985. * Will return all nodes that have this node as ascendant
  24986. * @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
  24987. * @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
  24988. * @return all children nodes of all types
  24989. */
  24990. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24991. /**
  24992. * Get all child-meshes of this node
  24993. * @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)
  24994. * @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
  24995. * @returns an array of AbstractMesh
  24996. */
  24997. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24998. /**
  24999. * Get all direct children of this node
  25000. * @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
  25001. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  25002. * @returns an array of Node
  25003. */
  25004. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25005. /** @hidden */
  25006. _setReady(state: boolean): void;
  25007. /**
  25008. * Get an animation by name
  25009. * @param name defines the name of the animation to look for
  25010. * @returns null if not found else the requested animation
  25011. */
  25012. getAnimationByName(name: string): Nullable<Animation>;
  25013. /**
  25014. * Creates an animation range for this node
  25015. * @param name defines the name of the range
  25016. * @param from defines the starting key
  25017. * @param to defines the end key
  25018. */
  25019. createAnimationRange(name: string, from: number, to: number): void;
  25020. /**
  25021. * Delete a specific animation range
  25022. * @param name defines the name of the range to delete
  25023. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25024. */
  25025. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25026. /**
  25027. * Get an animation range by name
  25028. * @param name defines the name of the animation range to look for
  25029. * @returns null if not found else the requested animation range
  25030. */
  25031. getAnimationRange(name: string): Nullable<AnimationRange>;
  25032. /**
  25033. * Gets the list of all animation ranges defined on this node
  25034. * @returns an array
  25035. */
  25036. getAnimationRanges(): Nullable<AnimationRange>[];
  25037. /**
  25038. * Will start the animation sequence
  25039. * @param name defines the range frames for animation sequence
  25040. * @param loop defines if the animation should loop (false by default)
  25041. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25042. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25043. * @returns the object created for this animation. If range does not exist, it will return null
  25044. */
  25045. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25046. /**
  25047. * Serialize animation ranges into a JSON compatible object
  25048. * @returns serialization object
  25049. */
  25050. serializeAnimationRanges(): any;
  25051. /**
  25052. * Computes the world matrix of the node
  25053. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25054. * @returns the world matrix
  25055. */
  25056. computeWorldMatrix(force?: boolean): Matrix;
  25057. /**
  25058. * Releases resources associated with this node.
  25059. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25060. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25061. */
  25062. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25063. /**
  25064. * Parse animation range data from a serialization object and store them into a given node
  25065. * @param node defines where to store the animation ranges
  25066. * @param parsedNode defines the serialization object to read data from
  25067. * @param scene defines the hosting scene
  25068. */
  25069. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25070. /**
  25071. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25072. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25073. * @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
  25074. * @returns the new bounding vectors
  25075. */
  25076. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25077. min: Vector3;
  25078. max: Vector3;
  25079. };
  25080. }
  25081. }
  25082. declare module BABYLON {
  25083. /**
  25084. * @hidden
  25085. */
  25086. export class _IAnimationState {
  25087. key: number;
  25088. repeatCount: number;
  25089. workValue?: any;
  25090. loopMode?: number;
  25091. offsetValue?: any;
  25092. highLimitValue?: any;
  25093. }
  25094. /**
  25095. * Class used to store any kind of animation
  25096. */
  25097. export class Animation {
  25098. /**Name of the animation */
  25099. name: string;
  25100. /**Property to animate */
  25101. targetProperty: string;
  25102. /**The frames per second of the animation */
  25103. framePerSecond: number;
  25104. /**The data type of the animation */
  25105. dataType: number;
  25106. /**The loop mode of the animation */
  25107. loopMode?: number | undefined;
  25108. /**Specifies if blending should be enabled */
  25109. enableBlending?: boolean | undefined;
  25110. /**
  25111. * Use matrix interpolation instead of using direct key value when animating matrices
  25112. */
  25113. static AllowMatricesInterpolation: boolean;
  25114. /**
  25115. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25116. */
  25117. static AllowMatrixDecomposeForInterpolation: boolean;
  25118. /**
  25119. * Stores the key frames of the animation
  25120. */
  25121. private _keys;
  25122. /**
  25123. * Stores the easing function of the animation
  25124. */
  25125. private _easingFunction;
  25126. /**
  25127. * @hidden Internal use only
  25128. */
  25129. _runtimeAnimations: RuntimeAnimation[];
  25130. /**
  25131. * The set of event that will be linked to this animation
  25132. */
  25133. private _events;
  25134. /**
  25135. * Stores an array of target property paths
  25136. */
  25137. targetPropertyPath: string[];
  25138. /**
  25139. * Stores the blending speed of the animation
  25140. */
  25141. blendingSpeed: number;
  25142. /**
  25143. * Stores the animation ranges for the animation
  25144. */
  25145. private _ranges;
  25146. /**
  25147. * @hidden Internal use
  25148. */
  25149. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25150. /**
  25151. * Sets up an animation
  25152. * @param property The property to animate
  25153. * @param animationType The animation type to apply
  25154. * @param framePerSecond The frames per second of the animation
  25155. * @param easingFunction The easing function used in the animation
  25156. * @returns The created animation
  25157. */
  25158. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25159. /**
  25160. * Create and start an animation on a node
  25161. * @param name defines the name of the global animation that will be run on all nodes
  25162. * @param node defines the root node where the animation will take place
  25163. * @param targetProperty defines property to animate
  25164. * @param framePerSecond defines the number of frame per second yo use
  25165. * @param totalFrame defines the number of frames in total
  25166. * @param from defines the initial value
  25167. * @param to defines the final value
  25168. * @param loopMode defines which loop mode you want to use (off by default)
  25169. * @param easingFunction defines the easing function to use (linear by default)
  25170. * @param onAnimationEnd defines the callback to call when animation end
  25171. * @returns the animatable created for this animation
  25172. */
  25173. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25174. /**
  25175. * Create and start an animation on a node and its descendants
  25176. * @param name defines the name of the global animation that will be run on all nodes
  25177. * @param node defines the root node where the animation will take place
  25178. * @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
  25179. * @param targetProperty defines property to animate
  25180. * @param framePerSecond defines the number of frame per second to use
  25181. * @param totalFrame defines the number of frames in total
  25182. * @param from defines the initial value
  25183. * @param to defines the final value
  25184. * @param loopMode defines which loop mode you want to use (off by default)
  25185. * @param easingFunction defines the easing function to use (linear by default)
  25186. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25187. * @returns the list of animatables created for all nodes
  25188. * @example https://www.babylonjs-playground.com/#MH0VLI
  25189. */
  25190. 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[]>;
  25191. /**
  25192. * Creates a new animation, merges it with the existing animations and starts it
  25193. * @param name Name of the animation
  25194. * @param node Node which contains the scene that begins the animations
  25195. * @param targetProperty Specifies which property to animate
  25196. * @param framePerSecond The frames per second of the animation
  25197. * @param totalFrame The total number of frames
  25198. * @param from The frame at the beginning of the animation
  25199. * @param to The frame at the end of the animation
  25200. * @param loopMode Specifies the loop mode of the animation
  25201. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25202. * @param onAnimationEnd Callback to run once the animation is complete
  25203. * @returns Nullable animation
  25204. */
  25205. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25206. /**
  25207. * Transition property of an host to the target Value
  25208. * @param property The property to transition
  25209. * @param targetValue The target Value of the property
  25210. * @param host The object where the property to animate belongs
  25211. * @param scene Scene used to run the animation
  25212. * @param frameRate Framerate (in frame/s) to use
  25213. * @param transition The transition type we want to use
  25214. * @param duration The duration of the animation, in milliseconds
  25215. * @param onAnimationEnd Callback trigger at the end of the animation
  25216. * @returns Nullable animation
  25217. */
  25218. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25219. /**
  25220. * Return the array of runtime animations currently using this animation
  25221. */
  25222. readonly runtimeAnimations: RuntimeAnimation[];
  25223. /**
  25224. * Specifies if any of the runtime animations are currently running
  25225. */
  25226. readonly hasRunningRuntimeAnimations: boolean;
  25227. /**
  25228. * Initializes the animation
  25229. * @param name Name of the animation
  25230. * @param targetProperty Property to animate
  25231. * @param framePerSecond The frames per second of the animation
  25232. * @param dataType The data type of the animation
  25233. * @param loopMode The loop mode of the animation
  25234. * @param enableBlending Specifies if blending should be enabled
  25235. */
  25236. constructor(
  25237. /**Name of the animation */
  25238. name: string,
  25239. /**Property to animate */
  25240. targetProperty: string,
  25241. /**The frames per second of the animation */
  25242. framePerSecond: number,
  25243. /**The data type of the animation */
  25244. dataType: number,
  25245. /**The loop mode of the animation */
  25246. loopMode?: number | undefined,
  25247. /**Specifies if blending should be enabled */
  25248. enableBlending?: boolean | undefined);
  25249. /**
  25250. * Converts the animation to a string
  25251. * @param fullDetails support for multiple levels of logging within scene loading
  25252. * @returns String form of the animation
  25253. */
  25254. toString(fullDetails?: boolean): string;
  25255. /**
  25256. * Add an event to this animation
  25257. * @param event Event to add
  25258. */
  25259. addEvent(event: AnimationEvent): void;
  25260. /**
  25261. * Remove all events found at the given frame
  25262. * @param frame The frame to remove events from
  25263. */
  25264. removeEvents(frame: number): void;
  25265. /**
  25266. * Retrieves all the events from the animation
  25267. * @returns Events from the animation
  25268. */
  25269. getEvents(): AnimationEvent[];
  25270. /**
  25271. * Creates an animation range
  25272. * @param name Name of the animation range
  25273. * @param from Starting frame of the animation range
  25274. * @param to Ending frame of the animation
  25275. */
  25276. createRange(name: string, from: number, to: number): void;
  25277. /**
  25278. * Deletes an animation range by name
  25279. * @param name Name of the animation range to delete
  25280. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25281. */
  25282. deleteRange(name: string, deleteFrames?: boolean): void;
  25283. /**
  25284. * Gets the animation range by name, or null if not defined
  25285. * @param name Name of the animation range
  25286. * @returns Nullable animation range
  25287. */
  25288. getRange(name: string): Nullable<AnimationRange>;
  25289. /**
  25290. * Gets the key frames from the animation
  25291. * @returns The key frames of the animation
  25292. */
  25293. getKeys(): Array<IAnimationKey>;
  25294. /**
  25295. * Gets the highest frame rate of the animation
  25296. * @returns Highest frame rate of the animation
  25297. */
  25298. getHighestFrame(): number;
  25299. /**
  25300. * Gets the easing function of the animation
  25301. * @returns Easing function of the animation
  25302. */
  25303. getEasingFunction(): IEasingFunction;
  25304. /**
  25305. * Sets the easing function of the animation
  25306. * @param easingFunction A custom mathematical formula for animation
  25307. */
  25308. setEasingFunction(easingFunction: EasingFunction): void;
  25309. /**
  25310. * Interpolates a scalar linearly
  25311. * @param startValue Start value of the animation curve
  25312. * @param endValue End value of the animation curve
  25313. * @param gradient Scalar amount to interpolate
  25314. * @returns Interpolated scalar value
  25315. */
  25316. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25317. /**
  25318. * Interpolates a scalar cubically
  25319. * @param startValue Start value of the animation curve
  25320. * @param outTangent End tangent of the animation
  25321. * @param endValue End value of the animation curve
  25322. * @param inTangent Start tangent of the animation curve
  25323. * @param gradient Scalar amount to interpolate
  25324. * @returns Interpolated scalar value
  25325. */
  25326. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25327. /**
  25328. * Interpolates a quaternion using a spherical linear interpolation
  25329. * @param startValue Start value of the animation curve
  25330. * @param endValue End value of the animation curve
  25331. * @param gradient Scalar amount to interpolate
  25332. * @returns Interpolated quaternion value
  25333. */
  25334. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25335. /**
  25336. * Interpolates a quaternion cubically
  25337. * @param startValue Start value of the animation curve
  25338. * @param outTangent End tangent of the animation curve
  25339. * @param endValue End value of the animation curve
  25340. * @param inTangent Start tangent of the animation curve
  25341. * @param gradient Scalar amount to interpolate
  25342. * @returns Interpolated quaternion value
  25343. */
  25344. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25345. /**
  25346. * Interpolates a Vector3 linearl
  25347. * @param startValue Start value of the animation curve
  25348. * @param endValue End value of the animation curve
  25349. * @param gradient Scalar amount to interpolate
  25350. * @returns Interpolated scalar value
  25351. */
  25352. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25353. /**
  25354. * Interpolates a Vector3 cubically
  25355. * @param startValue Start value of the animation curve
  25356. * @param outTangent End tangent of the animation
  25357. * @param endValue End value of the animation curve
  25358. * @param inTangent Start tangent of the animation curve
  25359. * @param gradient Scalar amount to interpolate
  25360. * @returns InterpolatedVector3 value
  25361. */
  25362. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25363. /**
  25364. * Interpolates a Vector2 linearly
  25365. * @param startValue Start value of the animation curve
  25366. * @param endValue End value of the animation curve
  25367. * @param gradient Scalar amount to interpolate
  25368. * @returns Interpolated Vector2 value
  25369. */
  25370. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25371. /**
  25372. * Interpolates a Vector2 cubically
  25373. * @param startValue Start value of the animation curve
  25374. * @param outTangent End tangent of the animation
  25375. * @param endValue End value of the animation curve
  25376. * @param inTangent Start tangent of the animation curve
  25377. * @param gradient Scalar amount to interpolate
  25378. * @returns Interpolated Vector2 value
  25379. */
  25380. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25381. /**
  25382. * Interpolates a size linearly
  25383. * @param startValue Start value of the animation curve
  25384. * @param endValue End value of the animation curve
  25385. * @param gradient Scalar amount to interpolate
  25386. * @returns Interpolated Size value
  25387. */
  25388. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25389. /**
  25390. * Interpolates a Color3 linearly
  25391. * @param startValue Start value of the animation curve
  25392. * @param endValue End value of the animation curve
  25393. * @param gradient Scalar amount to interpolate
  25394. * @returns Interpolated Color3 value
  25395. */
  25396. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25397. /**
  25398. * @hidden Internal use only
  25399. */
  25400. _getKeyValue(value: any): any;
  25401. /**
  25402. * @hidden Internal use only
  25403. */
  25404. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25405. /**
  25406. * Defines the function to use to interpolate matrices
  25407. * @param startValue defines the start matrix
  25408. * @param endValue defines the end matrix
  25409. * @param gradient defines the gradient between both matrices
  25410. * @param result defines an optional target matrix where to store the interpolation
  25411. * @returns the interpolated matrix
  25412. */
  25413. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25414. /**
  25415. * Makes a copy of the animation
  25416. * @returns Cloned animation
  25417. */
  25418. clone(): Animation;
  25419. /**
  25420. * Sets the key frames of the animation
  25421. * @param values The animation key frames to set
  25422. */
  25423. setKeys(values: Array<IAnimationKey>): void;
  25424. /**
  25425. * Serializes the animation to an object
  25426. * @returns Serialized object
  25427. */
  25428. serialize(): any;
  25429. /**
  25430. * Float animation type
  25431. */
  25432. private static _ANIMATIONTYPE_FLOAT;
  25433. /**
  25434. * Vector3 animation type
  25435. */
  25436. private static _ANIMATIONTYPE_VECTOR3;
  25437. /**
  25438. * Quaternion animation type
  25439. */
  25440. private static _ANIMATIONTYPE_QUATERNION;
  25441. /**
  25442. * Matrix animation type
  25443. */
  25444. private static _ANIMATIONTYPE_MATRIX;
  25445. /**
  25446. * Color3 animation type
  25447. */
  25448. private static _ANIMATIONTYPE_COLOR3;
  25449. /**
  25450. * Vector2 animation type
  25451. */
  25452. private static _ANIMATIONTYPE_VECTOR2;
  25453. /**
  25454. * Size animation type
  25455. */
  25456. private static _ANIMATIONTYPE_SIZE;
  25457. /**
  25458. * Relative Loop Mode
  25459. */
  25460. private static _ANIMATIONLOOPMODE_RELATIVE;
  25461. /**
  25462. * Cycle Loop Mode
  25463. */
  25464. private static _ANIMATIONLOOPMODE_CYCLE;
  25465. /**
  25466. * Constant Loop Mode
  25467. */
  25468. private static _ANIMATIONLOOPMODE_CONSTANT;
  25469. /**
  25470. * Get the float animation type
  25471. */
  25472. static readonly ANIMATIONTYPE_FLOAT: number;
  25473. /**
  25474. * Get the Vector3 animation type
  25475. */
  25476. static readonly ANIMATIONTYPE_VECTOR3: number;
  25477. /**
  25478. * Get the Vector2 animation type
  25479. */
  25480. static readonly ANIMATIONTYPE_VECTOR2: number;
  25481. /**
  25482. * Get the Size animation type
  25483. */
  25484. static readonly ANIMATIONTYPE_SIZE: number;
  25485. /**
  25486. * Get the Quaternion animation type
  25487. */
  25488. static readonly ANIMATIONTYPE_QUATERNION: number;
  25489. /**
  25490. * Get the Matrix animation type
  25491. */
  25492. static readonly ANIMATIONTYPE_MATRIX: number;
  25493. /**
  25494. * Get the Color3 animation type
  25495. */
  25496. static readonly ANIMATIONTYPE_COLOR3: number;
  25497. /**
  25498. * Get the Relative Loop Mode
  25499. */
  25500. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25501. /**
  25502. * Get the Cycle Loop Mode
  25503. */
  25504. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25505. /**
  25506. * Get the Constant Loop Mode
  25507. */
  25508. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25509. /** @hidden */
  25510. static _UniversalLerp(left: any, right: any, amount: number): any;
  25511. /**
  25512. * Parses an animation object and creates an animation
  25513. * @param parsedAnimation Parsed animation object
  25514. * @returns Animation object
  25515. */
  25516. static Parse(parsedAnimation: any): Animation;
  25517. /**
  25518. * Appends the serialized animations from the source animations
  25519. * @param source Source containing the animations
  25520. * @param destination Target to store the animations
  25521. */
  25522. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25523. }
  25524. }
  25525. declare module BABYLON {
  25526. /**
  25527. * Base class of all the textures in babylon.
  25528. * It groups all the common properties the materials, post process, lights... might need
  25529. * in order to make a correct use of the texture.
  25530. */
  25531. export class BaseTexture implements IAnimatable {
  25532. /**
  25533. * Default anisotropic filtering level for the application.
  25534. * It is set to 4 as a good tradeoff between perf and quality.
  25535. */
  25536. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25537. /**
  25538. * Gets or sets the unique id of the texture
  25539. */
  25540. uniqueId: number;
  25541. /**
  25542. * Define the name of the texture.
  25543. */
  25544. name: string;
  25545. /**
  25546. * Gets or sets an object used to store user defined information.
  25547. */
  25548. metadata: any;
  25549. /**
  25550. * For internal use only. Please do not use.
  25551. */
  25552. reservedDataStore: any;
  25553. private _hasAlpha;
  25554. /**
  25555. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25556. */
  25557. hasAlpha: boolean;
  25558. /**
  25559. * Defines if the alpha value should be determined via the rgb values.
  25560. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25561. */
  25562. getAlphaFromRGB: boolean;
  25563. /**
  25564. * Intensity or strength of the texture.
  25565. * It is commonly used by materials to fine tune the intensity of the texture
  25566. */
  25567. level: number;
  25568. /**
  25569. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25570. * This is part of the texture as textures usually maps to one uv set.
  25571. */
  25572. coordinatesIndex: number;
  25573. private _coordinatesMode;
  25574. /**
  25575. * How a texture is mapped.
  25576. *
  25577. * | Value | Type | Description |
  25578. * | ----- | ----------------------------------- | ----------- |
  25579. * | 0 | EXPLICIT_MODE | |
  25580. * | 1 | SPHERICAL_MODE | |
  25581. * | 2 | PLANAR_MODE | |
  25582. * | 3 | CUBIC_MODE | |
  25583. * | 4 | PROJECTION_MODE | |
  25584. * | 5 | SKYBOX_MODE | |
  25585. * | 6 | INVCUBIC_MODE | |
  25586. * | 7 | EQUIRECTANGULAR_MODE | |
  25587. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25588. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25589. */
  25590. coordinatesMode: number;
  25591. /**
  25592. * | Value | Type | Description |
  25593. * | ----- | ------------------ | ----------- |
  25594. * | 0 | CLAMP_ADDRESSMODE | |
  25595. * | 1 | WRAP_ADDRESSMODE | |
  25596. * | 2 | MIRROR_ADDRESSMODE | |
  25597. */
  25598. wrapU: number;
  25599. /**
  25600. * | Value | Type | Description |
  25601. * | ----- | ------------------ | ----------- |
  25602. * | 0 | CLAMP_ADDRESSMODE | |
  25603. * | 1 | WRAP_ADDRESSMODE | |
  25604. * | 2 | MIRROR_ADDRESSMODE | |
  25605. */
  25606. wrapV: number;
  25607. /**
  25608. * | Value | Type | Description |
  25609. * | ----- | ------------------ | ----------- |
  25610. * | 0 | CLAMP_ADDRESSMODE | |
  25611. * | 1 | WRAP_ADDRESSMODE | |
  25612. * | 2 | MIRROR_ADDRESSMODE | |
  25613. */
  25614. wrapR: number;
  25615. /**
  25616. * With compliant hardware and browser (supporting anisotropic filtering)
  25617. * this defines the level of anisotropic filtering in the texture.
  25618. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25619. */
  25620. anisotropicFilteringLevel: number;
  25621. /**
  25622. * Define if the texture is a cube texture or if false a 2d texture.
  25623. */
  25624. isCube: boolean;
  25625. /**
  25626. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25627. */
  25628. is3D: boolean;
  25629. /**
  25630. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25631. * HDR texture are usually stored in linear space.
  25632. * This only impacts the PBR and Background materials
  25633. */
  25634. gammaSpace: boolean;
  25635. /**
  25636. * Gets whether or not the texture contains RGBD data.
  25637. */
  25638. readonly isRGBD: boolean;
  25639. /**
  25640. * Is Z inverted in the texture (useful in a cube texture).
  25641. */
  25642. invertZ: boolean;
  25643. /**
  25644. * Are mip maps generated for this texture or not.
  25645. */
  25646. readonly noMipmap: boolean;
  25647. /**
  25648. * @hidden
  25649. */
  25650. lodLevelInAlpha: boolean;
  25651. /**
  25652. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25653. */
  25654. lodGenerationOffset: number;
  25655. /**
  25656. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25657. */
  25658. lodGenerationScale: number;
  25659. /**
  25660. * Define if the texture is a render target.
  25661. */
  25662. isRenderTarget: boolean;
  25663. /**
  25664. * Define the unique id of the texture in the scene.
  25665. */
  25666. readonly uid: string;
  25667. /**
  25668. * Return a string representation of the texture.
  25669. * @returns the texture as a string
  25670. */
  25671. toString(): string;
  25672. /**
  25673. * Get the class name of the texture.
  25674. * @returns "BaseTexture"
  25675. */
  25676. getClassName(): string;
  25677. /**
  25678. * Define the list of animation attached to the texture.
  25679. */
  25680. animations: Animation[];
  25681. /**
  25682. * An event triggered when the texture is disposed.
  25683. */
  25684. onDisposeObservable: Observable<BaseTexture>;
  25685. private _onDisposeObserver;
  25686. /**
  25687. * Callback triggered when the texture has been disposed.
  25688. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25689. */
  25690. onDispose: () => void;
  25691. /**
  25692. * Define the current state of the loading sequence when in delayed load mode.
  25693. */
  25694. delayLoadState: number;
  25695. private _scene;
  25696. /** @hidden */
  25697. _texture: Nullable<InternalTexture>;
  25698. private _uid;
  25699. /**
  25700. * Define if the texture is preventinga material to render or not.
  25701. * If not and the texture is not ready, the engine will use a default black texture instead.
  25702. */
  25703. readonly isBlocking: boolean;
  25704. /**
  25705. * Instantiates a new BaseTexture.
  25706. * Base class of all the textures in babylon.
  25707. * It groups all the common properties the materials, post process, lights... might need
  25708. * in order to make a correct use of the texture.
  25709. * @param scene Define the scene the texture blongs to
  25710. */
  25711. constructor(scene: Nullable<Scene>);
  25712. /**
  25713. * Get the scene the texture belongs to.
  25714. * @returns the scene or null if undefined
  25715. */
  25716. getScene(): Nullable<Scene>;
  25717. /**
  25718. * Get the texture transform matrix used to offset tile the texture for istance.
  25719. * @returns the transformation matrix
  25720. */
  25721. getTextureMatrix(): Matrix;
  25722. /**
  25723. * Get the texture reflection matrix used to rotate/transform the reflection.
  25724. * @returns the reflection matrix
  25725. */
  25726. getReflectionTextureMatrix(): Matrix;
  25727. /**
  25728. * Get the underlying lower level texture from Babylon.
  25729. * @returns the insternal texture
  25730. */
  25731. getInternalTexture(): Nullable<InternalTexture>;
  25732. /**
  25733. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25734. * @returns true if ready or not blocking
  25735. */
  25736. isReadyOrNotBlocking(): boolean;
  25737. /**
  25738. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25739. * @returns true if fully ready
  25740. */
  25741. isReady(): boolean;
  25742. private _cachedSize;
  25743. /**
  25744. * Get the size of the texture.
  25745. * @returns the texture size.
  25746. */
  25747. getSize(): ISize;
  25748. /**
  25749. * Get the base size of the texture.
  25750. * It can be different from the size if the texture has been resized for POT for instance
  25751. * @returns the base size
  25752. */
  25753. getBaseSize(): ISize;
  25754. /**
  25755. * Update the sampling mode of the texture.
  25756. * Default is Trilinear mode.
  25757. *
  25758. * | Value | Type | Description |
  25759. * | ----- | ------------------ | ----------- |
  25760. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25761. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25762. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25763. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25764. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25765. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25766. * | 7 | NEAREST_LINEAR | |
  25767. * | 8 | NEAREST_NEAREST | |
  25768. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25769. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25770. * | 11 | LINEAR_LINEAR | |
  25771. * | 12 | LINEAR_NEAREST | |
  25772. *
  25773. * > _mag_: magnification filter (close to the viewer)
  25774. * > _min_: minification filter (far from the viewer)
  25775. * > _mip_: filter used between mip map levels
  25776. *@param samplingMode Define the new sampling mode of the texture
  25777. */
  25778. updateSamplingMode(samplingMode: number): void;
  25779. /**
  25780. * Scales the texture if is `canRescale()`
  25781. * @param ratio the resize factor we want to use to rescale
  25782. */
  25783. scale(ratio: number): void;
  25784. /**
  25785. * Get if the texture can rescale.
  25786. */
  25787. readonly canRescale: boolean;
  25788. /** @hidden */
  25789. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25790. /** @hidden */
  25791. _rebuild(): void;
  25792. /**
  25793. * Triggers the load sequence in delayed load mode.
  25794. */
  25795. delayLoad(): void;
  25796. /**
  25797. * Clones the texture.
  25798. * @returns the cloned texture
  25799. */
  25800. clone(): Nullable<BaseTexture>;
  25801. /**
  25802. * Get the texture underlying type (INT, FLOAT...)
  25803. */
  25804. readonly textureType: number;
  25805. /**
  25806. * Get the texture underlying format (RGB, RGBA...)
  25807. */
  25808. readonly textureFormat: number;
  25809. /**
  25810. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25811. * This will returns an RGBA array buffer containing either in values (0-255) or
  25812. * float values (0-1) depending of the underlying buffer type.
  25813. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25814. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25815. * @param buffer defines a user defined buffer to fill with data (can be null)
  25816. * @returns The Array buffer containing the pixels data.
  25817. */
  25818. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25819. /**
  25820. * Release and destroy the underlying lower level texture aka internalTexture.
  25821. */
  25822. releaseInternalTexture(): void;
  25823. /**
  25824. * Get the polynomial representation of the texture data.
  25825. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25826. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25827. */
  25828. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25829. /** @hidden */
  25830. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25831. /** @hidden */
  25832. readonly _lodTextureMid: Nullable<BaseTexture>;
  25833. /** @hidden */
  25834. readonly _lodTextureLow: Nullable<BaseTexture>;
  25835. /**
  25836. * Dispose the texture and release its associated resources.
  25837. */
  25838. dispose(): void;
  25839. /**
  25840. * Serialize the texture into a JSON representation that can be parsed later on.
  25841. * @returns the JSON representation of the texture
  25842. */
  25843. serialize(): any;
  25844. /**
  25845. * Helper function to be called back once a list of texture contains only ready textures.
  25846. * @param textures Define the list of textures to wait for
  25847. * @param callback Define the callback triggered once the entire list will be ready
  25848. */
  25849. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25850. }
  25851. }
  25852. declare module BABYLON {
  25853. /**
  25854. * Uniform buffer objects.
  25855. *
  25856. * Handles blocks of uniform on the GPU.
  25857. *
  25858. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25859. *
  25860. * For more information, please refer to :
  25861. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25862. */
  25863. export class UniformBuffer {
  25864. private _engine;
  25865. private _buffer;
  25866. private _data;
  25867. private _bufferData;
  25868. private _dynamic?;
  25869. private _uniformLocations;
  25870. private _uniformSizes;
  25871. private _uniformLocationPointer;
  25872. private _needSync;
  25873. private _noUBO;
  25874. private _currentEffect;
  25875. private static _MAX_UNIFORM_SIZE;
  25876. private static _tempBuffer;
  25877. /**
  25878. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25879. * This is dynamic to allow compat with webgl 1 and 2.
  25880. * You will need to pass the name of the uniform as well as the value.
  25881. */
  25882. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25883. /**
  25884. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25885. * This is dynamic to allow compat with webgl 1 and 2.
  25886. * You will need to pass the name of the uniform as well as the value.
  25887. */
  25888. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25889. /**
  25890. * Lambda to Update a single float in a uniform buffer.
  25891. * This is dynamic to allow compat with webgl 1 and 2.
  25892. * You will need to pass the name of the uniform as well as the value.
  25893. */
  25894. updateFloat: (name: string, x: number) => void;
  25895. /**
  25896. * Lambda to Update a vec2 of float in a uniform buffer.
  25897. * This is dynamic to allow compat with webgl 1 and 2.
  25898. * You will need to pass the name of the uniform as well as the value.
  25899. */
  25900. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25901. /**
  25902. * Lambda to Update a vec3 of float in a uniform buffer.
  25903. * This is dynamic to allow compat with webgl 1 and 2.
  25904. * You will need to pass the name of the uniform as well as the value.
  25905. */
  25906. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25907. /**
  25908. * Lambda to Update a vec4 of float in a uniform buffer.
  25909. * This is dynamic to allow compat with webgl 1 and 2.
  25910. * You will need to pass the name of the uniform as well as the value.
  25911. */
  25912. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25913. /**
  25914. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25915. * This is dynamic to allow compat with webgl 1 and 2.
  25916. * You will need to pass the name of the uniform as well as the value.
  25917. */
  25918. updateMatrix: (name: string, mat: Matrix) => void;
  25919. /**
  25920. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25921. * This is dynamic to allow compat with webgl 1 and 2.
  25922. * You will need to pass the name of the uniform as well as the value.
  25923. */
  25924. updateVector3: (name: string, vector: Vector3) => void;
  25925. /**
  25926. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25927. * This is dynamic to allow compat with webgl 1 and 2.
  25928. * You will need to pass the name of the uniform as well as the value.
  25929. */
  25930. updateVector4: (name: string, vector: Vector4) => void;
  25931. /**
  25932. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25933. * This is dynamic to allow compat with webgl 1 and 2.
  25934. * You will need to pass the name of the uniform as well as the value.
  25935. */
  25936. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25937. /**
  25938. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25939. * This is dynamic to allow compat with webgl 1 and 2.
  25940. * You will need to pass the name of the uniform as well as the value.
  25941. */
  25942. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25943. /**
  25944. * Instantiates a new Uniform buffer objects.
  25945. *
  25946. * Handles blocks of uniform on the GPU.
  25947. *
  25948. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25949. *
  25950. * For more information, please refer to :
  25951. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25952. * @param engine Define the engine the buffer is associated with
  25953. * @param data Define the data contained in the buffer
  25954. * @param dynamic Define if the buffer is updatable
  25955. */
  25956. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25957. /**
  25958. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25959. * or just falling back on setUniformXXX calls.
  25960. */
  25961. readonly useUbo: boolean;
  25962. /**
  25963. * Indicates if the WebGL underlying uniform buffer is in sync
  25964. * with the javascript cache data.
  25965. */
  25966. readonly isSync: boolean;
  25967. /**
  25968. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25969. * Also, a dynamic UniformBuffer will disable cache verification and always
  25970. * update the underlying WebGL uniform buffer to the GPU.
  25971. * @returns if Dynamic, otherwise false
  25972. */
  25973. isDynamic(): boolean;
  25974. /**
  25975. * The data cache on JS side.
  25976. * @returns the underlying data as a float array
  25977. */
  25978. getData(): Float32Array;
  25979. /**
  25980. * The underlying WebGL Uniform buffer.
  25981. * @returns the webgl buffer
  25982. */
  25983. getBuffer(): Nullable<WebGLBuffer>;
  25984. /**
  25985. * std140 layout specifies how to align data within an UBO structure.
  25986. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25987. * for specs.
  25988. */
  25989. private _fillAlignment;
  25990. /**
  25991. * Adds an uniform in the buffer.
  25992. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25993. * for the layout to be correct !
  25994. * @param name Name of the uniform, as used in the uniform block in the shader.
  25995. * @param size Data size, or data directly.
  25996. */
  25997. addUniform(name: string, size: number | number[]): void;
  25998. /**
  25999. * Adds a Matrix 4x4 to the uniform buffer.
  26000. * @param name Name of the uniform, as used in the uniform block in the shader.
  26001. * @param mat A 4x4 matrix.
  26002. */
  26003. addMatrix(name: string, mat: Matrix): void;
  26004. /**
  26005. * Adds a vec2 to the uniform buffer.
  26006. * @param name Name of the uniform, as used in the uniform block in the shader.
  26007. * @param x Define the x component value of the vec2
  26008. * @param y Define the y component value of the vec2
  26009. */
  26010. addFloat2(name: string, x: number, y: number): void;
  26011. /**
  26012. * Adds a vec3 to the uniform buffer.
  26013. * @param name Name of the uniform, as used in the uniform block in the shader.
  26014. * @param x Define the x component value of the vec3
  26015. * @param y Define the y component value of the vec3
  26016. * @param z Define the z component value of the vec3
  26017. */
  26018. addFloat3(name: string, x: number, y: number, z: number): void;
  26019. /**
  26020. * Adds a vec3 to the uniform buffer.
  26021. * @param name Name of the uniform, as used in the uniform block in the shader.
  26022. * @param color Define the vec3 from a Color
  26023. */
  26024. addColor3(name: string, color: Color3): void;
  26025. /**
  26026. * Adds a vec4 to the uniform buffer.
  26027. * @param name Name of the uniform, as used in the uniform block in the shader.
  26028. * @param color Define the rgb components from a Color
  26029. * @param alpha Define the a component of the vec4
  26030. */
  26031. addColor4(name: string, color: Color3, alpha: number): void;
  26032. /**
  26033. * Adds a vec3 to the uniform buffer.
  26034. * @param name Name of the uniform, as used in the uniform block in the shader.
  26035. * @param vector Define the vec3 components from a Vector
  26036. */
  26037. addVector3(name: string, vector: Vector3): void;
  26038. /**
  26039. * Adds a Matrix 3x3 to the uniform buffer.
  26040. * @param name Name of the uniform, as used in the uniform block in the shader.
  26041. */
  26042. addMatrix3x3(name: string): void;
  26043. /**
  26044. * Adds a Matrix 2x2 to the uniform buffer.
  26045. * @param name Name of the uniform, as used in the uniform block in the shader.
  26046. */
  26047. addMatrix2x2(name: string): void;
  26048. /**
  26049. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26050. */
  26051. create(): void;
  26052. /** @hidden */
  26053. _rebuild(): void;
  26054. /**
  26055. * Updates the WebGL Uniform Buffer on the GPU.
  26056. * If the `dynamic` flag is set to true, no cache comparison is done.
  26057. * Otherwise, the buffer will be updated only if the cache differs.
  26058. */
  26059. update(): void;
  26060. /**
  26061. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26062. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26063. * @param data Define the flattened data
  26064. * @param size Define the size of the data.
  26065. */
  26066. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26067. private _updateMatrix3x3ForUniform;
  26068. private _updateMatrix3x3ForEffect;
  26069. private _updateMatrix2x2ForEffect;
  26070. private _updateMatrix2x2ForUniform;
  26071. private _updateFloatForEffect;
  26072. private _updateFloatForUniform;
  26073. private _updateFloat2ForEffect;
  26074. private _updateFloat2ForUniform;
  26075. private _updateFloat3ForEffect;
  26076. private _updateFloat3ForUniform;
  26077. private _updateFloat4ForEffect;
  26078. private _updateFloat4ForUniform;
  26079. private _updateMatrixForEffect;
  26080. private _updateMatrixForUniform;
  26081. private _updateVector3ForEffect;
  26082. private _updateVector3ForUniform;
  26083. private _updateVector4ForEffect;
  26084. private _updateVector4ForUniform;
  26085. private _updateColor3ForEffect;
  26086. private _updateColor3ForUniform;
  26087. private _updateColor4ForEffect;
  26088. private _updateColor4ForUniform;
  26089. /**
  26090. * Sets a sampler uniform on the effect.
  26091. * @param name Define the name of the sampler.
  26092. * @param texture Define the texture to set in the sampler
  26093. */
  26094. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26095. /**
  26096. * Directly updates the value of the uniform in the cache AND on the GPU.
  26097. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26098. * @param data Define the flattened data
  26099. */
  26100. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26101. /**
  26102. * Binds this uniform buffer to an effect.
  26103. * @param effect Define the effect to bind the buffer to
  26104. * @param name Name of the uniform block in the shader.
  26105. */
  26106. bindToEffect(effect: Effect, name: string): void;
  26107. /**
  26108. * Disposes the uniform buffer.
  26109. */
  26110. dispose(): void;
  26111. }
  26112. }
  26113. declare module BABYLON {
  26114. /**
  26115. * This represents the required contract to create a new type of texture loader.
  26116. */
  26117. export interface IInternalTextureLoader {
  26118. /**
  26119. * Defines wether the loader supports cascade loading the different faces.
  26120. */
  26121. supportCascades: boolean;
  26122. /**
  26123. * This returns if the loader support the current file information.
  26124. * @param extension defines the file extension of the file being loaded
  26125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26126. * @param fallback defines the fallback internal texture if any
  26127. * @param isBase64 defines whether the texture is encoded as a base64
  26128. * @param isBuffer defines whether the texture data are stored as a buffer
  26129. * @returns true if the loader can load the specified file
  26130. */
  26131. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26132. /**
  26133. * Transform the url before loading if required.
  26134. * @param rootUrl the url of the texture
  26135. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26136. * @returns the transformed texture
  26137. */
  26138. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26139. /**
  26140. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26141. * @param rootUrl the url of the texture
  26142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26143. * @returns the fallback texture
  26144. */
  26145. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26146. /**
  26147. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26148. * @param data contains the texture data
  26149. * @param texture defines the BabylonJS internal texture
  26150. * @param createPolynomials will be true if polynomials have been requested
  26151. * @param onLoad defines the callback to trigger once the texture is ready
  26152. * @param onError defines the callback to trigger in case of error
  26153. */
  26154. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26155. /**
  26156. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26157. * @param data contains the texture data
  26158. * @param texture defines the BabylonJS internal texture
  26159. * @param callback defines the method to call once ready to upload
  26160. */
  26161. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26162. }
  26163. }
  26164. declare module BABYLON {
  26165. /**
  26166. * Creation options of the multi render target texture.
  26167. */
  26168. export interface IMultiRenderTargetOptions {
  26169. /**
  26170. * Define if the texture needs to create mip maps after render.
  26171. */
  26172. generateMipMaps?: boolean;
  26173. /**
  26174. * Define the types of all the draw buffers we want to create
  26175. */
  26176. types?: number[];
  26177. /**
  26178. * Define the sampling modes of all the draw buffers we want to create
  26179. */
  26180. samplingModes?: number[];
  26181. /**
  26182. * Define if a depth buffer is required
  26183. */
  26184. generateDepthBuffer?: boolean;
  26185. /**
  26186. * Define if a stencil buffer is required
  26187. */
  26188. generateStencilBuffer?: boolean;
  26189. /**
  26190. * Define if a depth texture is required instead of a depth buffer
  26191. */
  26192. generateDepthTexture?: boolean;
  26193. /**
  26194. * Define the number of desired draw buffers
  26195. */
  26196. textureCount?: number;
  26197. /**
  26198. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26199. */
  26200. doNotChangeAspectRatio?: boolean;
  26201. /**
  26202. * Define the default type of the buffers we are creating
  26203. */
  26204. defaultType?: number;
  26205. }
  26206. /**
  26207. * A multi render target, like a render target provides the ability to render to a texture.
  26208. * Unlike the render target, it can render to several draw buffers in one draw.
  26209. * This is specially interesting in deferred rendering or for any effects requiring more than
  26210. * just one color from a single pass.
  26211. */
  26212. export class MultiRenderTarget extends RenderTargetTexture {
  26213. private _internalTextures;
  26214. private _textures;
  26215. private _multiRenderTargetOptions;
  26216. /**
  26217. * Get if draw buffers are currently supported by the used hardware and browser.
  26218. */
  26219. readonly isSupported: boolean;
  26220. /**
  26221. * Get the list of textures generated by the multi render target.
  26222. */
  26223. readonly textures: Texture[];
  26224. /**
  26225. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26226. */
  26227. readonly depthTexture: Texture;
  26228. /**
  26229. * Set the wrapping mode on U of all the textures we are rendering to.
  26230. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26231. */
  26232. wrapU: number;
  26233. /**
  26234. * Set the wrapping mode on V of all the textures we are rendering to.
  26235. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26236. */
  26237. wrapV: number;
  26238. /**
  26239. * Instantiate a new multi render target texture.
  26240. * A multi render target, like a render target provides the ability to render to a texture.
  26241. * Unlike the render target, it can render to several draw buffers in one draw.
  26242. * This is specially interesting in deferred rendering or for any effects requiring more than
  26243. * just one color from a single pass.
  26244. * @param name Define the name of the texture
  26245. * @param size Define the size of the buffers to render to
  26246. * @param count Define the number of target we are rendering into
  26247. * @param scene Define the scene the texture belongs to
  26248. * @param options Define the options used to create the multi render target
  26249. */
  26250. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26251. /** @hidden */
  26252. _rebuild(): void;
  26253. private _createInternalTextures;
  26254. private _createTextures;
  26255. /**
  26256. * Define the number of samples used if MSAA is enabled.
  26257. */
  26258. samples: number;
  26259. /**
  26260. * Resize all the textures in the multi render target.
  26261. * Be carrefull as it will recreate all the data in the new texture.
  26262. * @param size Define the new size
  26263. */
  26264. resize(size: any): void;
  26265. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26266. /**
  26267. * Dispose the render targets and their associated resources
  26268. */
  26269. dispose(): void;
  26270. /**
  26271. * Release all the underlying texture used as draw buffers.
  26272. */
  26273. releaseInternalTextures(): void;
  26274. }
  26275. }
  26276. declare module BABYLON {
  26277. /**
  26278. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26280. */
  26281. export class Analyser {
  26282. /**
  26283. * Gets or sets the smoothing
  26284. * @ignorenaming
  26285. */
  26286. SMOOTHING: number;
  26287. /**
  26288. * Gets or sets the FFT table size
  26289. * @ignorenaming
  26290. */
  26291. FFT_SIZE: number;
  26292. /**
  26293. * Gets or sets the bar graph amplitude
  26294. * @ignorenaming
  26295. */
  26296. BARGRAPHAMPLITUDE: number;
  26297. /**
  26298. * Gets or sets the position of the debug canvas
  26299. * @ignorenaming
  26300. */
  26301. DEBUGCANVASPOS: {
  26302. x: number;
  26303. y: number;
  26304. };
  26305. /**
  26306. * Gets or sets the debug canvas size
  26307. * @ignorenaming
  26308. */
  26309. DEBUGCANVASSIZE: {
  26310. width: number;
  26311. height: number;
  26312. };
  26313. private _byteFreqs;
  26314. private _byteTime;
  26315. private _floatFreqs;
  26316. private _webAudioAnalyser;
  26317. private _debugCanvas;
  26318. private _debugCanvasContext;
  26319. private _scene;
  26320. private _registerFunc;
  26321. private _audioEngine;
  26322. /**
  26323. * Creates a new analyser
  26324. * @param scene defines hosting scene
  26325. */
  26326. constructor(scene: Scene);
  26327. /**
  26328. * Get the number of data values you will have to play with for the visualization
  26329. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26330. * @returns a number
  26331. */
  26332. getFrequencyBinCount(): number;
  26333. /**
  26334. * Gets the current frequency data as a byte array
  26335. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26336. * @returns a Uint8Array
  26337. */
  26338. getByteFrequencyData(): Uint8Array;
  26339. /**
  26340. * Gets the current waveform as a byte array
  26341. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26342. * @returns a Uint8Array
  26343. */
  26344. getByteTimeDomainData(): Uint8Array;
  26345. /**
  26346. * Gets the current frequency data as a float array
  26347. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26348. * @returns a Float32Array
  26349. */
  26350. getFloatFrequencyData(): Float32Array;
  26351. /**
  26352. * Renders the debug canvas
  26353. */
  26354. drawDebugCanvas(): void;
  26355. /**
  26356. * Stops rendering the debug canvas and removes it
  26357. */
  26358. stopDebugCanvas(): void;
  26359. /**
  26360. * Connects two audio nodes
  26361. * @param inputAudioNode defines first node to connect
  26362. * @param outputAudioNode defines second node to connect
  26363. */
  26364. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26365. /**
  26366. * Releases all associated resources
  26367. */
  26368. dispose(): void;
  26369. }
  26370. }
  26371. declare module BABYLON {
  26372. /**
  26373. * This represents an audio engine and it is responsible
  26374. * to play, synchronize and analyse sounds throughout the application.
  26375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26376. */
  26377. export interface IAudioEngine extends IDisposable {
  26378. /**
  26379. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26380. */
  26381. readonly canUseWebAudio: boolean;
  26382. /**
  26383. * Gets the current AudioContext if available.
  26384. */
  26385. readonly audioContext: Nullable<AudioContext>;
  26386. /**
  26387. * The master gain node defines the global audio volume of your audio engine.
  26388. */
  26389. readonly masterGain: GainNode;
  26390. /**
  26391. * Gets whether or not mp3 are supported by your browser.
  26392. */
  26393. readonly isMP3supported: boolean;
  26394. /**
  26395. * Gets whether or not ogg are supported by your browser.
  26396. */
  26397. readonly isOGGsupported: boolean;
  26398. /**
  26399. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26400. * @ignoreNaming
  26401. */
  26402. WarnedWebAudioUnsupported: boolean;
  26403. /**
  26404. * Defines if the audio engine relies on a custom unlocked button.
  26405. * In this case, the embedded button will not be displayed.
  26406. */
  26407. useCustomUnlockedButton: boolean;
  26408. /**
  26409. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26410. */
  26411. readonly unlocked: boolean;
  26412. /**
  26413. * Event raised when audio has been unlocked on the browser.
  26414. */
  26415. onAudioUnlockedObservable: Observable<AudioEngine>;
  26416. /**
  26417. * Event raised when audio has been locked on the browser.
  26418. */
  26419. onAudioLockedObservable: Observable<AudioEngine>;
  26420. /**
  26421. * Flags the audio engine in Locked state.
  26422. * This happens due to new browser policies preventing audio to autoplay.
  26423. */
  26424. lock(): void;
  26425. /**
  26426. * Unlocks the audio engine once a user action has been done on the dom.
  26427. * This is helpful to resume play once browser policies have been satisfied.
  26428. */
  26429. unlock(): void;
  26430. }
  26431. /**
  26432. * This represents the default audio engine used in babylon.
  26433. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26435. */
  26436. export class AudioEngine implements IAudioEngine {
  26437. private _audioContext;
  26438. private _audioContextInitialized;
  26439. private _muteButton;
  26440. private _hostElement;
  26441. /**
  26442. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26443. */
  26444. canUseWebAudio: boolean;
  26445. /**
  26446. * The master gain node defines the global audio volume of your audio engine.
  26447. */
  26448. masterGain: GainNode;
  26449. /**
  26450. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26451. * @ignoreNaming
  26452. */
  26453. WarnedWebAudioUnsupported: boolean;
  26454. /**
  26455. * Gets whether or not mp3 are supported by your browser.
  26456. */
  26457. isMP3supported: boolean;
  26458. /**
  26459. * Gets whether or not ogg are supported by your browser.
  26460. */
  26461. isOGGsupported: boolean;
  26462. /**
  26463. * Gets whether audio has been unlocked on the device.
  26464. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26465. * a user interaction has happened.
  26466. */
  26467. unlocked: boolean;
  26468. /**
  26469. * Defines if the audio engine relies on a custom unlocked button.
  26470. * In this case, the embedded button will not be displayed.
  26471. */
  26472. useCustomUnlockedButton: boolean;
  26473. /**
  26474. * Event raised when audio has been unlocked on the browser.
  26475. */
  26476. onAudioUnlockedObservable: Observable<AudioEngine>;
  26477. /**
  26478. * Event raised when audio has been locked on the browser.
  26479. */
  26480. onAudioLockedObservable: Observable<AudioEngine>;
  26481. /**
  26482. * Gets the current AudioContext if available.
  26483. */
  26484. readonly audioContext: Nullable<AudioContext>;
  26485. private _connectedAnalyser;
  26486. /**
  26487. * Instantiates a new audio engine.
  26488. *
  26489. * There should be only one per page as some browsers restrict the number
  26490. * of audio contexts you can create.
  26491. * @param hostElement defines the host element where to display the mute icon if necessary
  26492. */
  26493. constructor(hostElement?: Nullable<HTMLElement>);
  26494. /**
  26495. * Flags the audio engine in Locked state.
  26496. * This happens due to new browser policies preventing audio to autoplay.
  26497. */
  26498. lock(): void;
  26499. /**
  26500. * Unlocks the audio engine once a user action has been done on the dom.
  26501. * This is helpful to resume play once browser policies have been satisfied.
  26502. */
  26503. unlock(): void;
  26504. private _resumeAudioContext;
  26505. private _initializeAudioContext;
  26506. private _tryToRun;
  26507. private _triggerRunningState;
  26508. private _triggerSuspendedState;
  26509. private _displayMuteButton;
  26510. private _moveButtonToTopLeft;
  26511. private _onResize;
  26512. private _hideMuteButton;
  26513. /**
  26514. * Destroy and release the resources associated with the audio ccontext.
  26515. */
  26516. dispose(): void;
  26517. /**
  26518. * Gets the global volume sets on the master gain.
  26519. * @returns the global volume if set or -1 otherwise
  26520. */
  26521. getGlobalVolume(): number;
  26522. /**
  26523. * Sets the global volume of your experience (sets on the master gain).
  26524. * @param newVolume Defines the new global volume of the application
  26525. */
  26526. setGlobalVolume(newVolume: number): void;
  26527. /**
  26528. * Connect the audio engine to an audio analyser allowing some amazing
  26529. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26531. * @param analyser The analyser to connect to the engine
  26532. */
  26533. connectToAnalyser(analyser: Analyser): void;
  26534. }
  26535. }
  26536. declare module BABYLON {
  26537. /**
  26538. * Interface used to present a loading screen while loading a scene
  26539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26540. */
  26541. export interface ILoadingScreen {
  26542. /**
  26543. * Function called to display the loading screen
  26544. */
  26545. displayLoadingUI: () => void;
  26546. /**
  26547. * Function called to hide the loading screen
  26548. */
  26549. hideLoadingUI: () => void;
  26550. /**
  26551. * Gets or sets the color to use for the background
  26552. */
  26553. loadingUIBackgroundColor: string;
  26554. /**
  26555. * Gets or sets the text to display while loading
  26556. */
  26557. loadingUIText: string;
  26558. }
  26559. /**
  26560. * Class used for the default loading screen
  26561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26562. */
  26563. export class DefaultLoadingScreen implements ILoadingScreen {
  26564. private _renderingCanvas;
  26565. private _loadingText;
  26566. private _loadingDivBackgroundColor;
  26567. private _loadingDiv;
  26568. private _loadingTextDiv;
  26569. /**
  26570. * Creates a new default loading screen
  26571. * @param _renderingCanvas defines the canvas used to render the scene
  26572. * @param _loadingText defines the default text to display
  26573. * @param _loadingDivBackgroundColor defines the default background color
  26574. */
  26575. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26576. /**
  26577. * Function called to display the loading screen
  26578. */
  26579. displayLoadingUI(): void;
  26580. /**
  26581. * Function called to hide the loading screen
  26582. */
  26583. hideLoadingUI(): void;
  26584. /**
  26585. * Gets or sets the text to display while loading
  26586. */
  26587. loadingUIText: string;
  26588. /**
  26589. * Gets or sets the color to use for the background
  26590. */
  26591. loadingUIBackgroundColor: string;
  26592. private _resizeLoadingUI;
  26593. }
  26594. }
  26595. declare module BABYLON {
  26596. /**
  26597. * Settings for finer control over video usage
  26598. */
  26599. export interface VideoTextureSettings {
  26600. /**
  26601. * Applies `autoplay` to video, if specified
  26602. */
  26603. autoPlay?: boolean;
  26604. /**
  26605. * Applies `loop` to video, if specified
  26606. */
  26607. loop?: boolean;
  26608. /**
  26609. * Automatically updates internal texture from video at every frame in the render loop
  26610. */
  26611. autoUpdateTexture: boolean;
  26612. /**
  26613. * Image src displayed during the video loading or until the user interacts with the video.
  26614. */
  26615. poster?: string;
  26616. }
  26617. /**
  26618. * If you want to display a video in your scene, this is the special texture for that.
  26619. * This special texture works similar to other textures, with the exception of a few parameters.
  26620. * @see https://doc.babylonjs.com/how_to/video_texture
  26621. */
  26622. export class VideoTexture extends Texture {
  26623. /**
  26624. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26625. */
  26626. readonly autoUpdateTexture: boolean;
  26627. /**
  26628. * The video instance used by the texture internally
  26629. */
  26630. readonly video: HTMLVideoElement;
  26631. private _onUserActionRequestedObservable;
  26632. /**
  26633. * Event triggerd when a dom action is required by the user to play the video.
  26634. * This happens due to recent changes in browser policies preventing video to auto start.
  26635. */
  26636. readonly onUserActionRequestedObservable: Observable<Texture>;
  26637. private _generateMipMaps;
  26638. private _engine;
  26639. private _stillImageCaptured;
  26640. private _displayingPosterTexture;
  26641. private _settings;
  26642. private _createInternalTextureOnEvent;
  26643. /**
  26644. * Creates a video texture.
  26645. * If you want to display a video in your scene, this is the special texture for that.
  26646. * This special texture works similar to other textures, with the exception of a few parameters.
  26647. * @see https://doc.babylonjs.com/how_to/video_texture
  26648. * @param name optional name, will detect from video source, if not defined
  26649. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26650. * @param scene is obviously the current scene.
  26651. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26652. * @param invertY is false by default but can be used to invert video on Y axis
  26653. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26654. * @param settings allows finer control over video usage
  26655. */
  26656. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26657. private _getName;
  26658. private _getVideo;
  26659. private _createInternalTexture;
  26660. private reset;
  26661. /**
  26662. * @hidden Internal method to initiate `update`.
  26663. */
  26664. _rebuild(): void;
  26665. /**
  26666. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26667. */
  26668. update(): void;
  26669. /**
  26670. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26671. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26672. */
  26673. updateTexture(isVisible: boolean): void;
  26674. protected _updateInternalTexture: () => void;
  26675. /**
  26676. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26677. * @param url New url.
  26678. */
  26679. updateURL(url: string): void;
  26680. /**
  26681. * Dispose the texture and release its associated resources.
  26682. */
  26683. dispose(): void;
  26684. /**
  26685. * Creates a video texture straight from a stream.
  26686. * @param scene Define the scene the texture should be created in
  26687. * @param stream Define the stream the texture should be created from
  26688. * @returns The created video texture as a promise
  26689. */
  26690. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26691. /**
  26692. * Creates a video texture straight from your WebCam video feed.
  26693. * @param scene Define the scene the texture should be created in
  26694. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26695. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26696. * @returns The created video texture as a promise
  26697. */
  26698. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26699. minWidth: number;
  26700. maxWidth: number;
  26701. minHeight: number;
  26702. maxHeight: number;
  26703. deviceId: string;
  26704. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26705. /**
  26706. * Creates a video texture straight from your WebCam video feed.
  26707. * @param scene Define the scene the texture should be created in
  26708. * @param onReady Define a callback to triggered once the texture will be ready
  26709. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26710. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26711. */
  26712. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26713. minWidth: number;
  26714. maxWidth: number;
  26715. minHeight: number;
  26716. maxHeight: number;
  26717. deviceId: string;
  26718. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26719. }
  26720. }
  26721. declare module BABYLON {
  26722. /**
  26723. * Interface for attribute information associated with buffer instanciation
  26724. */
  26725. export class InstancingAttributeInfo {
  26726. /**
  26727. * Index/offset of the attribute in the vertex shader
  26728. */
  26729. index: number;
  26730. /**
  26731. * size of the attribute, 1, 2, 3 or 4
  26732. */
  26733. attributeSize: number;
  26734. /**
  26735. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26736. * default is FLOAT
  26737. */
  26738. attribyteType: number;
  26739. /**
  26740. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26741. */
  26742. normalized: boolean;
  26743. /**
  26744. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26745. */
  26746. offset: number;
  26747. /**
  26748. * Name of the GLSL attribute, for debugging purpose only
  26749. */
  26750. attributeName: string;
  26751. }
  26752. /**
  26753. * Define options used to create a depth texture
  26754. */
  26755. export class DepthTextureCreationOptions {
  26756. /** Specifies whether or not a stencil should be allocated in the texture */
  26757. generateStencil?: boolean;
  26758. /** Specifies whether or not bilinear filtering is enable on the texture */
  26759. bilinearFiltering?: boolean;
  26760. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26761. comparisonFunction?: number;
  26762. /** Specifies if the created texture is a cube texture */
  26763. isCube?: boolean;
  26764. }
  26765. /**
  26766. * Class used to describe the capabilities of the engine relatively to the current browser
  26767. */
  26768. export class EngineCapabilities {
  26769. /** Maximum textures units per fragment shader */
  26770. maxTexturesImageUnits: number;
  26771. /** Maximum texture units per vertex shader */
  26772. maxVertexTextureImageUnits: number;
  26773. /** Maximum textures units in the entire pipeline */
  26774. maxCombinedTexturesImageUnits: number;
  26775. /** Maximum texture size */
  26776. maxTextureSize: number;
  26777. /** Maximum cube texture size */
  26778. maxCubemapTextureSize: number;
  26779. /** Maximum render texture size */
  26780. maxRenderTextureSize: number;
  26781. /** Maximum number of vertex attributes */
  26782. maxVertexAttribs: number;
  26783. /** Maximum number of varyings */
  26784. maxVaryingVectors: number;
  26785. /** Maximum number of uniforms per vertex shader */
  26786. maxVertexUniformVectors: number;
  26787. /** Maximum number of uniforms per fragment shader */
  26788. maxFragmentUniformVectors: number;
  26789. /** Defines if standard derivates (dx/dy) are supported */
  26790. standardDerivatives: boolean;
  26791. /** Defines if s3tc texture compression is supported */
  26792. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26793. /** Defines if pvrtc texture compression is supported */
  26794. pvrtc: any;
  26795. /** Defines if etc1 texture compression is supported */
  26796. etc1: any;
  26797. /** Defines if etc2 texture compression is supported */
  26798. etc2: any;
  26799. /** Defines if astc texture compression is supported */
  26800. astc: any;
  26801. /** Defines if float textures are supported */
  26802. textureFloat: boolean;
  26803. /** Defines if vertex array objects are supported */
  26804. vertexArrayObject: boolean;
  26805. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26806. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26807. /** Gets the maximum level of anisotropy supported */
  26808. maxAnisotropy: number;
  26809. /** Defines if instancing is supported */
  26810. instancedArrays: boolean;
  26811. /** Defines if 32 bits indices are supported */
  26812. uintIndices: boolean;
  26813. /** Defines if high precision shaders are supported */
  26814. highPrecisionShaderSupported: boolean;
  26815. /** Defines if depth reading in the fragment shader is supported */
  26816. fragmentDepthSupported: boolean;
  26817. /** Defines if float texture linear filtering is supported*/
  26818. textureFloatLinearFiltering: boolean;
  26819. /** Defines if rendering to float textures is supported */
  26820. textureFloatRender: boolean;
  26821. /** Defines if half float textures are supported*/
  26822. textureHalfFloat: boolean;
  26823. /** Defines if half float texture linear filtering is supported*/
  26824. textureHalfFloatLinearFiltering: boolean;
  26825. /** Defines if rendering to half float textures is supported */
  26826. textureHalfFloatRender: boolean;
  26827. /** Defines if textureLOD shader command is supported */
  26828. textureLOD: boolean;
  26829. /** Defines if draw buffers extension is supported */
  26830. drawBuffersExtension: boolean;
  26831. /** Defines if depth textures are supported */
  26832. depthTextureExtension: boolean;
  26833. /** Defines if float color buffer are supported */
  26834. colorBufferFloat: boolean;
  26835. /** Gets disjoint timer query extension (null if not supported) */
  26836. timerQuery: EXT_disjoint_timer_query;
  26837. /** Defines if timestamp can be used with timer query */
  26838. canUseTimestampForTimerQuery: boolean;
  26839. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26840. multiview: any;
  26841. /** Function used to let the system compiles shaders in background */
  26842. parallelShaderCompile: {
  26843. COMPLETION_STATUS_KHR: number;
  26844. };
  26845. }
  26846. /** Interface defining initialization parameters for Engine class */
  26847. export interface EngineOptions extends WebGLContextAttributes {
  26848. /**
  26849. * Defines if the engine should no exceed a specified device ratio
  26850. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26851. */
  26852. limitDeviceRatio?: number;
  26853. /**
  26854. * Defines if webvr should be enabled automatically
  26855. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26856. */
  26857. autoEnableWebVR?: boolean;
  26858. /**
  26859. * Defines if webgl2 should be turned off even if supported
  26860. * @see http://doc.babylonjs.com/features/webgl2
  26861. */
  26862. disableWebGL2Support?: boolean;
  26863. /**
  26864. * Defines if webaudio should be initialized as well
  26865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26866. */
  26867. audioEngine?: boolean;
  26868. /**
  26869. * Defines if animations should run using a deterministic lock step
  26870. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26871. */
  26872. deterministicLockstep?: boolean;
  26873. /** Defines the maximum steps to use with deterministic lock step mode */
  26874. lockstepMaxSteps?: number;
  26875. /**
  26876. * Defines that engine should ignore context lost events
  26877. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26878. */
  26879. doNotHandleContextLost?: boolean;
  26880. /**
  26881. * Defines that engine should ignore modifying touch action attribute and style
  26882. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26883. */
  26884. doNotHandleTouchAction?: boolean;
  26885. /**
  26886. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26887. */
  26888. useHighPrecisionFloats?: boolean;
  26889. }
  26890. /**
  26891. * Defines the interface used by display changed events
  26892. */
  26893. export interface IDisplayChangedEventArgs {
  26894. /** Gets the vrDisplay object (if any) */
  26895. vrDisplay: Nullable<any>;
  26896. /** Gets a boolean indicating if webVR is supported */
  26897. vrSupported: boolean;
  26898. }
  26899. /**
  26900. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26901. */
  26902. export class Engine {
  26903. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26904. static ExceptionList: ({
  26905. key: string;
  26906. capture: string;
  26907. captureConstraint: number;
  26908. targets: string[];
  26909. } | {
  26910. key: string;
  26911. capture: null;
  26912. captureConstraint: null;
  26913. targets: string[];
  26914. })[];
  26915. /** Gets the list of created engines */
  26916. static readonly Instances: Engine[];
  26917. /**
  26918. * Gets the latest created engine
  26919. */
  26920. static readonly LastCreatedEngine: Nullable<Engine>;
  26921. /**
  26922. * Gets the latest created scene
  26923. */
  26924. static readonly LastCreatedScene: Nullable<Scene>;
  26925. /**
  26926. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26927. * @param flag defines which part of the materials must be marked as dirty
  26928. * @param predicate defines a predicate used to filter which materials should be affected
  26929. */
  26930. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26931. /**
  26932. * Hidden
  26933. */
  26934. static _TextureLoaders: IInternalTextureLoader[];
  26935. /** Defines that alpha blending is disabled */
  26936. static readonly ALPHA_DISABLE: number;
  26937. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26938. static readonly ALPHA_ADD: number;
  26939. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26940. static readonly ALPHA_COMBINE: number;
  26941. /** Defines that alpha blending to DEST - SRC * DEST */
  26942. static readonly ALPHA_SUBTRACT: number;
  26943. /** Defines that alpha blending to SRC * DEST */
  26944. static readonly ALPHA_MULTIPLY: number;
  26945. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26946. static readonly ALPHA_MAXIMIZED: number;
  26947. /** Defines that alpha blending to SRC + DEST */
  26948. static readonly ALPHA_ONEONE: number;
  26949. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26950. static readonly ALPHA_PREMULTIPLIED: number;
  26951. /**
  26952. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26953. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26954. */
  26955. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26956. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26957. static readonly ALPHA_INTERPOLATE: number;
  26958. /**
  26959. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26960. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26961. */
  26962. static readonly ALPHA_SCREENMODE: number;
  26963. /** Defines that the ressource is not delayed*/
  26964. static readonly DELAYLOADSTATE_NONE: number;
  26965. /** Defines that the ressource was successfully delay loaded */
  26966. static readonly DELAYLOADSTATE_LOADED: number;
  26967. /** Defines that the ressource is currently delay loading */
  26968. static readonly DELAYLOADSTATE_LOADING: number;
  26969. /** Defines that the ressource is delayed and has not started loading */
  26970. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26972. static readonly NEVER: number;
  26973. /** 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 */
  26974. static readonly ALWAYS: number;
  26975. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26976. static readonly LESS: number;
  26977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26978. static readonly EQUAL: number;
  26979. /** 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 */
  26980. static readonly LEQUAL: number;
  26981. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26982. static readonly GREATER: number;
  26983. /** 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 */
  26984. static readonly GEQUAL: number;
  26985. /** 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 */
  26986. static readonly NOTEQUAL: number;
  26987. /** Passed to stencilOperation to specify that stencil value must be kept */
  26988. static readonly KEEP: number;
  26989. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26990. static readonly REPLACE: number;
  26991. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26992. static readonly INCR: number;
  26993. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26994. static readonly DECR: number;
  26995. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26996. static readonly INVERT: number;
  26997. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26998. static readonly INCR_WRAP: number;
  26999. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27000. static readonly DECR_WRAP: number;
  27001. /** Texture is not repeating outside of 0..1 UVs */
  27002. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27003. /** Texture is repeating outside of 0..1 UVs */
  27004. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27005. /** Texture is repeating and mirrored */
  27006. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27007. /** ALPHA */
  27008. static readonly TEXTUREFORMAT_ALPHA: number;
  27009. /** LUMINANCE */
  27010. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27011. /** LUMINANCE_ALPHA */
  27012. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27013. /** RGB */
  27014. static readonly TEXTUREFORMAT_RGB: number;
  27015. /** RGBA */
  27016. static readonly TEXTUREFORMAT_RGBA: number;
  27017. /** RED */
  27018. static readonly TEXTUREFORMAT_RED: number;
  27019. /** RED (2nd reference) */
  27020. static readonly TEXTUREFORMAT_R: number;
  27021. /** RG */
  27022. static readonly TEXTUREFORMAT_RG: number;
  27023. /** RED_INTEGER */
  27024. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27025. /** RED_INTEGER (2nd reference) */
  27026. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27027. /** RG_INTEGER */
  27028. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27029. /** RGB_INTEGER */
  27030. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27031. /** RGBA_INTEGER */
  27032. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27033. /** UNSIGNED_BYTE */
  27034. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27035. /** UNSIGNED_BYTE (2nd reference) */
  27036. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27037. /** FLOAT */
  27038. static readonly TEXTURETYPE_FLOAT: number;
  27039. /** HALF_FLOAT */
  27040. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27041. /** BYTE */
  27042. static readonly TEXTURETYPE_BYTE: number;
  27043. /** SHORT */
  27044. static readonly TEXTURETYPE_SHORT: number;
  27045. /** UNSIGNED_SHORT */
  27046. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27047. /** INT */
  27048. static readonly TEXTURETYPE_INT: number;
  27049. /** UNSIGNED_INT */
  27050. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27051. /** UNSIGNED_SHORT_4_4_4_4 */
  27052. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27053. /** UNSIGNED_SHORT_5_5_5_1 */
  27054. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27055. /** UNSIGNED_SHORT_5_6_5 */
  27056. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27057. /** UNSIGNED_INT_2_10_10_10_REV */
  27058. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27059. /** UNSIGNED_INT_24_8 */
  27060. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27061. /** UNSIGNED_INT_10F_11F_11F_REV */
  27062. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27063. /** UNSIGNED_INT_5_9_9_9_REV */
  27064. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27065. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27066. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27067. /** nearest is mag = nearest and min = nearest and mip = linear */
  27068. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27069. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27070. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27071. /** Trilinear is mag = linear and min = linear and mip = linear */
  27072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27073. /** nearest is mag = nearest and min = nearest and mip = linear */
  27074. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27076. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27077. /** Trilinear is mag = linear and min = linear and mip = linear */
  27078. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27079. /** mag = nearest and min = nearest and mip = nearest */
  27080. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27081. /** mag = nearest and min = linear and mip = nearest */
  27082. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27083. /** mag = nearest and min = linear and mip = linear */
  27084. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27085. /** mag = nearest and min = linear and mip = none */
  27086. static readonly TEXTURE_NEAREST_LINEAR: number;
  27087. /** mag = nearest and min = nearest and mip = none */
  27088. static readonly TEXTURE_NEAREST_NEAREST: number;
  27089. /** mag = linear and min = nearest and mip = nearest */
  27090. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27091. /** mag = linear and min = nearest and mip = linear */
  27092. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27093. /** mag = linear and min = linear and mip = none */
  27094. static readonly TEXTURE_LINEAR_LINEAR: number;
  27095. /** mag = linear and min = nearest and mip = none */
  27096. static readonly TEXTURE_LINEAR_NEAREST: number;
  27097. /** Explicit coordinates mode */
  27098. static readonly TEXTURE_EXPLICIT_MODE: number;
  27099. /** Spherical coordinates mode */
  27100. static readonly TEXTURE_SPHERICAL_MODE: number;
  27101. /** Planar coordinates mode */
  27102. static readonly TEXTURE_PLANAR_MODE: number;
  27103. /** Cubic coordinates mode */
  27104. static readonly TEXTURE_CUBIC_MODE: number;
  27105. /** Projection coordinates mode */
  27106. static readonly TEXTURE_PROJECTION_MODE: number;
  27107. /** Skybox coordinates mode */
  27108. static readonly TEXTURE_SKYBOX_MODE: number;
  27109. /** Inverse Cubic coordinates mode */
  27110. static readonly TEXTURE_INVCUBIC_MODE: number;
  27111. /** Equirectangular coordinates mode */
  27112. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27113. /** Equirectangular Fixed coordinates mode */
  27114. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27115. /** Equirectangular Fixed Mirrored coordinates mode */
  27116. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27117. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27118. static readonly SCALEMODE_FLOOR: number;
  27119. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27120. static readonly SCALEMODE_NEAREST: number;
  27121. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27122. static readonly SCALEMODE_CEILING: number;
  27123. /**
  27124. * Returns the current npm package of the sdk
  27125. */
  27126. static readonly NpmPackage: string;
  27127. /**
  27128. * Returns the current version of the framework
  27129. */
  27130. static readonly Version: string;
  27131. /**
  27132. * Returns a string describing the current engine
  27133. */
  27134. readonly description: string;
  27135. /**
  27136. * Gets or sets the epsilon value used by collision engine
  27137. */
  27138. static CollisionsEpsilon: number;
  27139. /**
  27140. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27141. */
  27142. static ShadersRepository: string;
  27143. /**
  27144. * Method called to create the default loading screen.
  27145. * This can be overriden in your own app.
  27146. * @param canvas The rendering canvas element
  27147. * @returns The loading screen
  27148. */
  27149. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27150. /**
  27151. * Method called to create the default rescale post process on each engine.
  27152. */
  27153. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27154. /**
  27155. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27156. */
  27157. forcePOTTextures: boolean;
  27158. /**
  27159. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27160. */
  27161. isFullscreen: boolean;
  27162. /**
  27163. * Gets a boolean indicating if the pointer is currently locked
  27164. */
  27165. isPointerLock: boolean;
  27166. /**
  27167. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27168. */
  27169. cullBackFaces: boolean;
  27170. /**
  27171. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27172. */
  27173. renderEvenInBackground: boolean;
  27174. /**
  27175. * Gets or sets a boolean indicating that cache can be kept between frames
  27176. */
  27177. preventCacheWipeBetweenFrames: boolean;
  27178. /**
  27179. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27180. **/
  27181. enableOfflineSupport: boolean;
  27182. /**
  27183. * 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)
  27184. **/
  27185. disableManifestCheck: boolean;
  27186. /**
  27187. * Gets the list of created scenes
  27188. */
  27189. scenes: Scene[];
  27190. /**
  27191. * Event raised when a new scene is created
  27192. */
  27193. onNewSceneAddedObservable: Observable<Scene>;
  27194. /**
  27195. * Gets the list of created postprocesses
  27196. */
  27197. postProcesses: PostProcess[];
  27198. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27199. validateShaderPrograms: boolean;
  27200. /**
  27201. * Observable event triggered each time the rendering canvas is resized
  27202. */
  27203. onResizeObservable: Observable<Engine>;
  27204. /**
  27205. * Observable event triggered each time the canvas loses focus
  27206. */
  27207. onCanvasBlurObservable: Observable<Engine>;
  27208. /**
  27209. * Observable event triggered each time the canvas gains focus
  27210. */
  27211. onCanvasFocusObservable: Observable<Engine>;
  27212. /**
  27213. * Observable event triggered each time the canvas receives pointerout event
  27214. */
  27215. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27216. /**
  27217. * Observable event triggered before each texture is initialized
  27218. */
  27219. onBeforeTextureInitObservable: Observable<Texture>;
  27220. private _vrDisplay;
  27221. private _vrSupported;
  27222. private _oldSize;
  27223. private _oldHardwareScaleFactor;
  27224. private _vrExclusivePointerMode;
  27225. private _webVRInitPromise;
  27226. /**
  27227. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27228. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27229. */
  27230. readonly isInVRExclusivePointerMode: boolean;
  27231. /**
  27232. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27233. */
  27234. disableUniformBuffers: boolean;
  27235. /** @hidden */
  27236. _uniformBuffers: UniformBuffer[];
  27237. /**
  27238. * Gets a boolean indicating that the engine supports uniform buffers
  27239. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27240. */
  27241. readonly supportsUniformBuffers: boolean;
  27242. /**
  27243. * Observable raised when the engine begins a new frame
  27244. */
  27245. onBeginFrameObservable: Observable<Engine>;
  27246. /**
  27247. * If set, will be used to request the next animation frame for the render loop
  27248. */
  27249. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27250. /**
  27251. * Observable raised when the engine ends the current frame
  27252. */
  27253. onEndFrameObservable: Observable<Engine>;
  27254. /**
  27255. * Observable raised when the engine is about to compile a shader
  27256. */
  27257. onBeforeShaderCompilationObservable: Observable<Engine>;
  27258. /**
  27259. * Observable raised when the engine has jsut compiled a shader
  27260. */
  27261. onAfterShaderCompilationObservable: Observable<Engine>;
  27262. /** @hidden */
  27263. _gl: WebGLRenderingContext;
  27264. private _renderingCanvas;
  27265. private _windowIsBackground;
  27266. private _webGLVersion;
  27267. protected _highPrecisionShadersAllowed: boolean;
  27268. /** @hidden */
  27269. readonly _shouldUseHighPrecisionShader: boolean;
  27270. /**
  27271. * Gets a boolean indicating that only power of 2 textures are supported
  27272. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27273. */
  27274. readonly needPOTTextures: boolean;
  27275. /** @hidden */
  27276. _badOS: boolean;
  27277. /** @hidden */
  27278. _badDesktopOS: boolean;
  27279. /**
  27280. * Gets the audio engine
  27281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27282. * @ignorenaming
  27283. */
  27284. static audioEngine: IAudioEngine;
  27285. /**
  27286. * Default AudioEngine factory responsible of creating the Audio Engine.
  27287. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27288. */
  27289. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27290. /**
  27291. * Default offline support factory responsible of creating a tool used to store data locally.
  27292. * By default, this will create a Database object if the workload has been embedded.
  27293. */
  27294. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27295. private _onFocus;
  27296. private _onBlur;
  27297. private _onCanvasPointerOut;
  27298. private _onCanvasBlur;
  27299. private _onCanvasFocus;
  27300. private _onFullscreenChange;
  27301. private _onPointerLockChange;
  27302. private _onVRDisplayPointerRestricted;
  27303. private _onVRDisplayPointerUnrestricted;
  27304. private _onVrDisplayConnect;
  27305. private _onVrDisplayDisconnect;
  27306. private _onVrDisplayPresentChange;
  27307. /**
  27308. * Observable signaled when VR display mode changes
  27309. */
  27310. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27311. /**
  27312. * Observable signaled when VR request present is complete
  27313. */
  27314. onVRRequestPresentComplete: Observable<boolean>;
  27315. /**
  27316. * Observable signaled when VR request present starts
  27317. */
  27318. onVRRequestPresentStart: Observable<Engine>;
  27319. private _hardwareScalingLevel;
  27320. /** @hidden */
  27321. protected _caps: EngineCapabilities;
  27322. private _pointerLockRequested;
  27323. private _isStencilEnable;
  27324. private _colorWrite;
  27325. private _loadingScreen;
  27326. /** @hidden */
  27327. _drawCalls: PerfCounter;
  27328. private _glVersion;
  27329. private _glRenderer;
  27330. private _glVendor;
  27331. private _videoTextureSupported;
  27332. private _renderingQueueLaunched;
  27333. private _activeRenderLoops;
  27334. private _deterministicLockstep;
  27335. private _lockstepMaxSteps;
  27336. /**
  27337. * Observable signaled when a context lost event is raised
  27338. */
  27339. onContextLostObservable: Observable<Engine>;
  27340. /**
  27341. * Observable signaled when a context restored event is raised
  27342. */
  27343. onContextRestoredObservable: Observable<Engine>;
  27344. private _onContextLost;
  27345. private _onContextRestored;
  27346. private _contextWasLost;
  27347. private _doNotHandleContextLost;
  27348. /**
  27349. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27351. */
  27352. doNotHandleContextLost: boolean;
  27353. private _performanceMonitor;
  27354. private _fps;
  27355. private _deltaTime;
  27356. /**
  27357. * Turn this value on if you want to pause FPS computation when in background
  27358. */
  27359. disablePerformanceMonitorInBackground: boolean;
  27360. /**
  27361. * Gets the performance monitor attached to this engine
  27362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27363. */
  27364. readonly performanceMonitor: PerformanceMonitor;
  27365. /**
  27366. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27367. */
  27368. disableVertexArrayObjects: boolean;
  27369. /** @hidden */
  27370. protected _depthCullingState: _DepthCullingState;
  27371. /** @hidden */
  27372. protected _stencilState: _StencilState;
  27373. /** @hidden */
  27374. protected _alphaState: _AlphaState;
  27375. /** @hidden */
  27376. protected _alphaMode: number;
  27377. protected _internalTexturesCache: InternalTexture[];
  27378. /** @hidden */
  27379. protected _activeChannel: number;
  27380. private _currentTextureChannel;
  27381. /** @hidden */
  27382. protected _boundTexturesCache: {
  27383. [key: string]: Nullable<InternalTexture>;
  27384. };
  27385. /** @hidden */
  27386. protected _currentEffect: Nullable<Effect>;
  27387. /** @hidden */
  27388. protected _currentProgram: Nullable<WebGLProgram>;
  27389. private _compiledEffects;
  27390. private _vertexAttribArraysEnabled;
  27391. /** @hidden */
  27392. protected _cachedViewport: Nullable<Viewport>;
  27393. private _cachedVertexArrayObject;
  27394. /** @hidden */
  27395. protected _cachedVertexBuffers: any;
  27396. /** @hidden */
  27397. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27398. /** @hidden */
  27399. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27400. /** @hidden */
  27401. protected _currentRenderTarget: Nullable<InternalTexture>;
  27402. private _uintIndicesCurrentlySet;
  27403. private _currentBoundBuffer;
  27404. /** @hidden */
  27405. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27406. private _currentBufferPointers;
  27407. private _currentInstanceLocations;
  27408. private _currentInstanceBuffers;
  27409. private _textureUnits;
  27410. private _workingCanvas;
  27411. private _workingContext;
  27412. private _rescalePostProcess;
  27413. private _dummyFramebuffer;
  27414. private _externalData;
  27415. private _bindedRenderFunction;
  27416. private _vaoRecordInProgress;
  27417. private _mustWipeVertexAttributes;
  27418. private _emptyTexture;
  27419. private _emptyCubeTexture;
  27420. private _emptyTexture3D;
  27421. /** @hidden */
  27422. _frameHandler: number;
  27423. private _nextFreeTextureSlots;
  27424. private _maxSimultaneousTextures;
  27425. private _activeRequests;
  27426. private _texturesSupported;
  27427. private _textureFormatInUse;
  27428. /**
  27429. * Gets the list of texture formats supported
  27430. */
  27431. readonly texturesSupported: Array<string>;
  27432. /**
  27433. * Gets the list of texture formats in use
  27434. */
  27435. readonly textureFormatInUse: Nullable<string>;
  27436. /**
  27437. * Gets the current viewport
  27438. */
  27439. readonly currentViewport: Nullable<Viewport>;
  27440. /**
  27441. * Gets the default empty texture
  27442. */
  27443. readonly emptyTexture: InternalTexture;
  27444. /**
  27445. * Gets the default empty 3D texture
  27446. */
  27447. readonly emptyTexture3D: InternalTexture;
  27448. /**
  27449. * Gets the default empty cube texture
  27450. */
  27451. readonly emptyCubeTexture: InternalTexture;
  27452. /**
  27453. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27454. */
  27455. readonly premultipliedAlpha: boolean;
  27456. /**
  27457. * Creates a new engine
  27458. * @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
  27459. * @param antialias defines enable antialiasing (default: false)
  27460. * @param options defines further options to be sent to the getContext() function
  27461. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27462. */
  27463. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27464. private _disableTouchAction;
  27465. private _rebuildInternalTextures;
  27466. private _rebuildEffects;
  27467. /**
  27468. * Gets a boolean indicating if all created effects are ready
  27469. * @returns true if all effects are ready
  27470. */
  27471. areAllEffectsReady(): boolean;
  27472. private _rebuildBuffers;
  27473. private _initGLContext;
  27474. /**
  27475. * Gets version of the current webGL context
  27476. */
  27477. readonly webGLVersion: number;
  27478. /**
  27479. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27480. */
  27481. readonly isStencilEnable: boolean;
  27482. private _prepareWorkingCanvas;
  27483. /**
  27484. * Reset the texture cache to empty state
  27485. */
  27486. resetTextureCache(): void;
  27487. /**
  27488. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27489. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27490. * @returns true if engine is in deterministic lock step mode
  27491. */
  27492. isDeterministicLockStep(): boolean;
  27493. /**
  27494. * Gets the max steps when engine is running in deterministic lock step
  27495. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27496. * @returns the max steps
  27497. */
  27498. getLockstepMaxSteps(): number;
  27499. /**
  27500. * Gets an object containing information about the current webGL context
  27501. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27502. */
  27503. getGlInfo(): {
  27504. vendor: string;
  27505. renderer: string;
  27506. version: string;
  27507. };
  27508. /**
  27509. * Gets current aspect ratio
  27510. * @param camera defines the camera to use to get the aspect ratio
  27511. * @param useScreen defines if screen size must be used (or the current render target if any)
  27512. * @returns a number defining the aspect ratio
  27513. */
  27514. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27515. /**
  27516. * Gets current screen aspect ratio
  27517. * @returns a number defining the aspect ratio
  27518. */
  27519. getScreenAspectRatio(): number;
  27520. /**
  27521. * Gets the current render width
  27522. * @param useScreen defines if screen size must be used (or the current render target if any)
  27523. * @returns a number defining the current render width
  27524. */
  27525. getRenderWidth(useScreen?: boolean): number;
  27526. /**
  27527. * Gets the current render height
  27528. * @param useScreen defines if screen size must be used (or the current render target if any)
  27529. * @returns a number defining the current render height
  27530. */
  27531. getRenderHeight(useScreen?: boolean): number;
  27532. /**
  27533. * Gets the HTML canvas attached with the current webGL context
  27534. * @returns a HTML canvas
  27535. */
  27536. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27537. /**
  27538. * Gets the client rect of the HTML canvas attached with the current webGL context
  27539. * @returns a client rectanglee
  27540. */
  27541. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27542. /**
  27543. * Defines the hardware scaling level.
  27544. * By default the hardware scaling level is computed from the window device ratio.
  27545. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  27546. * @param level defines the level to use
  27547. */
  27548. setHardwareScalingLevel(level: number): void;
  27549. /**
  27550. * Gets the current hardware scaling level.
  27551. * By default the hardware scaling level is computed from the window device ratio.
  27552. * 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.
  27553. * @returns a number indicating the current hardware scaling level
  27554. */
  27555. getHardwareScalingLevel(): number;
  27556. /**
  27557. * Gets the list of loaded textures
  27558. * @returns an array containing all loaded textures
  27559. */
  27560. getLoadedTexturesCache(): InternalTexture[];
  27561. /**
  27562. * Gets the object containing all engine capabilities
  27563. * @returns the EngineCapabilities object
  27564. */
  27565. getCaps(): EngineCapabilities;
  27566. /**
  27567. * Gets the current depth function
  27568. * @returns a number defining the depth function
  27569. */
  27570. getDepthFunction(): Nullable<number>;
  27571. /**
  27572. * Sets the current depth function
  27573. * @param depthFunc defines the function to use
  27574. */
  27575. setDepthFunction(depthFunc: number): void;
  27576. /**
  27577. * Sets the current depth function to GREATER
  27578. */
  27579. setDepthFunctionToGreater(): void;
  27580. /**
  27581. * Sets the current depth function to GEQUAL
  27582. */
  27583. setDepthFunctionToGreaterOrEqual(): void;
  27584. /**
  27585. * Sets the current depth function to LESS
  27586. */
  27587. setDepthFunctionToLess(): void;
  27588. private _cachedStencilBuffer;
  27589. private _cachedStencilFunction;
  27590. private _cachedStencilMask;
  27591. private _cachedStencilOperationPass;
  27592. private _cachedStencilOperationFail;
  27593. private _cachedStencilOperationDepthFail;
  27594. private _cachedStencilReference;
  27595. /**
  27596. * Caches the the state of the stencil buffer
  27597. */
  27598. cacheStencilState(): void;
  27599. /**
  27600. * Restores the state of the stencil buffer
  27601. */
  27602. restoreStencilState(): void;
  27603. /**
  27604. * Sets the current depth function to LEQUAL
  27605. */
  27606. setDepthFunctionToLessOrEqual(): void;
  27607. /**
  27608. * Gets a boolean indicating if stencil buffer is enabled
  27609. * @returns the current stencil buffer state
  27610. */
  27611. getStencilBuffer(): boolean;
  27612. /**
  27613. * Enable or disable the stencil buffer
  27614. * @param enable defines if the stencil buffer must be enabled or disabled
  27615. */
  27616. setStencilBuffer(enable: boolean): void;
  27617. /**
  27618. * Gets the current stencil mask
  27619. * @returns a number defining the new stencil mask to use
  27620. */
  27621. getStencilMask(): number;
  27622. /**
  27623. * Sets the current stencil mask
  27624. * @param mask defines the new stencil mask to use
  27625. */
  27626. setStencilMask(mask: number): void;
  27627. /**
  27628. * Gets the current stencil function
  27629. * @returns a number defining the stencil function to use
  27630. */
  27631. getStencilFunction(): number;
  27632. /**
  27633. * Gets the current stencil reference value
  27634. * @returns a number defining the stencil reference value to use
  27635. */
  27636. getStencilFunctionReference(): number;
  27637. /**
  27638. * Gets the current stencil mask
  27639. * @returns a number defining the stencil mask to use
  27640. */
  27641. getStencilFunctionMask(): number;
  27642. /**
  27643. * Sets the current stencil function
  27644. * @param stencilFunc defines the new stencil function to use
  27645. */
  27646. setStencilFunction(stencilFunc: number): void;
  27647. /**
  27648. * Sets the current stencil reference
  27649. * @param reference defines the new stencil reference to use
  27650. */
  27651. setStencilFunctionReference(reference: number): void;
  27652. /**
  27653. * Sets the current stencil mask
  27654. * @param mask defines the new stencil mask to use
  27655. */
  27656. setStencilFunctionMask(mask: number): void;
  27657. /**
  27658. * Gets the current stencil operation when stencil fails
  27659. * @returns a number defining stencil operation to use when stencil fails
  27660. */
  27661. getStencilOperationFail(): number;
  27662. /**
  27663. * Gets the current stencil operation when depth fails
  27664. * @returns a number defining stencil operation to use when depth fails
  27665. */
  27666. getStencilOperationDepthFail(): number;
  27667. /**
  27668. * Gets the current stencil operation when stencil passes
  27669. * @returns a number defining stencil operation to use when stencil passes
  27670. */
  27671. getStencilOperationPass(): number;
  27672. /**
  27673. * Sets the stencil operation to use when stencil fails
  27674. * @param operation defines the stencil operation to use when stencil fails
  27675. */
  27676. setStencilOperationFail(operation: number): void;
  27677. /**
  27678. * Sets the stencil operation to use when depth fails
  27679. * @param operation defines the stencil operation to use when depth fails
  27680. */
  27681. setStencilOperationDepthFail(operation: number): void;
  27682. /**
  27683. * Sets the stencil operation to use when stencil passes
  27684. * @param operation defines the stencil operation to use when stencil passes
  27685. */
  27686. setStencilOperationPass(operation: number): void;
  27687. /**
  27688. * Sets a boolean indicating if the dithering state is enabled or disabled
  27689. * @param value defines the dithering state
  27690. */
  27691. setDitheringState(value: boolean): void;
  27692. /**
  27693. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27694. * @param value defines the rasterizer state
  27695. */
  27696. setRasterizerState(value: boolean): void;
  27697. /**
  27698. * stop executing a render loop function and remove it from the execution array
  27699. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27700. */
  27701. stopRenderLoop(renderFunction?: () => void): void;
  27702. /** @hidden */
  27703. _renderLoop(): void;
  27704. /**
  27705. * Register and execute a render loop. The engine can have more than one render function
  27706. * @param renderFunction defines the function to continuously execute
  27707. */
  27708. runRenderLoop(renderFunction: () => void): void;
  27709. /**
  27710. * Toggle full screen mode
  27711. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27712. */
  27713. switchFullscreen(requestPointerLock: boolean): void;
  27714. /**
  27715. * Enters full screen mode
  27716. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27717. */
  27718. enterFullscreen(requestPointerLock: boolean): void;
  27719. /**
  27720. * Exits full screen mode
  27721. */
  27722. exitFullscreen(): void;
  27723. /**
  27724. * Clear the current render buffer or the current render target (if any is set up)
  27725. * @param color defines the color to use
  27726. * @param backBuffer defines if the back buffer must be cleared
  27727. * @param depth defines if the depth buffer must be cleared
  27728. * @param stencil defines if the stencil buffer must be cleared
  27729. */
  27730. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27731. /**
  27732. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27733. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27734. * @param y defines the y-coordinate of the corner of the clear rectangle
  27735. * @param width defines the width of the clear rectangle
  27736. * @param height defines the height of the clear rectangle
  27737. * @param clearColor defines the clear color
  27738. */
  27739. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27740. /**
  27741. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27742. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27743. * @param y defines the y-coordinate of the corner of the clear rectangle
  27744. * @param width defines the width of the clear rectangle
  27745. * @param height defines the height of the clear rectangle
  27746. */
  27747. enableScissor(x: number, y: number, width: number, height: number): void;
  27748. /**
  27749. * Disable previously set scissor test rectangle
  27750. */
  27751. disableScissor(): void;
  27752. private _viewportCached;
  27753. /** @hidden */
  27754. _viewport(x: number, y: number, width: number, height: number): void;
  27755. /**
  27756. * Set the WebGL's viewport
  27757. * @param viewport defines the viewport element to be used
  27758. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27759. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27760. */
  27761. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27762. /**
  27763. * Directly set the WebGL Viewport
  27764. * @param x defines the x coordinate of the viewport (in screen space)
  27765. * @param y defines the y coordinate of the viewport (in screen space)
  27766. * @param width defines the width of the viewport (in screen space)
  27767. * @param height defines the height of the viewport (in screen space)
  27768. * @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
  27769. */
  27770. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27771. /**
  27772. * Begin a new frame
  27773. */
  27774. beginFrame(): void;
  27775. /**
  27776. * Enf the current frame
  27777. */
  27778. endFrame(): void;
  27779. /**
  27780. * Resize the view according to the canvas' size
  27781. */
  27782. resize(): void;
  27783. /**
  27784. * Force a specific size of the canvas
  27785. * @param width defines the new canvas' width
  27786. * @param height defines the new canvas' height
  27787. */
  27788. setSize(width: number, height: number): void;
  27789. /**
  27790. * Gets a boolean indicating if a webVR device was detected
  27791. * @returns true if a webVR device was detected
  27792. */
  27793. isVRDevicePresent(): boolean;
  27794. /**
  27795. * Gets the current webVR device
  27796. * @returns the current webVR device (or null)
  27797. */
  27798. getVRDevice(): any;
  27799. /**
  27800. * Initializes a webVR display and starts listening to display change events
  27801. * The onVRDisplayChangedObservable will be notified upon these changes
  27802. * @returns The onVRDisplayChangedObservable
  27803. */
  27804. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27805. /**
  27806. * Initializes a webVR display and starts listening to display change events
  27807. * The onVRDisplayChangedObservable will be notified upon these changes
  27808. * @returns A promise containing a VRDisplay and if vr is supported
  27809. */
  27810. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27811. /**
  27812. * Call this function to switch to webVR mode
  27813. * Will do nothing if webVR is not supported or if there is no webVR device
  27814. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27815. */
  27816. enableVR(): void;
  27817. /**
  27818. * Call this function to leave webVR mode
  27819. * Will do nothing if webVR is not supported or if there is no webVR device
  27820. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27821. */
  27822. disableVR(): void;
  27823. private _onVRFullScreenTriggered;
  27824. private _getVRDisplaysAsync;
  27825. /**
  27826. * Binds the frame buffer to the specified texture.
  27827. * @param texture The texture to render to or null for the default canvas
  27828. * @param faceIndex The face of the texture to render to in case of cube texture
  27829. * @param requiredWidth The width of the target to render to
  27830. * @param requiredHeight The height of the target to render to
  27831. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27832. * @param depthStencilTexture The depth stencil texture to use to render
  27833. * @param lodLevel defines le lod level to bind to the frame buffer
  27834. */
  27835. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27836. private bindUnboundFramebuffer;
  27837. /**
  27838. * Unbind the current render target texture from the webGL context
  27839. * @param texture defines the render target texture to unbind
  27840. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27841. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27842. */
  27843. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27844. /**
  27845. * Unbind a list of render target textures from the webGL context
  27846. * This is used only when drawBuffer extension or webGL2 are active
  27847. * @param textures defines the render target textures to unbind
  27848. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27849. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27850. */
  27851. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27852. /**
  27853. * Force the mipmap generation for the given render target texture
  27854. * @param texture defines the render target texture to use
  27855. */
  27856. generateMipMapsForCubemap(texture: InternalTexture): void;
  27857. /**
  27858. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27859. */
  27860. flushFramebuffer(): void;
  27861. /**
  27862. * Unbind the current render target and bind the default framebuffer
  27863. */
  27864. restoreDefaultFramebuffer(): void;
  27865. /**
  27866. * Create an uniform buffer
  27867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27868. * @param elements defines the content of the uniform buffer
  27869. * @returns the webGL uniform buffer
  27870. */
  27871. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27872. /**
  27873. * Create a dynamic uniform buffer
  27874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27875. * @param elements defines the content of the uniform buffer
  27876. * @returns the webGL uniform buffer
  27877. */
  27878. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27879. /**
  27880. * Update an existing uniform buffer
  27881. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27882. * @param uniformBuffer defines the target uniform buffer
  27883. * @param elements defines the content to update
  27884. * @param offset defines the offset in the uniform buffer where update should start
  27885. * @param count defines the size of the data to update
  27886. */
  27887. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27888. private _resetVertexBufferBinding;
  27889. /**
  27890. * Creates a vertex buffer
  27891. * @param data the data for the vertex buffer
  27892. * @returns the new WebGL static buffer
  27893. */
  27894. createVertexBuffer(data: DataArray): WebGLBuffer;
  27895. /**
  27896. * Creates a dynamic vertex buffer
  27897. * @param data the data for the dynamic vertex buffer
  27898. * @returns the new WebGL dynamic buffer
  27899. */
  27900. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27901. /**
  27902. * Update a dynamic index buffer
  27903. * @param indexBuffer defines the target index buffer
  27904. * @param indices defines the data to update
  27905. * @param offset defines the offset in the target index buffer where update should start
  27906. */
  27907. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27908. /**
  27909. * Updates a dynamic vertex buffer.
  27910. * @param vertexBuffer the vertex buffer to update
  27911. * @param data the data used to update the vertex buffer
  27912. * @param byteOffset the byte offset of the data
  27913. * @param byteLength the byte length of the data
  27914. */
  27915. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27916. private _resetIndexBufferBinding;
  27917. /**
  27918. * Creates a new index buffer
  27919. * @param indices defines the content of the index buffer
  27920. * @param updatable defines if the index buffer must be updatable
  27921. * @returns a new webGL buffer
  27922. */
  27923. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27924. /**
  27925. * Bind a webGL buffer to the webGL context
  27926. * @param buffer defines the buffer to bind
  27927. */
  27928. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27929. /**
  27930. * Bind an uniform buffer to the current webGL context
  27931. * @param buffer defines the buffer to bind
  27932. */
  27933. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27934. /**
  27935. * Bind a buffer to the current webGL context at a given location
  27936. * @param buffer defines the buffer to bind
  27937. * @param location defines the index where to bind the buffer
  27938. */
  27939. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27940. /**
  27941. * Bind a specific block at a given index in a specific shader program
  27942. * @param shaderProgram defines the shader program
  27943. * @param blockName defines the block name
  27944. * @param index defines the index where to bind the block
  27945. */
  27946. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27947. private bindIndexBuffer;
  27948. private bindBuffer;
  27949. /**
  27950. * update the bound buffer with the given data
  27951. * @param data defines the data to update
  27952. */
  27953. updateArrayBuffer(data: Float32Array): void;
  27954. private _vertexAttribPointer;
  27955. private _bindIndexBufferWithCache;
  27956. private _bindVertexBuffersAttributes;
  27957. /**
  27958. * Records a vertex array object
  27959. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27960. * @param vertexBuffers defines the list of vertex buffers to store
  27961. * @param indexBuffer defines the index buffer to store
  27962. * @param effect defines the effect to store
  27963. * @returns the new vertex array object
  27964. */
  27965. recordVertexArrayObject(vertexBuffers: {
  27966. [key: string]: VertexBuffer;
  27967. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27968. /**
  27969. * Bind a specific vertex array object
  27970. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27971. * @param vertexArrayObject defines the vertex array object to bind
  27972. * @param indexBuffer defines the index buffer to bind
  27973. */
  27974. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27975. /**
  27976. * Bind webGl buffers directly to the webGL context
  27977. * @param vertexBuffer defines the vertex buffer to bind
  27978. * @param indexBuffer defines the index buffer to bind
  27979. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27980. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27981. * @param effect defines the effect associated with the vertex buffer
  27982. */
  27983. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27984. private _unbindVertexArrayObject;
  27985. /**
  27986. * Bind a list of vertex buffers to the webGL context
  27987. * @param vertexBuffers defines the list of vertex buffers to bind
  27988. * @param indexBuffer defines the index buffer to bind
  27989. * @param effect defines the effect associated with the vertex buffers
  27990. */
  27991. bindBuffers(vertexBuffers: {
  27992. [key: string]: Nullable<VertexBuffer>;
  27993. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27994. /**
  27995. * Unbind all instance attributes
  27996. */
  27997. unbindInstanceAttributes(): void;
  27998. /**
  27999. * Release and free the memory of a vertex array object
  28000. * @param vao defines the vertex array object to delete
  28001. */
  28002. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28003. /** @hidden */
  28004. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28005. /**
  28006. * Creates a webGL buffer to use with instanciation
  28007. * @param capacity defines the size of the buffer
  28008. * @returns the webGL buffer
  28009. */
  28010. createInstancesBuffer(capacity: number): WebGLBuffer;
  28011. /**
  28012. * Delete a webGL buffer used with instanciation
  28013. * @param buffer defines the webGL buffer to delete
  28014. */
  28015. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28016. /**
  28017. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28018. * @param instancesBuffer defines the webGL buffer to update and bind
  28019. * @param data defines the data to store in the buffer
  28020. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28021. */
  28022. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28023. /**
  28024. * Apply all cached states (depth, culling, stencil and alpha)
  28025. */
  28026. applyStates(): void;
  28027. /**
  28028. * Send a draw order
  28029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28030. * @param indexStart defines the starting index
  28031. * @param indexCount defines the number of index to draw
  28032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28033. */
  28034. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28035. /**
  28036. * Draw a list of points
  28037. * @param verticesStart defines the index of first vertex to draw
  28038. * @param verticesCount defines the count of vertices to draw
  28039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28040. */
  28041. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28042. /**
  28043. * Draw a list of unindexed primitives
  28044. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28045. * @param verticesStart defines the index of first vertex to draw
  28046. * @param verticesCount defines the count of vertices to draw
  28047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28048. */
  28049. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28050. /**
  28051. * Draw a list of indexed primitives
  28052. * @param fillMode defines the primitive to use
  28053. * @param indexStart defines the starting index
  28054. * @param indexCount defines the number of index to draw
  28055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28056. */
  28057. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28058. /**
  28059. * Draw a list of unindexed primitives
  28060. * @param fillMode defines the primitive to use
  28061. * @param verticesStart defines the index of first vertex to draw
  28062. * @param verticesCount defines the count of vertices to draw
  28063. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28064. */
  28065. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28066. private _drawMode;
  28067. /** @hidden */
  28068. _releaseEffect(effect: Effect): void;
  28069. /** @hidden */
  28070. _deleteProgram(program: WebGLProgram): void;
  28071. /**
  28072. * Create a new effect (used to store vertex/fragment shaders)
  28073. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28074. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28075. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28076. * @param samplers defines an array of string used to represent textures
  28077. * @param defines defines the string containing the defines to use to compile the shaders
  28078. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28079. * @param onCompiled defines a function to call when the effect creation is successful
  28080. * @param onError defines a function to call when the effect creation has failed
  28081. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28082. * @returns the new Effect
  28083. */
  28084. 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;
  28085. private _compileShader;
  28086. private _compileRawShader;
  28087. /**
  28088. * Directly creates a webGL program
  28089. * @param vertexCode defines the vertex shader code to use
  28090. * @param fragmentCode defines the fragment shader code to use
  28091. * @param context defines the webGL context to use (if not set, the current one will be used)
  28092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28093. * @returns the new webGL program
  28094. */
  28095. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28096. /**
  28097. * Creates a webGL program
  28098. * @param vertexCode defines the vertex shader code to use
  28099. * @param fragmentCode defines the fragment shader code to use
  28100. * @param defines defines the string containing the defines to use to compile the shaders
  28101. * @param context defines the webGL context to use (if not set, the current one will be used)
  28102. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28103. * @returns the new webGL program
  28104. */
  28105. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28106. private _createShaderProgram;
  28107. private _finalizeProgram;
  28108. /** @hidden */
  28109. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28110. /** @hidden */
  28111. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28112. /**
  28113. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28114. * @param shaderProgram defines the webGL program to use
  28115. * @param uniformsNames defines the list of uniform names
  28116. * @returns an array of webGL uniform locations
  28117. */
  28118. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28119. /**
  28120. * Gets the lsit of active attributes for a given webGL program
  28121. * @param shaderProgram defines the webGL program to use
  28122. * @param attributesNames defines the list of attribute names to get
  28123. * @returns an array of indices indicating the offset of each attribute
  28124. */
  28125. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28126. /**
  28127. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28128. * @param effect defines the effect to activate
  28129. */
  28130. enableEffect(effect: Nullable<Effect>): void;
  28131. /**
  28132. * Set the value of an uniform to an array of int32
  28133. * @param uniform defines the webGL uniform location where to store the value
  28134. * @param array defines the array of int32 to store
  28135. */
  28136. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28137. /**
  28138. * Set the value of an uniform to an array of int32 (stored as vec2)
  28139. * @param uniform defines the webGL uniform location where to store the value
  28140. * @param array defines the array of int32 to store
  28141. */
  28142. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28143. /**
  28144. * Set the value of an uniform to an array of int32 (stored as vec3)
  28145. * @param uniform defines the webGL uniform location where to store the value
  28146. * @param array defines the array of int32 to store
  28147. */
  28148. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28149. /**
  28150. * Set the value of an uniform to an array of int32 (stored as vec4)
  28151. * @param uniform defines the webGL uniform location where to store the value
  28152. * @param array defines the array of int32 to store
  28153. */
  28154. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28155. /**
  28156. * Set the value of an uniform to an array of float32
  28157. * @param uniform defines the webGL uniform location where to store the value
  28158. * @param array defines the array of float32 to store
  28159. */
  28160. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28161. /**
  28162. * Set the value of an uniform to an array of float32 (stored as vec2)
  28163. * @param uniform defines the webGL uniform location where to store the value
  28164. * @param array defines the array of float32 to store
  28165. */
  28166. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28167. /**
  28168. * Set the value of an uniform to an array of float32 (stored as vec3)
  28169. * @param uniform defines the webGL uniform location where to store the value
  28170. * @param array defines the array of float32 to store
  28171. */
  28172. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28173. /**
  28174. * Set the value of an uniform to an array of float32 (stored as vec4)
  28175. * @param uniform defines the webGL uniform location where to store the value
  28176. * @param array defines the array of float32 to store
  28177. */
  28178. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28179. /**
  28180. * Set the value of an uniform to an array of number
  28181. * @param uniform defines the webGL uniform location where to store the value
  28182. * @param array defines the array of number to store
  28183. */
  28184. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28185. /**
  28186. * Set the value of an uniform to an array of number (stored as vec2)
  28187. * @param uniform defines the webGL uniform location where to store the value
  28188. * @param array defines the array of number to store
  28189. */
  28190. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28191. /**
  28192. * Set the value of an uniform to an array of number (stored as vec3)
  28193. * @param uniform defines the webGL uniform location where to store the value
  28194. * @param array defines the array of number to store
  28195. */
  28196. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28197. /**
  28198. * Set the value of an uniform to an array of number (stored as vec4)
  28199. * @param uniform defines the webGL uniform location where to store the value
  28200. * @param array defines the array of number to store
  28201. */
  28202. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28203. /**
  28204. * Set the value of an uniform to an array of float32 (stored as matrices)
  28205. * @param uniform defines the webGL uniform location where to store the value
  28206. * @param matrices defines the array of float32 to store
  28207. */
  28208. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28209. /**
  28210. * Set the value of an uniform to a matrix
  28211. * @param uniform defines the webGL uniform location where to store the value
  28212. * @param matrix defines the matrix to store
  28213. */
  28214. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28215. /**
  28216. * Set the value of an uniform to a matrix (3x3)
  28217. * @param uniform defines the webGL uniform location where to store the value
  28218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28219. */
  28220. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28221. /**
  28222. * Set the value of an uniform to a matrix (2x2)
  28223. * @param uniform defines the webGL uniform location where to store the value
  28224. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28225. */
  28226. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28227. /**
  28228. * Set the value of an uniform to a number (int)
  28229. * @param uniform defines the webGL uniform location where to store the value
  28230. * @param value defines the int number to store
  28231. */
  28232. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28233. /**
  28234. * Set the value of an uniform to a number (float)
  28235. * @param uniform defines the webGL uniform location where to store the value
  28236. * @param value defines the float number to store
  28237. */
  28238. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28239. /**
  28240. * Set the value of an uniform to a vec2
  28241. * @param uniform defines the webGL uniform location where to store the value
  28242. * @param x defines the 1st component of the value
  28243. * @param y defines the 2nd component of the value
  28244. */
  28245. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28246. /**
  28247. * Set the value of an uniform to a vec3
  28248. * @param uniform defines the webGL uniform location where to store the value
  28249. * @param x defines the 1st component of the value
  28250. * @param y defines the 2nd component of the value
  28251. * @param z defines the 3rd component of the value
  28252. */
  28253. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28254. /**
  28255. * Set the value of an uniform to a boolean
  28256. * @param uniform defines the webGL uniform location where to store the value
  28257. * @param bool defines the boolean to store
  28258. */
  28259. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28260. /**
  28261. * Set the value of an uniform to a vec4
  28262. * @param uniform defines the webGL uniform location where to store the value
  28263. * @param x defines the 1st component of the value
  28264. * @param y defines the 2nd component of the value
  28265. * @param z defines the 3rd component of the value
  28266. * @param w defines the 4th component of the value
  28267. */
  28268. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28269. /**
  28270. * Set the value of an uniform to a Color3
  28271. * @param uniform defines the webGL uniform location where to store the value
  28272. * @param color3 defines the color to store
  28273. */
  28274. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28275. /**
  28276. * Set the value of an uniform to a Color3 and an alpha value
  28277. * @param uniform defines the webGL uniform location where to store the value
  28278. * @param color3 defines the color to store
  28279. * @param alpha defines the alpha component to store
  28280. */
  28281. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28282. /**
  28283. * Sets a Color4 on a uniform variable
  28284. * @param uniform defines the uniform location
  28285. * @param color4 defines the value to be set
  28286. */
  28287. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28288. /**
  28289. * Set various states to the webGL context
  28290. * @param culling defines backface culling state
  28291. * @param zOffset defines the value to apply to zOffset (0 by default)
  28292. * @param force defines if states must be applied even if cache is up to date
  28293. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28294. */
  28295. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28296. /**
  28297. * Set the z offset to apply to current rendering
  28298. * @param value defines the offset to apply
  28299. */
  28300. setZOffset(value: number): void;
  28301. /**
  28302. * Gets the current value of the zOffset
  28303. * @returns the current zOffset state
  28304. */
  28305. getZOffset(): number;
  28306. /**
  28307. * Enable or disable depth buffering
  28308. * @param enable defines the state to set
  28309. */
  28310. setDepthBuffer(enable: boolean): void;
  28311. /**
  28312. * Gets a boolean indicating if depth writing is enabled
  28313. * @returns the current depth writing state
  28314. */
  28315. getDepthWrite(): boolean;
  28316. /**
  28317. * Enable or disable depth writing
  28318. * @param enable defines the state to set
  28319. */
  28320. setDepthWrite(enable: boolean): void;
  28321. /**
  28322. * Enable or disable color writing
  28323. * @param enable defines the state to set
  28324. */
  28325. setColorWrite(enable: boolean): void;
  28326. /**
  28327. * Gets a boolean indicating if color writing is enabled
  28328. * @returns the current color writing state
  28329. */
  28330. getColorWrite(): boolean;
  28331. /**
  28332. * Sets alpha constants used by some alpha blending modes
  28333. * @param r defines the red component
  28334. * @param g defines the green component
  28335. * @param b defines the blue component
  28336. * @param a defines the alpha component
  28337. */
  28338. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28339. /**
  28340. * Sets the current alpha mode
  28341. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28342. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28344. */
  28345. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28346. /**
  28347. * Gets the current alpha mode
  28348. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28349. * @returns the current alpha mode
  28350. */
  28351. getAlphaMode(): number;
  28352. /**
  28353. * Clears the list of texture accessible through engine.
  28354. * This can help preventing texture load conflict due to name collision.
  28355. */
  28356. clearInternalTexturesCache(): void;
  28357. /**
  28358. * Force the entire cache to be cleared
  28359. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28360. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28361. */
  28362. wipeCaches(bruteForce?: boolean): void;
  28363. /**
  28364. * Set the compressed texture format to use, based on the formats you have, and the formats
  28365. * supported by the hardware / browser.
  28366. *
  28367. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28368. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28369. * to API arguments needed to compressed textures. This puts the burden on the container
  28370. * generator to house the arcane code for determining these for current & future formats.
  28371. *
  28372. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28373. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28374. *
  28375. * Note: The result of this call is not taken into account when a texture is base64.
  28376. *
  28377. * @param formatsAvailable defines the list of those format families you have created
  28378. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28379. *
  28380. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28381. * @returns The extension selected.
  28382. */
  28383. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28384. private _getSamplingParameters;
  28385. private _partialLoadImg;
  28386. private _cascadeLoadImgs;
  28387. /** @hidden */
  28388. _createTexture(): WebGLTexture;
  28389. /**
  28390. * Usually called from Texture.ts.
  28391. * Passed information to create a WebGLTexture
  28392. * @param urlArg defines a value which contains one of the following:
  28393. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28394. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28395. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28396. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28397. * @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)
  28398. * @param scene needed for loading to the correct scene
  28399. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28400. * @param onLoad optional callback to be called upon successful completion
  28401. * @param onError optional callback to be called upon failure
  28402. * @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
  28403. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28404. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28405. * @param forcedExtension defines the extension to use to pick the right loader
  28406. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28407. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28408. */
  28409. 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;
  28410. private _rescaleTexture;
  28411. /**
  28412. * Update a raw texture
  28413. * @param texture defines the texture to update
  28414. * @param data defines the data to store in the texture
  28415. * @param format defines the format of the data
  28416. * @param invertY defines if data must be stored with Y axis inverted
  28417. * @param compression defines the compression used (null by default)
  28418. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28419. */
  28420. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28421. /**
  28422. * Creates a raw texture
  28423. * @param data defines the data to store in the texture
  28424. * @param width defines the width of the texture
  28425. * @param height defines the height of the texture
  28426. * @param format defines the format of the data
  28427. * @param generateMipMaps defines if the engine should generate the mip levels
  28428. * @param invertY defines if data must be stored with Y axis inverted
  28429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28430. * @param compression defines the compression used (null by default)
  28431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28432. * @returns the raw texture inside an InternalTexture
  28433. */
  28434. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28435. private _unpackFlipYCached;
  28436. /**
  28437. * In case you are sharing the context with other applications, it might
  28438. * be interested to not cache the unpack flip y state to ensure a consistent
  28439. * value would be set.
  28440. */
  28441. enableUnpackFlipYCached: boolean;
  28442. /** @hidden */
  28443. _unpackFlipY(value: boolean): void;
  28444. /** @hidden */
  28445. _getUnpackAlignement(): number;
  28446. /**
  28447. * Creates a dynamic texture
  28448. * @param width defines the width of the texture
  28449. * @param height defines the height of the texture
  28450. * @param generateMipMaps defines if the engine should generate the mip levels
  28451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28452. * @returns the dynamic texture inside an InternalTexture
  28453. */
  28454. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28455. /**
  28456. * Update the sampling mode of a given texture
  28457. * @param samplingMode defines the required sampling mode
  28458. * @param texture defines the texture to update
  28459. */
  28460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28461. /**
  28462. * Update the content of a dynamic texture
  28463. * @param texture defines the texture to update
  28464. * @param canvas defines the canvas containing the source
  28465. * @param invertY defines if data must be stored with Y axis inverted
  28466. * @param premulAlpha defines if alpha is stored as premultiplied
  28467. * @param format defines the format of the data
  28468. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28469. */
  28470. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28471. /**
  28472. * Update a video texture
  28473. * @param texture defines the texture to update
  28474. * @param video defines the video element to use
  28475. * @param invertY defines if data must be stored with Y axis inverted
  28476. */
  28477. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28478. /**
  28479. * Updates a depth texture Comparison Mode and Function.
  28480. * If the comparison Function is equal to 0, the mode will be set to none.
  28481. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28482. * @param texture The texture to set the comparison function for
  28483. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28484. */
  28485. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28486. private _setupDepthStencilTexture;
  28487. /**
  28488. * Creates a depth stencil texture.
  28489. * This is only available in WebGL 2 or with the depth texture extension available.
  28490. * @param size The size of face edge in the texture.
  28491. * @param options The options defining the texture.
  28492. * @returns The texture
  28493. */
  28494. createDepthStencilTexture(size: number | {
  28495. width: number;
  28496. height: number;
  28497. }, options: DepthTextureCreationOptions): InternalTexture;
  28498. /**
  28499. * Creates a depth stencil texture.
  28500. * This is only available in WebGL 2 or with the depth texture extension available.
  28501. * @param size The size of face edge in the texture.
  28502. * @param options The options defining the texture.
  28503. * @returns The texture
  28504. */
  28505. private _createDepthStencilTexture;
  28506. /**
  28507. * Creates a depth stencil cube texture.
  28508. * This is only available in WebGL 2.
  28509. * @param size The size of face edge in the cube texture.
  28510. * @param options The options defining the cube texture.
  28511. * @returns The cube texture
  28512. */
  28513. private _createDepthStencilCubeTexture;
  28514. /**
  28515. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28516. * @param renderTarget The render target to set the frame buffer for
  28517. */
  28518. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28519. /**
  28520. * Creates a new render target texture
  28521. * @param size defines the size of the texture
  28522. * @param options defines the options used to create the texture
  28523. * @returns a new render target texture stored in an InternalTexture
  28524. */
  28525. createRenderTargetTexture(size: number | {
  28526. width: number;
  28527. height: number;
  28528. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28529. /**
  28530. * Create a multi render target texture
  28531. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28532. * @param size defines the size of the texture
  28533. * @param options defines the creation options
  28534. * @returns the cube texture as an InternalTexture
  28535. */
  28536. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28537. private _setupFramebufferDepthAttachments;
  28538. /**
  28539. * Updates the sample count of a render target texture
  28540. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28541. * @param texture defines the texture to update
  28542. * @param samples defines the sample count to set
  28543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28544. */
  28545. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28546. /**
  28547. * Update the sample count for a given multiple render target texture
  28548. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28549. * @param textures defines the textures to update
  28550. * @param samples defines the sample count to set
  28551. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28552. */
  28553. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28554. /** @hidden */
  28555. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28556. /** @hidden */
  28557. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28558. /** @hidden */
  28559. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28560. /** @hidden */
  28561. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28562. /**
  28563. * Creates a new render target cube texture
  28564. * @param size defines the size of the texture
  28565. * @param options defines the options used to create the texture
  28566. * @returns a new render target cube texture stored in an InternalTexture
  28567. */
  28568. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28569. /**
  28570. * Creates a cube texture
  28571. * @param rootUrl defines the url where the files to load is located
  28572. * @param scene defines the current scene
  28573. * @param files defines the list of files to load (1 per face)
  28574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28575. * @param onLoad defines an optional callback raised when the texture is loaded
  28576. * @param onError defines an optional callback raised if there is an issue to load the texture
  28577. * @param format defines the format of the data
  28578. * @param forcedExtension defines the extension to use to pick the right loader
  28579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28582. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28584. * @returns the cube texture as an InternalTexture
  28585. */
  28586. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28587. /**
  28588. * @hidden
  28589. */
  28590. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28591. /**
  28592. * Update a raw cube texture
  28593. * @param texture defines the texture to udpdate
  28594. * @param data defines the data to store
  28595. * @param format defines the data format
  28596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28597. * @param invertY defines if data must be stored with Y axis inverted
  28598. * @param compression defines the compression used (null by default)
  28599. * @param level defines which level of the texture to update
  28600. */
  28601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28602. /**
  28603. * Creates a new raw cube texture
  28604. * @param data defines the array of data to use to create each face
  28605. * @param size defines the size of the textures
  28606. * @param format defines the format of the data
  28607. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28608. * @param generateMipMaps defines if the engine should generate the mip levels
  28609. * @param invertY defines if data must be stored with Y axis inverted
  28610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28611. * @param compression defines the compression used (null by default)
  28612. * @returns the cube texture as an InternalTexture
  28613. */
  28614. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28615. /**
  28616. * Creates a new raw cube texture from a specified url
  28617. * @param url defines the url where the data is located
  28618. * @param scene defines the current scene
  28619. * @param size defines the size of the textures
  28620. * @param format defines the format of the data
  28621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28622. * @param noMipmap defines if the engine should avoid generating the mip levels
  28623. * @param callback defines a callback used to extract texture data from loaded data
  28624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28625. * @param onLoad defines a callback called when texture is loaded
  28626. * @param onError defines a callback called if there is an error
  28627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28628. * @param invertY defines if data must be stored with Y axis inverted
  28629. * @returns the cube texture as an InternalTexture
  28630. */
  28631. 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;
  28632. /**
  28633. * Update a raw 3D texture
  28634. * @param texture defines the texture to update
  28635. * @param data defines the data to store
  28636. * @param format defines the data format
  28637. * @param invertY defines if data must be stored with Y axis inverted
  28638. * @param compression defines the used compression (can be null)
  28639. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28640. */
  28641. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28642. /**
  28643. * Creates a new raw 3D texture
  28644. * @param data defines the data used to create the texture
  28645. * @param width defines the width of the texture
  28646. * @param height defines the height of the texture
  28647. * @param depth defines the depth of the texture
  28648. * @param format defines the format of the texture
  28649. * @param generateMipMaps defines if the engine must generate mip levels
  28650. * @param invertY defines if data must be stored with Y axis inverted
  28651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28652. * @param compression defines the compressed used (can be null)
  28653. * @param textureType defines the compressed used (can be null)
  28654. * @returns a new raw 3D texture (stored in an InternalTexture)
  28655. */
  28656. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28657. private _prepareWebGLTextureContinuation;
  28658. private _prepareWebGLTexture;
  28659. private _convertRGBtoRGBATextureData;
  28660. /** @hidden */
  28661. _releaseFramebufferObjects(texture: InternalTexture): void;
  28662. /** @hidden */
  28663. _releaseTexture(texture: InternalTexture): void;
  28664. private setProgram;
  28665. private _boundUniforms;
  28666. /**
  28667. * Binds an effect to the webGL context
  28668. * @param effect defines the effect to bind
  28669. */
  28670. bindSamplers(effect: Effect): void;
  28671. private _activateCurrentTexture;
  28672. /** @hidden */
  28673. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28674. /** @hidden */
  28675. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28676. /**
  28677. * Sets a texture to the webGL context from a postprocess
  28678. * @param channel defines the channel to use
  28679. * @param postProcess defines the source postprocess
  28680. */
  28681. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28682. /**
  28683. * Binds the output of the passed in post process to the texture channel specified
  28684. * @param channel The channel the texture should be bound to
  28685. * @param postProcess The post process which's output should be bound
  28686. */
  28687. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28688. /**
  28689. * Unbind all textures from the webGL context
  28690. */
  28691. unbindAllTextures(): void;
  28692. /**
  28693. * Sets a texture to the according uniform.
  28694. * @param channel The texture channel
  28695. * @param uniform The uniform to set
  28696. * @param texture The texture to apply
  28697. */
  28698. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28699. /**
  28700. * Sets a depth stencil texture from a render target to the according uniform.
  28701. * @param channel The texture channel
  28702. * @param uniform The uniform to set
  28703. * @param texture The render target texture containing the depth stencil texture to apply
  28704. */
  28705. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28706. private _bindSamplerUniformToChannel;
  28707. private _getTextureWrapMode;
  28708. private _setTexture;
  28709. /**
  28710. * Sets an array of texture to the webGL context
  28711. * @param channel defines the channel where the texture array must be set
  28712. * @param uniform defines the associated uniform location
  28713. * @param textures defines the array of textures to bind
  28714. */
  28715. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28716. /** @hidden */
  28717. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28718. private _setTextureParameterFloat;
  28719. private _setTextureParameterInteger;
  28720. /**
  28721. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28722. * @param x defines the x coordinate of the rectangle where pixels must be read
  28723. * @param y defines the y coordinate of the rectangle where pixels must be read
  28724. * @param width defines the width of the rectangle where pixels must be read
  28725. * @param height defines the height of the rectangle where pixels must be read
  28726. * @returns a Uint8Array containing RGBA colors
  28727. */
  28728. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28729. /**
  28730. * Add an externaly attached data from its key.
  28731. * This method call will fail and return false, if such key already exists.
  28732. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28733. * @param key the unique key that identifies the data
  28734. * @param data the data object to associate to the key for this Engine instance
  28735. * @return true if no such key were already present and the data was added successfully, false otherwise
  28736. */
  28737. addExternalData<T>(key: string, data: T): boolean;
  28738. /**
  28739. * Get an externaly attached data from its key
  28740. * @param key the unique key that identifies the data
  28741. * @return the associated data, if present (can be null), or undefined if not present
  28742. */
  28743. getExternalData<T>(key: string): T;
  28744. /**
  28745. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28746. * @param key the unique key that identifies the data
  28747. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28748. * @return the associated data, can be null if the factory returned null.
  28749. */
  28750. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28751. /**
  28752. * Remove an externaly attached data from the Engine instance
  28753. * @param key the unique key that identifies the data
  28754. * @return true if the data was successfully removed, false if it doesn't exist
  28755. */
  28756. removeExternalData(key: string): boolean;
  28757. /**
  28758. * Unbind all vertex attributes from the webGL context
  28759. */
  28760. unbindAllAttributes(): void;
  28761. /**
  28762. * 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
  28763. */
  28764. releaseEffects(): void;
  28765. /**
  28766. * Dispose and release all associated resources
  28767. */
  28768. dispose(): void;
  28769. /**
  28770. * Display the loading screen
  28771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28772. */
  28773. displayLoadingUI(): void;
  28774. /**
  28775. * Hide the loading screen
  28776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28777. */
  28778. hideLoadingUI(): void;
  28779. /**
  28780. * Gets the current loading screen object
  28781. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28782. */
  28783. /**
  28784. * Sets the current loading screen object
  28785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28786. */
  28787. loadingScreen: ILoadingScreen;
  28788. /**
  28789. * Sets the current loading screen text
  28790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28791. */
  28792. loadingUIText: string;
  28793. /**
  28794. * Sets the current loading screen background color
  28795. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28796. */
  28797. loadingUIBackgroundColor: string;
  28798. /**
  28799. * Attach a new callback raised when context lost event is fired
  28800. * @param callback defines the callback to call
  28801. */
  28802. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28803. /**
  28804. * Attach a new callback raised when context restored event is fired
  28805. * @param callback defines the callback to call
  28806. */
  28807. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28808. /**
  28809. * Gets the source code of the vertex shader associated with a specific webGL program
  28810. * @param program defines the program to use
  28811. * @returns a string containing the source code of the vertex shader associated with the program
  28812. */
  28813. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28814. /**
  28815. * Gets the source code of the fragment shader associated with a specific webGL program
  28816. * @param program defines the program to use
  28817. * @returns a string containing the source code of the fragment shader associated with the program
  28818. */
  28819. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28820. /**
  28821. * Get the current error code of the webGL context
  28822. * @returns the error code
  28823. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28824. */
  28825. getError(): number;
  28826. /**
  28827. * Gets the current framerate
  28828. * @returns a number representing the framerate
  28829. */
  28830. getFps(): number;
  28831. /**
  28832. * Gets the time spent between current and previous frame
  28833. * @returns a number representing the delta time in ms
  28834. */
  28835. getDeltaTime(): number;
  28836. private _measureFps;
  28837. /** @hidden */
  28838. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28839. private _canRenderToFloatFramebuffer;
  28840. private _canRenderToHalfFloatFramebuffer;
  28841. private _canRenderToFramebuffer;
  28842. /** @hidden */
  28843. _getWebGLTextureType(type: number): number;
  28844. private _getInternalFormat;
  28845. /** @hidden */
  28846. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28847. /** @hidden */
  28848. _getRGBAMultiSampleBufferFormat(type: number): number;
  28849. /** @hidden */
  28850. _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;
  28851. /** @hidden */
  28852. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28853. private _partialLoadFile;
  28854. private _cascadeLoadFiles;
  28855. /**
  28856. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28857. * @returns true if the engine can be created
  28858. * @ignorenaming
  28859. */
  28860. static isSupported(): boolean;
  28861. }
  28862. }
  28863. declare module BABYLON {
  28864. /**
  28865. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28866. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28867. */
  28868. export class EffectFallbacks {
  28869. private _defines;
  28870. private _currentRank;
  28871. private _maxRank;
  28872. private _mesh;
  28873. /**
  28874. * Removes the fallback from the bound mesh.
  28875. */
  28876. unBindMesh(): void;
  28877. /**
  28878. * Adds a fallback on the specified property.
  28879. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28880. * @param define The name of the define in the shader
  28881. */
  28882. addFallback(rank: number, define: string): void;
  28883. /**
  28884. * Sets the mesh to use CPU skinning when needing to fallback.
  28885. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28886. * @param mesh The mesh to use the fallbacks.
  28887. */
  28888. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28889. /**
  28890. * Checks to see if more fallbacks are still availible.
  28891. */
  28892. readonly isMoreFallbacks: boolean;
  28893. /**
  28894. * Removes the defines that shoould be removed when falling back.
  28895. * @param currentDefines defines the current define statements for the shader.
  28896. * @param effect defines the current effect we try to compile
  28897. * @returns The resulting defines with defines of the current rank removed.
  28898. */
  28899. reduce(currentDefines: string, effect: Effect): string;
  28900. }
  28901. /**
  28902. * Options to be used when creating an effect.
  28903. */
  28904. export class EffectCreationOptions {
  28905. /**
  28906. * Atrributes that will be used in the shader.
  28907. */
  28908. attributes: string[];
  28909. /**
  28910. * Uniform varible names that will be set in the shader.
  28911. */
  28912. uniformsNames: string[];
  28913. /**
  28914. * Uniform buffer varible names that will be set in the shader.
  28915. */
  28916. uniformBuffersNames: string[];
  28917. /**
  28918. * Sampler texture variable names that will be set in the shader.
  28919. */
  28920. samplers: string[];
  28921. /**
  28922. * Define statements that will be set in the shader.
  28923. */
  28924. defines: any;
  28925. /**
  28926. * Possible fallbacks for this effect to improve performance when needed.
  28927. */
  28928. fallbacks: Nullable<EffectFallbacks>;
  28929. /**
  28930. * Callback that will be called when the shader is compiled.
  28931. */
  28932. onCompiled: Nullable<(effect: Effect) => void>;
  28933. /**
  28934. * Callback that will be called if an error occurs during shader compilation.
  28935. */
  28936. onError: Nullable<(effect: Effect, errors: string) => void>;
  28937. /**
  28938. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28939. */
  28940. indexParameters: any;
  28941. /**
  28942. * Max number of lights that can be used in the shader.
  28943. */
  28944. maxSimultaneousLights: number;
  28945. /**
  28946. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28947. */
  28948. transformFeedbackVaryings: Nullable<string[]>;
  28949. }
  28950. /**
  28951. * Effect containing vertex and fragment shader that can be executed on an object.
  28952. */
  28953. export class Effect implements IDisposable {
  28954. /**
  28955. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28956. */
  28957. static ShadersRepository: string;
  28958. /**
  28959. * Name of the effect.
  28960. */
  28961. name: any;
  28962. /**
  28963. * String container all the define statements that should be set on the shader.
  28964. */
  28965. defines: string;
  28966. /**
  28967. * Callback that will be called when the shader is compiled.
  28968. */
  28969. onCompiled: Nullable<(effect: Effect) => void>;
  28970. /**
  28971. * Callback that will be called if an error occurs during shader compilation.
  28972. */
  28973. onError: Nullable<(effect: Effect, errors: string) => void>;
  28974. /**
  28975. * Callback that will be called when effect is bound.
  28976. */
  28977. onBind: Nullable<(effect: Effect) => void>;
  28978. /**
  28979. * Unique ID of the effect.
  28980. */
  28981. uniqueId: number;
  28982. /**
  28983. * Observable that will be called when the shader is compiled.
  28984. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28985. */
  28986. onCompileObservable: Observable<Effect>;
  28987. /**
  28988. * Observable that will be called if an error occurs during shader compilation.
  28989. */
  28990. onErrorObservable: Observable<Effect>;
  28991. /** @hidden */
  28992. _onBindObservable: Nullable<Observable<Effect>>;
  28993. /**
  28994. * Observable that will be called when effect is bound.
  28995. */
  28996. readonly onBindObservable: Observable<Effect>;
  28997. /** @hidden */
  28998. _bonesComputationForcedToCPU: boolean;
  28999. private static _uniqueIdSeed;
  29000. private _engine;
  29001. private _uniformBuffersNames;
  29002. private _uniformsNames;
  29003. private _samplerList;
  29004. private _samplers;
  29005. private _isReady;
  29006. private _compilationError;
  29007. private _attributesNames;
  29008. private _attributes;
  29009. private _uniforms;
  29010. /**
  29011. * Key for the effect.
  29012. * @hidden
  29013. */
  29014. _key: string;
  29015. private _indexParameters;
  29016. private _fallbacks;
  29017. private _vertexSourceCode;
  29018. private _fragmentSourceCode;
  29019. private _vertexSourceCodeOverride;
  29020. private _fragmentSourceCodeOverride;
  29021. private _transformFeedbackVaryings;
  29022. /**
  29023. * Compiled shader to webGL program.
  29024. * @hidden
  29025. */
  29026. _program: WebGLProgram;
  29027. private _valueCache;
  29028. private static _baseCache;
  29029. /**
  29030. * Instantiates an effect.
  29031. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29032. * @param baseName Name of the effect.
  29033. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29034. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29035. * @param samplers List of sampler variables that will be passed to the shader.
  29036. * @param engine Engine to be used to render the effect
  29037. * @param defines Define statements to be added to the shader.
  29038. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29039. * @param onCompiled Callback that will be called when the shader is compiled.
  29040. * @param onError Callback that will be called if an error occurs during shader compilation.
  29041. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29042. */
  29043. 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);
  29044. /**
  29045. * Unique key for this effect
  29046. */
  29047. readonly key: string;
  29048. /**
  29049. * If the effect has been compiled and prepared.
  29050. * @returns if the effect is compiled and prepared.
  29051. */
  29052. isReady(): boolean;
  29053. /**
  29054. * The engine the effect was initialized with.
  29055. * @returns the engine.
  29056. */
  29057. getEngine(): Engine;
  29058. /**
  29059. * The compiled webGL program for the effect
  29060. * @returns the webGL program.
  29061. */
  29062. getProgram(): WebGLProgram;
  29063. /**
  29064. * The set of names of attribute variables for the shader.
  29065. * @returns An array of attribute names.
  29066. */
  29067. getAttributesNames(): string[];
  29068. /**
  29069. * Returns the attribute at the given index.
  29070. * @param index The index of the attribute.
  29071. * @returns The location of the attribute.
  29072. */
  29073. getAttributeLocation(index: number): number;
  29074. /**
  29075. * Returns the attribute based on the name of the variable.
  29076. * @param name of the attribute to look up.
  29077. * @returns the attribute location.
  29078. */
  29079. getAttributeLocationByName(name: string): number;
  29080. /**
  29081. * The number of attributes.
  29082. * @returns the numnber of attributes.
  29083. */
  29084. getAttributesCount(): number;
  29085. /**
  29086. * Gets the index of a uniform variable.
  29087. * @param uniformName of the uniform to look up.
  29088. * @returns the index.
  29089. */
  29090. getUniformIndex(uniformName: string): number;
  29091. /**
  29092. * Returns the attribute based on the name of the variable.
  29093. * @param uniformName of the uniform to look up.
  29094. * @returns the location of the uniform.
  29095. */
  29096. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29097. /**
  29098. * Returns an array of sampler variable names
  29099. * @returns The array of sampler variable neames.
  29100. */
  29101. getSamplers(): string[];
  29102. /**
  29103. * The error from the last compilation.
  29104. * @returns the error string.
  29105. */
  29106. getCompilationError(): string;
  29107. /**
  29108. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29109. * @param func The callback to be used.
  29110. */
  29111. executeWhenCompiled(func: (effect: Effect) => void): void;
  29112. private _checkIsReady;
  29113. /** @hidden */
  29114. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29115. /** @hidden */
  29116. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29117. /** @hidden */
  29118. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29119. private _processShaderConversion;
  29120. private _processIncludes;
  29121. private _processPrecision;
  29122. /**
  29123. * Recompiles the webGL program
  29124. * @param vertexSourceCode The source code for the vertex shader.
  29125. * @param fragmentSourceCode The source code for the fragment shader.
  29126. * @param onCompiled Callback called when completed.
  29127. * @param onError Callback called on error.
  29128. * @hidden
  29129. */
  29130. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29131. /**
  29132. * Gets the uniform locations of the the specified variable names
  29133. * @param names THe names of the variables to lookup.
  29134. * @returns Array of locations in the same order as variable names.
  29135. */
  29136. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29137. /**
  29138. * Prepares the effect
  29139. * @hidden
  29140. */
  29141. _prepareEffect(): void;
  29142. /**
  29143. * Checks if the effect is supported. (Must be called after compilation)
  29144. */
  29145. readonly isSupported: boolean;
  29146. /**
  29147. * Binds a texture to the engine to be used as output of the shader.
  29148. * @param channel Name of the output variable.
  29149. * @param texture Texture to bind.
  29150. * @hidden
  29151. */
  29152. _bindTexture(channel: string, texture: InternalTexture): void;
  29153. /**
  29154. * Sets a texture on the engine to be used in the shader.
  29155. * @param channel Name of the sampler variable.
  29156. * @param texture Texture to set.
  29157. */
  29158. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29159. /**
  29160. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29161. * @param channel Name of the sampler variable.
  29162. * @param texture Texture to set.
  29163. */
  29164. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29165. /**
  29166. * Sets an array of textures on the engine to be used in the shader.
  29167. * @param channel Name of the variable.
  29168. * @param textures Textures to set.
  29169. */
  29170. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29171. /**
  29172. * 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)
  29173. * @param channel Name of the sampler variable.
  29174. * @param postProcess Post process to get the input texture from.
  29175. */
  29176. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29177. /**
  29178. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29179. * 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)
  29180. * @param channel Name of the sampler variable.
  29181. * @param postProcess Post process to get the output texture from.
  29182. */
  29183. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29184. /** @hidden */
  29185. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29186. /** @hidden */
  29187. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29188. /** @hidden */
  29189. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29190. /** @hidden */
  29191. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29192. /**
  29193. * Binds a buffer to a uniform.
  29194. * @param buffer Buffer to bind.
  29195. * @param name Name of the uniform variable to bind to.
  29196. */
  29197. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29198. /**
  29199. * Binds block to a uniform.
  29200. * @param blockName Name of the block to bind.
  29201. * @param index Index to bind.
  29202. */
  29203. bindUniformBlock(blockName: string, index: number): void;
  29204. /**
  29205. * Sets an interger value on a uniform variable.
  29206. * @param uniformName Name of the variable.
  29207. * @param value Value to be set.
  29208. * @returns this effect.
  29209. */
  29210. setInt(uniformName: string, value: number): Effect;
  29211. /**
  29212. * Sets an int array on a uniform variable.
  29213. * @param uniformName Name of the variable.
  29214. * @param array array to be set.
  29215. * @returns this effect.
  29216. */
  29217. setIntArray(uniformName: string, array: Int32Array): Effect;
  29218. /**
  29219. * 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)
  29220. * @param uniformName Name of the variable.
  29221. * @param array array to be set.
  29222. * @returns this effect.
  29223. */
  29224. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29225. /**
  29226. * 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)
  29227. * @param uniformName Name of the variable.
  29228. * @param array array to be set.
  29229. * @returns this effect.
  29230. */
  29231. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29232. /**
  29233. * 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)
  29234. * @param uniformName Name of the variable.
  29235. * @param array array to be set.
  29236. * @returns this effect.
  29237. */
  29238. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29239. /**
  29240. * Sets an float array on a uniform variable.
  29241. * @param uniformName Name of the variable.
  29242. * @param array array to be set.
  29243. * @returns this effect.
  29244. */
  29245. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29246. /**
  29247. * 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)
  29248. * @param uniformName Name of the variable.
  29249. * @param array array to be set.
  29250. * @returns this effect.
  29251. */
  29252. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29253. /**
  29254. * 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)
  29255. * @param uniformName Name of the variable.
  29256. * @param array array to be set.
  29257. * @returns this effect.
  29258. */
  29259. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29260. /**
  29261. * 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)
  29262. * @param uniformName Name of the variable.
  29263. * @param array array to be set.
  29264. * @returns this effect.
  29265. */
  29266. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29267. /**
  29268. * Sets an array on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param array array to be set.
  29271. * @returns this effect.
  29272. */
  29273. setArray(uniformName: string, array: number[]): Effect;
  29274. /**
  29275. * 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)
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setArray2(uniformName: string, array: number[]): Effect;
  29281. /**
  29282. * 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)
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setArray3(uniformName: string, array: number[]): Effect;
  29288. /**
  29289. * 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)
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setArray4(uniformName: string, array: number[]): Effect;
  29295. /**
  29296. * Sets matrices on a uniform variable.
  29297. * @param uniformName Name of the variable.
  29298. * @param matrices matrices to be set.
  29299. * @returns this effect.
  29300. */
  29301. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29302. /**
  29303. * Sets matrix on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param matrix matrix to be set.
  29306. * @returns this effect.
  29307. */
  29308. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29309. /**
  29310. * 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)
  29311. * @param uniformName Name of the variable.
  29312. * @param matrix matrix to be set.
  29313. * @returns this effect.
  29314. */
  29315. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29316. /**
  29317. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29318. * @param uniformName Name of the variable.
  29319. * @param matrix matrix to be set.
  29320. * @returns this effect.
  29321. */
  29322. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29323. /**
  29324. * Sets a float on a uniform variable.
  29325. * @param uniformName Name of the variable.
  29326. * @param value value to be set.
  29327. * @returns this effect.
  29328. */
  29329. setFloat(uniformName: string, value: number): Effect;
  29330. /**
  29331. * Sets a boolean on a uniform variable.
  29332. * @param uniformName Name of the variable.
  29333. * @param bool value to be set.
  29334. * @returns this effect.
  29335. */
  29336. setBool(uniformName: string, bool: boolean): Effect;
  29337. /**
  29338. * Sets a Vector2 on a uniform variable.
  29339. * @param uniformName Name of the variable.
  29340. * @param vector2 vector2 to be set.
  29341. * @returns this effect.
  29342. */
  29343. setVector2(uniformName: string, vector2: Vector2): Effect;
  29344. /**
  29345. * Sets a float2 on a uniform variable.
  29346. * @param uniformName Name of the variable.
  29347. * @param x First float in float2.
  29348. * @param y Second float in float2.
  29349. * @returns this effect.
  29350. */
  29351. setFloat2(uniformName: string, x: number, y: number): Effect;
  29352. /**
  29353. * Sets a Vector3 on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param vector3 Value to be set.
  29356. * @returns this effect.
  29357. */
  29358. setVector3(uniformName: string, vector3: Vector3): Effect;
  29359. /**
  29360. * Sets a float3 on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param x First float in float3.
  29363. * @param y Second float in float3.
  29364. * @param z Third float in float3.
  29365. * @returns this effect.
  29366. */
  29367. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29368. /**
  29369. * Sets a Vector4 on a uniform variable.
  29370. * @param uniformName Name of the variable.
  29371. * @param vector4 Value to be set.
  29372. * @returns this effect.
  29373. */
  29374. setVector4(uniformName: string, vector4: Vector4): Effect;
  29375. /**
  29376. * Sets a float4 on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param x First float in float4.
  29379. * @param y Second float in float4.
  29380. * @param z Third float in float4.
  29381. * @param w Fourth float in float4.
  29382. * @returns this effect.
  29383. */
  29384. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29385. /**
  29386. * Sets a Color3 on a uniform variable.
  29387. * @param uniformName Name of the variable.
  29388. * @param color3 Value to be set.
  29389. * @returns this effect.
  29390. */
  29391. setColor3(uniformName: string, color3: Color3): Effect;
  29392. /**
  29393. * Sets a Color4 on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param color3 Value to be set.
  29396. * @param alpha Alpha value to be set.
  29397. * @returns this effect.
  29398. */
  29399. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29400. /**
  29401. * Sets a Color4 on a uniform variable
  29402. * @param uniformName defines the name of the variable
  29403. * @param color4 defines the value to be set
  29404. * @returns this effect.
  29405. */
  29406. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29407. /** Release all associated resources */
  29408. dispose(): void;
  29409. /**
  29410. * This function will add a new shader to the shader store
  29411. * @param name the name of the shader
  29412. * @param pixelShader optional pixel shader content
  29413. * @param vertexShader optional vertex shader content
  29414. */
  29415. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29416. /**
  29417. * Store of each shader (The can be looked up using effect.key)
  29418. */
  29419. static ShadersStore: {
  29420. [key: string]: string;
  29421. };
  29422. /**
  29423. * Store of each included file for a shader (The can be looked up using effect.key)
  29424. */
  29425. static IncludesShadersStore: {
  29426. [key: string]: string;
  29427. };
  29428. /**
  29429. * Resets the cache of effects.
  29430. */
  29431. static ResetCache(): void;
  29432. }
  29433. }
  29434. declare module BABYLON {
  29435. /**
  29436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29438. * 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;
  29439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29440. */
  29441. export class ColorCurves {
  29442. private _dirty;
  29443. private _tempColor;
  29444. private _globalCurve;
  29445. private _highlightsCurve;
  29446. private _midtonesCurve;
  29447. private _shadowsCurve;
  29448. private _positiveCurve;
  29449. private _negativeCurve;
  29450. private _globalHue;
  29451. private _globalDensity;
  29452. private _globalSaturation;
  29453. private _globalExposure;
  29454. /**
  29455. * Gets the global Hue value.
  29456. * 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).
  29457. */
  29458. /**
  29459. * Sets the global Hue value.
  29460. * 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).
  29461. */
  29462. globalHue: number;
  29463. /**
  29464. * Gets the global Density value.
  29465. * 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.
  29466. * Values less than zero provide a filter of opposite hue.
  29467. */
  29468. /**
  29469. * Sets the global Density value.
  29470. * 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.
  29471. * Values less than zero provide a filter of opposite hue.
  29472. */
  29473. globalDensity: number;
  29474. /**
  29475. * Gets the global Saturation value.
  29476. * 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.
  29477. */
  29478. /**
  29479. * Sets the global Saturation value.
  29480. * 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.
  29481. */
  29482. globalSaturation: number;
  29483. /**
  29484. * Gets the global Exposure value.
  29485. * 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.
  29486. */
  29487. /**
  29488. * Sets the global Exposure value.
  29489. * 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.
  29490. */
  29491. globalExposure: number;
  29492. private _highlightsHue;
  29493. private _highlightsDensity;
  29494. private _highlightsSaturation;
  29495. private _highlightsExposure;
  29496. /**
  29497. * Gets the highlights Hue value.
  29498. * 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).
  29499. */
  29500. /**
  29501. * Sets the highlights Hue value.
  29502. * 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).
  29503. */
  29504. highlightsHue: number;
  29505. /**
  29506. * Gets the highlights Density value.
  29507. * 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.
  29508. * Values less than zero provide a filter of opposite hue.
  29509. */
  29510. /**
  29511. * Sets the highlights Density value.
  29512. * 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.
  29513. * Values less than zero provide a filter of opposite hue.
  29514. */
  29515. highlightsDensity: number;
  29516. /**
  29517. * Gets the highlights Saturation value.
  29518. * 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.
  29519. */
  29520. /**
  29521. * Sets the highlights Saturation value.
  29522. * 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.
  29523. */
  29524. highlightsSaturation: number;
  29525. /**
  29526. * Gets the highlights Exposure value.
  29527. * 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.
  29528. */
  29529. /**
  29530. * Sets the highlights Exposure value.
  29531. * 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.
  29532. */
  29533. highlightsExposure: number;
  29534. private _midtonesHue;
  29535. private _midtonesDensity;
  29536. private _midtonesSaturation;
  29537. private _midtonesExposure;
  29538. /**
  29539. * Gets the midtones Hue value.
  29540. * 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).
  29541. */
  29542. /**
  29543. * Sets the midtones Hue value.
  29544. * 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).
  29545. */
  29546. midtonesHue: number;
  29547. /**
  29548. * Gets the midtones Density value.
  29549. * 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.
  29550. * Values less than zero provide a filter of opposite hue.
  29551. */
  29552. /**
  29553. * Sets the midtones Density value.
  29554. * 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.
  29555. * Values less than zero provide a filter of opposite hue.
  29556. */
  29557. midtonesDensity: number;
  29558. /**
  29559. * Gets the midtones Saturation value.
  29560. * 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.
  29561. */
  29562. /**
  29563. * Sets the midtones Saturation value.
  29564. * 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.
  29565. */
  29566. midtonesSaturation: number;
  29567. /**
  29568. * Gets the midtones Exposure value.
  29569. * 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.
  29570. */
  29571. /**
  29572. * Sets the midtones Exposure value.
  29573. * 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.
  29574. */
  29575. midtonesExposure: number;
  29576. private _shadowsHue;
  29577. private _shadowsDensity;
  29578. private _shadowsSaturation;
  29579. private _shadowsExposure;
  29580. /**
  29581. * Gets the shadows Hue value.
  29582. * 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).
  29583. */
  29584. /**
  29585. * Sets the shadows Hue value.
  29586. * 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).
  29587. */
  29588. shadowsHue: number;
  29589. /**
  29590. * Gets the shadows Density value.
  29591. * 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.
  29592. * Values less than zero provide a filter of opposite hue.
  29593. */
  29594. /**
  29595. * Sets the shadows Density value.
  29596. * 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.
  29597. * Values less than zero provide a filter of opposite hue.
  29598. */
  29599. shadowsDensity: number;
  29600. /**
  29601. * Gets the shadows Saturation value.
  29602. * 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.
  29603. */
  29604. /**
  29605. * Sets the shadows Saturation value.
  29606. * 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.
  29607. */
  29608. shadowsSaturation: number;
  29609. /**
  29610. * Gets the shadows Exposure value.
  29611. * 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.
  29612. */
  29613. /**
  29614. * Sets the shadows Exposure value.
  29615. * 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.
  29616. */
  29617. shadowsExposure: number;
  29618. /**
  29619. * Returns the class name
  29620. * @returns The class name
  29621. */
  29622. getClassName(): string;
  29623. /**
  29624. * Binds the color curves to the shader.
  29625. * @param colorCurves The color curve to bind
  29626. * @param effect The effect to bind to
  29627. * @param positiveUniform The positive uniform shader parameter
  29628. * @param neutralUniform The neutral uniform shader parameter
  29629. * @param negativeUniform The negative uniform shader parameter
  29630. */
  29631. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29632. /**
  29633. * Prepare the list of uniforms associated with the ColorCurves effects.
  29634. * @param uniformsList The list of uniforms used in the effect
  29635. */
  29636. static PrepareUniforms(uniformsList: string[]): void;
  29637. /**
  29638. * Returns color grading data based on a hue, density, saturation and exposure value.
  29639. * @param filterHue The hue of the color filter.
  29640. * @param filterDensity The density of the color filter.
  29641. * @param saturation The saturation.
  29642. * @param exposure The exposure.
  29643. * @param result The result data container.
  29644. */
  29645. private getColorGradingDataToRef;
  29646. /**
  29647. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29648. * @param value The input slider value in range [-100,100].
  29649. * @returns Adjusted value.
  29650. */
  29651. private static applyColorGradingSliderNonlinear;
  29652. /**
  29653. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29654. * @param hue The hue (H) input.
  29655. * @param saturation The saturation (S) input.
  29656. * @param brightness The brightness (B) input.
  29657. * @result An RGBA color represented as Vector4.
  29658. */
  29659. private static fromHSBToRef;
  29660. /**
  29661. * Returns a value clamped between min and max
  29662. * @param value The value to clamp
  29663. * @param min The minimum of value
  29664. * @param max The maximum of value
  29665. * @returns The clamped value.
  29666. */
  29667. private static clamp;
  29668. /**
  29669. * Clones the current color curve instance.
  29670. * @return The cloned curves
  29671. */
  29672. clone(): ColorCurves;
  29673. /**
  29674. * Serializes the current color curve instance to a json representation.
  29675. * @return a JSON representation
  29676. */
  29677. serialize(): any;
  29678. /**
  29679. * Parses the color curve from a json representation.
  29680. * @param source the JSON source to parse
  29681. * @return The parsed curves
  29682. */
  29683. static Parse(source: any): ColorCurves;
  29684. }
  29685. }
  29686. declare module BABYLON {
  29687. /**
  29688. * Interface to follow in your material defines to integrate easily the
  29689. * Image proccessing functions.
  29690. * @hidden
  29691. */
  29692. export interface IImageProcessingConfigurationDefines {
  29693. IMAGEPROCESSING: boolean;
  29694. VIGNETTE: boolean;
  29695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29696. VIGNETTEBLENDMODEOPAQUE: boolean;
  29697. TONEMAPPING: boolean;
  29698. TONEMAPPING_ACES: boolean;
  29699. CONTRAST: boolean;
  29700. EXPOSURE: boolean;
  29701. COLORCURVES: boolean;
  29702. COLORGRADING: boolean;
  29703. COLORGRADING3D: boolean;
  29704. SAMPLER3DGREENDEPTH: boolean;
  29705. SAMPLER3DBGRMAP: boolean;
  29706. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29707. }
  29708. /**
  29709. * @hidden
  29710. */
  29711. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29712. IMAGEPROCESSING: boolean;
  29713. VIGNETTE: boolean;
  29714. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29715. VIGNETTEBLENDMODEOPAQUE: boolean;
  29716. TONEMAPPING: boolean;
  29717. TONEMAPPING_ACES: boolean;
  29718. CONTRAST: boolean;
  29719. COLORCURVES: boolean;
  29720. COLORGRADING: boolean;
  29721. COLORGRADING3D: boolean;
  29722. SAMPLER3DGREENDEPTH: boolean;
  29723. SAMPLER3DBGRMAP: boolean;
  29724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29725. EXPOSURE: boolean;
  29726. constructor();
  29727. }
  29728. /**
  29729. * This groups together the common properties used for image processing either in direct forward pass
  29730. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29731. * or not.
  29732. */
  29733. export class ImageProcessingConfiguration {
  29734. /**
  29735. * Default tone mapping applied in BabylonJS.
  29736. */
  29737. static readonly TONEMAPPING_STANDARD: number;
  29738. /**
  29739. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29740. * to other engines rendering to increase portability.
  29741. */
  29742. static readonly TONEMAPPING_ACES: number;
  29743. /**
  29744. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29745. */
  29746. colorCurves: Nullable<ColorCurves>;
  29747. private _colorCurvesEnabled;
  29748. /**
  29749. * Gets wether the color curves effect is enabled.
  29750. */
  29751. /**
  29752. * Sets wether the color curves effect is enabled.
  29753. */
  29754. colorCurvesEnabled: boolean;
  29755. private _colorGradingTexture;
  29756. /**
  29757. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29758. */
  29759. /**
  29760. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29761. */
  29762. colorGradingTexture: Nullable<BaseTexture>;
  29763. private _colorGradingEnabled;
  29764. /**
  29765. * Gets wether the color grading effect is enabled.
  29766. */
  29767. /**
  29768. * Sets wether the color grading effect is enabled.
  29769. */
  29770. colorGradingEnabled: boolean;
  29771. private _colorGradingWithGreenDepth;
  29772. /**
  29773. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29774. */
  29775. /**
  29776. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29777. */
  29778. colorGradingWithGreenDepth: boolean;
  29779. private _colorGradingBGR;
  29780. /**
  29781. * Gets wether the color grading texture contains BGR values.
  29782. */
  29783. /**
  29784. * Sets wether the color grading texture contains BGR values.
  29785. */
  29786. colorGradingBGR: boolean;
  29787. /** @hidden */
  29788. _exposure: number;
  29789. /**
  29790. * Gets the Exposure used in the effect.
  29791. */
  29792. /**
  29793. * Sets the Exposure used in the effect.
  29794. */
  29795. exposure: number;
  29796. private _toneMappingEnabled;
  29797. /**
  29798. * Gets wether the tone mapping effect is enabled.
  29799. */
  29800. /**
  29801. * Sets wether the tone mapping effect is enabled.
  29802. */
  29803. toneMappingEnabled: boolean;
  29804. private _toneMappingType;
  29805. /**
  29806. * Gets the type of tone mapping effect.
  29807. */
  29808. /**
  29809. * Sets the type of tone mapping effect used in BabylonJS.
  29810. */
  29811. toneMappingType: number;
  29812. protected _contrast: number;
  29813. /**
  29814. * Gets the contrast used in the effect.
  29815. */
  29816. /**
  29817. * Sets the contrast used in the effect.
  29818. */
  29819. contrast: number;
  29820. /**
  29821. * Vignette stretch size.
  29822. */
  29823. vignetteStretch: number;
  29824. /**
  29825. * Vignette centre X Offset.
  29826. */
  29827. vignetteCentreX: number;
  29828. /**
  29829. * Vignette centre Y Offset.
  29830. */
  29831. vignetteCentreY: number;
  29832. /**
  29833. * Vignette weight or intensity of the vignette effect.
  29834. */
  29835. vignetteWeight: number;
  29836. /**
  29837. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29838. * if vignetteEnabled is set to true.
  29839. */
  29840. vignetteColor: Color4;
  29841. /**
  29842. * Camera field of view used by the Vignette effect.
  29843. */
  29844. vignetteCameraFov: number;
  29845. private _vignetteBlendMode;
  29846. /**
  29847. * Gets the vignette blend mode allowing different kind of effect.
  29848. */
  29849. /**
  29850. * Sets the vignette blend mode allowing different kind of effect.
  29851. */
  29852. vignetteBlendMode: number;
  29853. private _vignetteEnabled;
  29854. /**
  29855. * Gets wether the vignette effect is enabled.
  29856. */
  29857. /**
  29858. * Sets wether the vignette effect is enabled.
  29859. */
  29860. vignetteEnabled: boolean;
  29861. private _applyByPostProcess;
  29862. /**
  29863. * Gets wether the image processing is applied through a post process or not.
  29864. */
  29865. /**
  29866. * Sets wether the image processing is applied through a post process or not.
  29867. */
  29868. applyByPostProcess: boolean;
  29869. private _isEnabled;
  29870. /**
  29871. * Gets wether the image processing is enabled or not.
  29872. */
  29873. /**
  29874. * Sets wether the image processing is enabled or not.
  29875. */
  29876. isEnabled: boolean;
  29877. /**
  29878. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29879. */
  29880. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29881. /**
  29882. * Method called each time the image processing information changes requires to recompile the effect.
  29883. */
  29884. protected _updateParameters(): void;
  29885. /**
  29886. * Gets the current class name.
  29887. * @return "ImageProcessingConfiguration"
  29888. */
  29889. getClassName(): string;
  29890. /**
  29891. * Prepare the list of uniforms associated with the Image Processing effects.
  29892. * @param uniforms The list of uniforms used in the effect
  29893. * @param defines the list of defines currently in use
  29894. */
  29895. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29896. /**
  29897. * Prepare the list of samplers associated with the Image Processing effects.
  29898. * @param samplersList The list of uniforms used in the effect
  29899. * @param defines the list of defines currently in use
  29900. */
  29901. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29902. /**
  29903. * Prepare the list of defines associated to the shader.
  29904. * @param defines the list of defines to complete
  29905. * @param forPostProcess Define if we are currently in post process mode or not
  29906. */
  29907. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29908. /**
  29909. * Returns true if all the image processing information are ready.
  29910. * @returns True if ready, otherwise, false
  29911. */
  29912. isReady(): boolean;
  29913. /**
  29914. * Binds the image processing to the shader.
  29915. * @param effect The effect to bind to
  29916. * @param aspectRatio Define the current aspect ratio of the effect
  29917. */
  29918. bind(effect: Effect, aspectRatio?: number): void;
  29919. /**
  29920. * Clones the current image processing instance.
  29921. * @return The cloned image processing
  29922. */
  29923. clone(): ImageProcessingConfiguration;
  29924. /**
  29925. * Serializes the current image processing instance to a json representation.
  29926. * @return a JSON representation
  29927. */
  29928. serialize(): any;
  29929. /**
  29930. * Parses the image processing from a json representation.
  29931. * @param source the JSON source to parse
  29932. * @return The parsed image processing
  29933. */
  29934. static Parse(source: any): ImageProcessingConfiguration;
  29935. private static _VIGNETTEMODE_MULTIPLY;
  29936. private static _VIGNETTEMODE_OPAQUE;
  29937. /**
  29938. * Used to apply the vignette as a mix with the pixel color.
  29939. */
  29940. static readonly VIGNETTEMODE_MULTIPLY: number;
  29941. /**
  29942. * Used to apply the vignette as a replacement of the pixel color.
  29943. */
  29944. static readonly VIGNETTEMODE_OPAQUE: number;
  29945. }
  29946. }
  29947. declare module BABYLON {
  29948. /**
  29949. * This represents all the required information to add a fresnel effect on a material:
  29950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29951. */
  29952. export class FresnelParameters {
  29953. private _isEnabled;
  29954. /**
  29955. * Define if the fresnel effect is enable or not.
  29956. */
  29957. isEnabled: boolean;
  29958. /**
  29959. * Define the color used on edges (grazing angle)
  29960. */
  29961. leftColor: Color3;
  29962. /**
  29963. * Define the color used on center
  29964. */
  29965. rightColor: Color3;
  29966. /**
  29967. * Define bias applied to computed fresnel term
  29968. */
  29969. bias: number;
  29970. /**
  29971. * Defined the power exponent applied to fresnel term
  29972. */
  29973. power: number;
  29974. /**
  29975. * Clones the current fresnel and its valuues
  29976. * @returns a clone fresnel configuration
  29977. */
  29978. clone(): FresnelParameters;
  29979. /**
  29980. * Serializes the current fresnel parameters to a JSON representation.
  29981. * @return the JSON serialization
  29982. */
  29983. serialize(): any;
  29984. /**
  29985. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29986. * @param parsedFresnelParameters Define the JSON representation
  29987. * @returns the parsed parameters
  29988. */
  29989. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29990. }
  29991. }
  29992. declare module BABYLON {
  29993. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29994. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29995. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29996. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29997. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29998. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29999. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30000. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30001. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30002. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30003. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30004. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30005. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30006. /**
  30007. * Decorator used to define property that can be serialized as reference to a camera
  30008. * @param sourceName defines the name of the property to decorate
  30009. */
  30010. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30011. /**
  30012. * Class used to help serialization objects
  30013. */
  30014. export class SerializationHelper {
  30015. /** hidden */
  30016. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30017. /** hidden */
  30018. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30019. /** hidden */
  30020. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30021. /** hidden */
  30022. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30023. /**
  30024. * Appends the serialized animations from the source animations
  30025. * @param source Source containing the animations
  30026. * @param destination Target to store the animations
  30027. */
  30028. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30029. /**
  30030. * Static function used to serialized a specific entity
  30031. * @param entity defines the entity to serialize
  30032. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30033. * @returns a JSON compatible object representing the serialization of the entity
  30034. */
  30035. static Serialize<T>(entity: T, serializationObject?: any): any;
  30036. /**
  30037. * Creates a new entity from a serialization data object
  30038. * @param creationFunction defines a function used to instanciated the new entity
  30039. * @param source defines the source serialization data
  30040. * @param scene defines the hosting scene
  30041. * @param rootUrl defines the root url for resources
  30042. * @returns a new entity
  30043. */
  30044. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30045. /**
  30046. * Clones an object
  30047. * @param creationFunction defines the function used to instanciate the new object
  30048. * @param source defines the source object
  30049. * @returns the cloned object
  30050. */
  30051. static Clone<T>(creationFunction: () => T, source: T): T;
  30052. /**
  30053. * Instanciates a new object based on a source one (some data will be shared between both object)
  30054. * @param creationFunction defines the function used to instanciate the new object
  30055. * @param source defines the source object
  30056. * @returns the new object
  30057. */
  30058. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30059. }
  30060. }
  30061. declare module BABYLON {
  30062. /**
  30063. * This is the base class of all the camera used in the application.
  30064. * @see http://doc.babylonjs.com/features/cameras
  30065. */
  30066. export class Camera extends Node {
  30067. /** @hidden */
  30068. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30069. /**
  30070. * This is the default projection mode used by the cameras.
  30071. * It helps recreating a feeling of perspective and better appreciate depth.
  30072. * This is the best way to simulate real life cameras.
  30073. */
  30074. static readonly PERSPECTIVE_CAMERA: number;
  30075. /**
  30076. * This helps creating camera with an orthographic mode.
  30077. * 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.
  30078. */
  30079. static readonly ORTHOGRAPHIC_CAMERA: number;
  30080. /**
  30081. * This is the default FOV mode for perspective cameras.
  30082. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30083. */
  30084. static readonly FOVMODE_VERTICAL_FIXED: number;
  30085. /**
  30086. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30087. */
  30088. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30089. /**
  30090. * This specifies ther is no need for a camera rig.
  30091. * Basically only one eye is rendered corresponding to the camera.
  30092. */
  30093. static readonly RIG_MODE_NONE: number;
  30094. /**
  30095. * Simulates a camera Rig with one blue eye and one red eye.
  30096. * This can be use with 3d blue and red glasses.
  30097. */
  30098. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30099. /**
  30100. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30101. */
  30102. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30103. /**
  30104. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30105. */
  30106. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30107. /**
  30108. * Defines that both eyes of the camera will be rendered over under each other.
  30109. */
  30110. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30111. /**
  30112. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30113. */
  30114. static readonly RIG_MODE_VR: number;
  30115. /**
  30116. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30117. */
  30118. static readonly RIG_MODE_WEBVR: number;
  30119. /**
  30120. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30121. */
  30122. static readonly RIG_MODE_CUSTOM: number;
  30123. /**
  30124. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30125. */
  30126. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30127. /**
  30128. * Define the input manager associated with the camera.
  30129. */
  30130. inputs: CameraInputsManager<Camera>;
  30131. /** @hidden */
  30132. _position: Vector3;
  30133. /**
  30134. * Define the current local position of the camera in the scene
  30135. */
  30136. position: Vector3;
  30137. /**
  30138. * The vector the camera should consider as up.
  30139. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30140. */
  30141. upVector: Vector3;
  30142. /**
  30143. * Define the current limit on the left side for an orthographic camera
  30144. * In scene unit
  30145. */
  30146. orthoLeft: Nullable<number>;
  30147. /**
  30148. * Define the current limit on the right side for an orthographic camera
  30149. * In scene unit
  30150. */
  30151. orthoRight: Nullable<number>;
  30152. /**
  30153. * Define the current limit on the bottom side for an orthographic camera
  30154. * In scene unit
  30155. */
  30156. orthoBottom: Nullable<number>;
  30157. /**
  30158. * Define the current limit on the top side for an orthographic camera
  30159. * In scene unit
  30160. */
  30161. orthoTop: Nullable<number>;
  30162. /**
  30163. * Field Of View is set in Radians. (default is 0.8)
  30164. */
  30165. fov: number;
  30166. /**
  30167. * Define the minimum distance the camera can see from.
  30168. * This is important to note that the depth buffer are not infinite and the closer it starts
  30169. * the more your scene might encounter depth fighting issue.
  30170. */
  30171. minZ: number;
  30172. /**
  30173. * Define the maximum distance the camera can see to.
  30174. * This is important to note that the depth buffer are not infinite and the further it end
  30175. * the more your scene might encounter depth fighting issue.
  30176. */
  30177. maxZ: number;
  30178. /**
  30179. * Define the default inertia of the camera.
  30180. * This helps giving a smooth feeling to the camera movement.
  30181. */
  30182. inertia: number;
  30183. /**
  30184. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30185. */
  30186. mode: number;
  30187. /**
  30188. * Define wether the camera is intermediate.
  30189. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30190. */
  30191. isIntermediate: boolean;
  30192. /**
  30193. * Define the viewport of the camera.
  30194. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30195. */
  30196. viewport: Viewport;
  30197. /**
  30198. * Restricts the camera to viewing objects with the same layerMask.
  30199. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30200. */
  30201. layerMask: number;
  30202. /**
  30203. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30204. */
  30205. fovMode: number;
  30206. /**
  30207. * Rig mode of the camera.
  30208. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30209. * This is normally controlled byt the camera themselves as internal use.
  30210. */
  30211. cameraRigMode: number;
  30212. /**
  30213. * Defines the distance between both "eyes" in case of a RIG
  30214. */
  30215. interaxialDistance: number;
  30216. /**
  30217. * Defines if stereoscopic rendering is done side by side or over under.
  30218. */
  30219. isStereoscopicSideBySide: boolean;
  30220. /**
  30221. * 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
  30222. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30223. * else in the scene.
  30224. */
  30225. customRenderTargets: RenderTargetTexture[];
  30226. /**
  30227. * When set, the camera will render to this render target instead of the default canvas
  30228. */
  30229. outputRenderTarget: Nullable<RenderTargetTexture>;
  30230. /**
  30231. * Observable triggered when the camera view matrix has changed.
  30232. */
  30233. onViewMatrixChangedObservable: Observable<Camera>;
  30234. /**
  30235. * Observable triggered when the camera Projection matrix has changed.
  30236. */
  30237. onProjectionMatrixChangedObservable: Observable<Camera>;
  30238. /**
  30239. * Observable triggered when the inputs have been processed.
  30240. */
  30241. onAfterCheckInputsObservable: Observable<Camera>;
  30242. /**
  30243. * Observable triggered when reset has been called and applied to the camera.
  30244. */
  30245. onRestoreStateObservable: Observable<Camera>;
  30246. /** @hidden */
  30247. _cameraRigParams: any;
  30248. /** @hidden */
  30249. _rigCameras: Camera[];
  30250. /** @hidden */
  30251. _rigPostProcess: Nullable<PostProcess>;
  30252. protected _webvrViewMatrix: Matrix;
  30253. /** @hidden */
  30254. _skipRendering: boolean;
  30255. /** @hidden */
  30256. _projectionMatrix: Matrix;
  30257. /** @hidden */
  30258. _postProcesses: Nullable<PostProcess>[];
  30259. /** @hidden */
  30260. _activeMeshes: SmartArray<AbstractMesh>;
  30261. protected _globalPosition: Vector3;
  30262. /** hidden */
  30263. _computedViewMatrix: Matrix;
  30264. private _doNotComputeProjectionMatrix;
  30265. private _transformMatrix;
  30266. private _frustumPlanes;
  30267. private _refreshFrustumPlanes;
  30268. private _storedFov;
  30269. private _stateStored;
  30270. /**
  30271. * Instantiates a new camera object.
  30272. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30273. * @see http://doc.babylonjs.com/features/cameras
  30274. * @param name Defines the name of the camera in the scene
  30275. * @param position Defines the position of the camera
  30276. * @param scene Defines the scene the camera belongs too
  30277. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30278. */
  30279. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30280. /**
  30281. * Store current camera state (fov, position, etc..)
  30282. * @returns the camera
  30283. */
  30284. storeState(): Camera;
  30285. /**
  30286. * Restores the camera state values if it has been stored. You must call storeState() first
  30287. */
  30288. protected _restoreStateValues(): boolean;
  30289. /**
  30290. * Restored camera state. You must call storeState() first.
  30291. * @returns true if restored and false otherwise
  30292. */
  30293. restoreState(): boolean;
  30294. /**
  30295. * Gets the class name of the camera.
  30296. * @returns the class name
  30297. */
  30298. getClassName(): string;
  30299. /** @hidden */
  30300. readonly _isCamera: boolean;
  30301. /**
  30302. * Gets a string representation of the camera useful for debug purpose.
  30303. * @param fullDetails Defines that a more verboe level of logging is required
  30304. * @returns the string representation
  30305. */
  30306. toString(fullDetails?: boolean): string;
  30307. /**
  30308. * Gets the current world space position of the camera.
  30309. */
  30310. readonly globalPosition: Vector3;
  30311. /**
  30312. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30313. * @returns the active meshe list
  30314. */
  30315. getActiveMeshes(): SmartArray<AbstractMesh>;
  30316. /**
  30317. * Check wether a mesh is part of the current active mesh list of the camera
  30318. * @param mesh Defines the mesh to check
  30319. * @returns true if active, false otherwise
  30320. */
  30321. isActiveMesh(mesh: Mesh): boolean;
  30322. /**
  30323. * Is this camera ready to be used/rendered
  30324. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30325. * @return true if the camera is ready
  30326. */
  30327. isReady(completeCheck?: boolean): boolean;
  30328. /** @hidden */
  30329. _initCache(): void;
  30330. /** @hidden */
  30331. _updateCache(ignoreParentClass?: boolean): void;
  30332. /** @hidden */
  30333. _isSynchronized(): boolean;
  30334. /** @hidden */
  30335. _isSynchronizedViewMatrix(): boolean;
  30336. /** @hidden */
  30337. _isSynchronizedProjectionMatrix(): boolean;
  30338. /**
  30339. * Attach the input controls to a specific dom element to get the input from.
  30340. * @param element Defines the element the controls should be listened from
  30341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30342. */
  30343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30344. /**
  30345. * Detach the current controls from the specified dom element.
  30346. * @param element Defines the element to stop listening the inputs from
  30347. */
  30348. detachControl(element: HTMLElement): void;
  30349. /**
  30350. * Update the camera state according to the different inputs gathered during the frame.
  30351. */
  30352. update(): void;
  30353. /** @hidden */
  30354. _checkInputs(): void;
  30355. /** @hidden */
  30356. readonly rigCameras: Camera[];
  30357. /**
  30358. * Gets the post process used by the rig cameras
  30359. */
  30360. readonly rigPostProcess: Nullable<PostProcess>;
  30361. /**
  30362. * Internal, gets the first post proces.
  30363. * @returns the first post process to be run on this camera.
  30364. */
  30365. _getFirstPostProcess(): Nullable<PostProcess>;
  30366. private _cascadePostProcessesToRigCams;
  30367. /**
  30368. * Attach a post process to the camera.
  30369. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30370. * @param postProcess The post process to attach to the camera
  30371. * @param insertAt The position of the post process in case several of them are in use in the scene
  30372. * @returns the position the post process has been inserted at
  30373. */
  30374. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30375. /**
  30376. * Detach a post process to the camera.
  30377. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30378. * @param postProcess The post process to detach from the camera
  30379. */
  30380. detachPostProcess(postProcess: PostProcess): void;
  30381. /**
  30382. * Gets the current world matrix of the camera
  30383. */
  30384. getWorldMatrix(): Matrix;
  30385. /** @hidden */
  30386. _getViewMatrix(): Matrix;
  30387. /**
  30388. * Gets the current view matrix of the camera.
  30389. * @param force forces the camera to recompute the matrix without looking at the cached state
  30390. * @returns the view matrix
  30391. */
  30392. getViewMatrix(force?: boolean): Matrix;
  30393. /**
  30394. * Freeze the projection matrix.
  30395. * It will prevent the cache check of the camera projection compute and can speed up perf
  30396. * if no parameter of the camera are meant to change
  30397. * @param projection Defines manually a projection if necessary
  30398. */
  30399. freezeProjectionMatrix(projection?: Matrix): void;
  30400. /**
  30401. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30402. */
  30403. unfreezeProjectionMatrix(): void;
  30404. /**
  30405. * Gets the current projection matrix of the camera.
  30406. * @param force forces the camera to recompute the matrix without looking at the cached state
  30407. * @returns the projection matrix
  30408. */
  30409. getProjectionMatrix(force?: boolean): Matrix;
  30410. /**
  30411. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30412. * @returns a Matrix
  30413. */
  30414. getTransformationMatrix(): Matrix;
  30415. private _updateFrustumPlanes;
  30416. /**
  30417. * Checks if a cullable object (mesh...) is in the camera frustum
  30418. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30419. * @param target The object to check
  30420. * @returns true if the object is in frustum otherwise false
  30421. */
  30422. isInFrustum(target: ICullable): boolean;
  30423. /**
  30424. * Checks if a cullable object (mesh...) is in the camera frustum
  30425. * Unlike isInFrustum this cheks the full bounding box
  30426. * @param target The object to check
  30427. * @returns true if the object is in frustum otherwise false
  30428. */
  30429. isCompletelyInFrustum(target: ICullable): boolean;
  30430. /**
  30431. * Gets a ray in the forward direction from the camera.
  30432. * @param length Defines the length of the ray to create
  30433. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30434. * @param origin Defines the start point of the ray which defaults to the camera position
  30435. * @returns the forward ray
  30436. */
  30437. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30438. /**
  30439. * Releases resources associated with this node.
  30440. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30441. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30442. */
  30443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30444. /** @hidden */
  30445. _isLeftCamera: boolean;
  30446. /**
  30447. * Gets the left camera of a rig setup in case of Rigged Camera
  30448. */
  30449. readonly isLeftCamera: boolean;
  30450. /** @hidden */
  30451. _isRightCamera: boolean;
  30452. /**
  30453. * Gets the right camera of a rig setup in case of Rigged Camera
  30454. */
  30455. readonly isRightCamera: boolean;
  30456. /**
  30457. * Gets the left camera of a rig setup in case of Rigged Camera
  30458. */
  30459. readonly leftCamera: Nullable<FreeCamera>;
  30460. /**
  30461. * Gets the right camera of a rig setup in case of Rigged Camera
  30462. */
  30463. readonly rightCamera: Nullable<FreeCamera>;
  30464. /**
  30465. * Gets the left camera target of a rig setup in case of Rigged Camera
  30466. * @returns the target position
  30467. */
  30468. getLeftTarget(): Nullable<Vector3>;
  30469. /**
  30470. * Gets the right camera target of a rig setup in case of Rigged Camera
  30471. * @returns the target position
  30472. */
  30473. getRightTarget(): Nullable<Vector3>;
  30474. /**
  30475. * @hidden
  30476. */
  30477. setCameraRigMode(mode: number, rigParams: any): void;
  30478. /** @hidden */
  30479. static _setStereoscopicRigMode(camera: Camera): void;
  30480. /** @hidden */
  30481. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30482. /** @hidden */
  30483. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30484. /** @hidden */
  30485. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30486. /** @hidden */
  30487. _getVRProjectionMatrix(): Matrix;
  30488. protected _updateCameraRotationMatrix(): void;
  30489. protected _updateWebVRCameraRotationMatrix(): void;
  30490. /**
  30491. * This function MUST be overwritten by the different WebVR cameras available.
  30492. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30493. * @hidden
  30494. */
  30495. _getWebVRProjectionMatrix(): Matrix;
  30496. /**
  30497. * This function MUST be overwritten by the different WebVR cameras available.
  30498. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30499. * @hidden
  30500. */
  30501. _getWebVRViewMatrix(): Matrix;
  30502. /** @hidden */
  30503. setCameraRigParameter(name: string, value: any): void;
  30504. /**
  30505. * needs to be overridden by children so sub has required properties to be copied
  30506. * @hidden
  30507. */
  30508. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30509. /**
  30510. * May need to be overridden by children
  30511. * @hidden
  30512. */
  30513. _updateRigCameras(): void;
  30514. /** @hidden */
  30515. _setupInputs(): void;
  30516. /**
  30517. * Serialiaze the camera setup to a json represention
  30518. * @returns the JSON representation
  30519. */
  30520. serialize(): any;
  30521. /**
  30522. * Clones the current camera.
  30523. * @param name The cloned camera name
  30524. * @returns the cloned camera
  30525. */
  30526. clone(name: string): Camera;
  30527. /**
  30528. * Gets the direction of the camera relative to a given local axis.
  30529. * @param localAxis Defines the reference axis to provide a relative direction.
  30530. * @return the direction
  30531. */
  30532. getDirection(localAxis: Vector3): Vector3;
  30533. /**
  30534. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30535. * @param localAxis Defines the reference axis to provide a relative direction.
  30536. * @param result Defines the vector to store the result in
  30537. */
  30538. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30539. /**
  30540. * Gets a camera constructor for a given camera type
  30541. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30542. * @param name The name of the camera the result will be able to instantiate
  30543. * @param scene The scene the result will construct the camera in
  30544. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30545. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30546. * @returns a factory method to construc the camera
  30547. */
  30548. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30549. /**
  30550. * Compute the world matrix of the camera.
  30551. * @returns the camera workd matrix
  30552. */
  30553. computeWorldMatrix(): Matrix;
  30554. /**
  30555. * Parse a JSON and creates the camera from the parsed information
  30556. * @param parsedCamera The JSON to parse
  30557. * @param scene The scene to instantiate the camera in
  30558. * @returns the newly constructed camera
  30559. */
  30560. static Parse(parsedCamera: any, scene: Scene): Camera;
  30561. }
  30562. }
  30563. declare module BABYLON {
  30564. /**
  30565. * Interface for any object that can request an animation frame
  30566. */
  30567. export interface ICustomAnimationFrameRequester {
  30568. /**
  30569. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30570. */
  30571. renderFunction?: Function;
  30572. /**
  30573. * Called to request the next frame to render to
  30574. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30575. */
  30576. requestAnimationFrame: Function;
  30577. /**
  30578. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30579. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30580. */
  30581. requestID?: number;
  30582. }
  30583. /**
  30584. * Interface containing an array of animations
  30585. */
  30586. export interface IAnimatable {
  30587. /**
  30588. * Array of animations
  30589. */
  30590. animations: Nullable<Array<Animation>>;
  30591. }
  30592. /** Interface used by value gradients (color, factor, ...) */
  30593. export interface IValueGradient {
  30594. /**
  30595. * Gets or sets the gradient value (between 0 and 1)
  30596. */
  30597. gradient: number;
  30598. }
  30599. /** Class used to store color4 gradient */
  30600. export class ColorGradient implements IValueGradient {
  30601. /**
  30602. * Gets or sets the gradient value (between 0 and 1)
  30603. */
  30604. gradient: number;
  30605. /**
  30606. * Gets or sets first associated color
  30607. */
  30608. color1: Color4;
  30609. /**
  30610. * Gets or sets second associated color
  30611. */
  30612. color2?: Color4;
  30613. /**
  30614. * Will get a color picked randomly between color1 and color2.
  30615. * If color2 is undefined then color1 will be used
  30616. * @param result defines the target Color4 to store the result in
  30617. */
  30618. getColorToRef(result: Color4): void;
  30619. }
  30620. /** Class used to store color 3 gradient */
  30621. export class Color3Gradient implements IValueGradient {
  30622. /**
  30623. * Gets or sets the gradient value (between 0 and 1)
  30624. */
  30625. gradient: number;
  30626. /**
  30627. * Gets or sets the associated color
  30628. */
  30629. color: Color3;
  30630. }
  30631. /** Class used to store factor gradient */
  30632. export class FactorGradient implements IValueGradient {
  30633. /**
  30634. * Gets or sets the gradient value (between 0 and 1)
  30635. */
  30636. gradient: number;
  30637. /**
  30638. * Gets or sets first associated factor
  30639. */
  30640. factor1: number;
  30641. /**
  30642. * Gets or sets second associated factor
  30643. */
  30644. factor2?: number;
  30645. /**
  30646. * Will get a number picked randomly between factor1 and factor2.
  30647. * If factor2 is undefined then factor1 will be used
  30648. * @returns the picked number
  30649. */
  30650. getFactor(): number;
  30651. }
  30652. /**
  30653. * @ignore
  30654. * Application error to support additional information when loading a file
  30655. */
  30656. export class LoadFileError extends Error {
  30657. /** defines the optional web request */
  30658. request?: WebRequest | undefined;
  30659. private static _setPrototypeOf;
  30660. /**
  30661. * Creates a new LoadFileError
  30662. * @param message defines the message of the error
  30663. * @param request defines the optional web request
  30664. */
  30665. constructor(message: string,
  30666. /** defines the optional web request */
  30667. request?: WebRequest | undefined);
  30668. }
  30669. /**
  30670. * Class used to define a retry strategy when error happens while loading assets
  30671. */
  30672. export class RetryStrategy {
  30673. /**
  30674. * Function used to defines an exponential back off strategy
  30675. * @param maxRetries defines the maximum number of retries (3 by default)
  30676. * @param baseInterval defines the interval between retries
  30677. * @returns the strategy function to use
  30678. */
  30679. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30680. }
  30681. /**
  30682. * File request interface
  30683. */
  30684. export interface IFileRequest {
  30685. /**
  30686. * Raised when the request is complete (success or error).
  30687. */
  30688. onCompleteObservable: Observable<IFileRequest>;
  30689. /**
  30690. * Aborts the request for a file.
  30691. */
  30692. abort: () => void;
  30693. }
  30694. /**
  30695. * Class containing a set of static utilities functions
  30696. */
  30697. export class Tools {
  30698. /**
  30699. * Gets or sets the base URL to use to load assets
  30700. */
  30701. static BaseUrl: string;
  30702. /**
  30703. * Enable/Disable Custom HTTP Request Headers globally.
  30704. * default = false
  30705. * @see CustomRequestHeaders
  30706. */
  30707. static UseCustomRequestHeaders: boolean;
  30708. /**
  30709. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30710. * i.e. when loading files, where the server/service expects an Authorization header
  30711. */
  30712. static CustomRequestHeaders: {
  30713. [key: string]: string;
  30714. };
  30715. /**
  30716. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30717. */
  30718. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30719. /**
  30720. * Default behaviour for cors in the application.
  30721. * It can be a string if the expected behavior is identical in the entire app.
  30722. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30723. */
  30724. static CorsBehavior: string | ((url: string | string[]) => string);
  30725. /**
  30726. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30727. * @ignorenaming
  30728. */
  30729. static UseFallbackTexture: boolean;
  30730. /**
  30731. * Use this object to register external classes like custom textures or material
  30732. * to allow the laoders to instantiate them
  30733. */
  30734. static RegisteredExternalClasses: {
  30735. [key: string]: Object;
  30736. };
  30737. /**
  30738. * Texture content used if a texture cannot loaded
  30739. * @ignorenaming
  30740. */
  30741. static fallbackTexture: string;
  30742. /**
  30743. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30744. * @param u defines the coordinate on X axis
  30745. * @param v defines the coordinate on Y axis
  30746. * @param width defines the width of the source data
  30747. * @param height defines the height of the source data
  30748. * @param pixels defines the source byte array
  30749. * @param color defines the output color
  30750. */
  30751. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30752. /**
  30753. * Interpolates between a and b via alpha
  30754. * @param a The lower value (returned when alpha = 0)
  30755. * @param b The upper value (returned when alpha = 1)
  30756. * @param alpha The interpolation-factor
  30757. * @return The mixed value
  30758. */
  30759. static Mix(a: number, b: number, alpha: number): number;
  30760. /**
  30761. * Tries to instantiate a new object from a given class name
  30762. * @param className defines the class name to instantiate
  30763. * @returns the new object or null if the system was not able to do the instantiation
  30764. */
  30765. static Instantiate(className: string): any;
  30766. /**
  30767. * Provides a slice function that will work even on IE
  30768. * @param data defines the array to slice
  30769. * @param start defines the start of the data (optional)
  30770. * @param end defines the end of the data (optional)
  30771. * @returns the new sliced array
  30772. */
  30773. static Slice<T>(data: T, start?: number, end?: number): T;
  30774. /**
  30775. * Polyfill for setImmediate
  30776. * @param action defines the action to execute after the current execution block
  30777. */
  30778. static SetImmediate(action: () => void): void;
  30779. /**
  30780. * Function indicating if a number is an exponent of 2
  30781. * @param value defines the value to test
  30782. * @returns true if the value is an exponent of 2
  30783. */
  30784. static IsExponentOfTwo(value: number): boolean;
  30785. private static _tmpFloatArray;
  30786. /**
  30787. * Returns the nearest 32-bit single precision float representation of a Number
  30788. * @param value A Number. If the parameter is of a different type, it will get converted
  30789. * to a number or to NaN if it cannot be converted
  30790. * @returns number
  30791. */
  30792. static FloatRound(value: number): number;
  30793. /**
  30794. * Find the next highest power of two.
  30795. * @param x Number to start search from.
  30796. * @return Next highest power of two.
  30797. */
  30798. static CeilingPOT(x: number): number;
  30799. /**
  30800. * Find the next lowest power of two.
  30801. * @param x Number to start search from.
  30802. * @return Next lowest power of two.
  30803. */
  30804. static FloorPOT(x: number): number;
  30805. /**
  30806. * Find the nearest power of two.
  30807. * @param x Number to start search from.
  30808. * @return Next nearest power of two.
  30809. */
  30810. static NearestPOT(x: number): number;
  30811. /**
  30812. * Get the closest exponent of two
  30813. * @param value defines the value to approximate
  30814. * @param max defines the maximum value to return
  30815. * @param mode defines how to define the closest value
  30816. * @returns closest exponent of two of the given value
  30817. */
  30818. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30819. /**
  30820. * Extracts the filename from a path
  30821. * @param path defines the path to use
  30822. * @returns the filename
  30823. */
  30824. static GetFilename(path: string): string;
  30825. /**
  30826. * Extracts the "folder" part of a path (everything before the filename).
  30827. * @param uri The URI to extract the info from
  30828. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30829. * @returns The "folder" part of the path
  30830. */
  30831. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30832. /**
  30833. * Extracts text content from a DOM element hierarchy
  30834. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30835. */
  30836. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30837. /**
  30838. * Convert an angle in radians to degrees
  30839. * @param angle defines the angle to convert
  30840. * @returns the angle in degrees
  30841. */
  30842. static ToDegrees(angle: number): number;
  30843. /**
  30844. * Convert an angle in degrees to radians
  30845. * @param angle defines the angle to convert
  30846. * @returns the angle in radians
  30847. */
  30848. static ToRadians(angle: number): number;
  30849. /**
  30850. * Encode a buffer to a base64 string
  30851. * @param buffer defines the buffer to encode
  30852. * @returns the encoded string
  30853. */
  30854. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30855. /**
  30856. * Extracts minimum and maximum values from a list of indexed positions
  30857. * @param positions defines the positions to use
  30858. * @param indices defines the indices to the positions
  30859. * @param indexStart defines the start index
  30860. * @param indexCount defines the end index
  30861. * @param bias defines bias value to add to the result
  30862. * @return minimum and maximum values
  30863. */
  30864. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30865. minimum: Vector3;
  30866. maximum: Vector3;
  30867. };
  30868. /**
  30869. * Extracts minimum and maximum values from a list of positions
  30870. * @param positions defines the positions to use
  30871. * @param start defines the start index in the positions array
  30872. * @param count defines the number of positions to handle
  30873. * @param bias defines bias value to add to the result
  30874. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30875. * @return minimum and maximum values
  30876. */
  30877. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30878. minimum: Vector3;
  30879. maximum: Vector3;
  30880. };
  30881. /**
  30882. * Returns an array if obj is not an array
  30883. * @param obj defines the object to evaluate as an array
  30884. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30885. * @returns either obj directly if obj is an array or a new array containing obj
  30886. */
  30887. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30888. /**
  30889. * Gets the pointer prefix to use
  30890. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30891. */
  30892. static GetPointerPrefix(): string;
  30893. /**
  30894. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30895. * @param func - the function to be called
  30896. * @param requester - the object that will request the next frame. Falls back to window.
  30897. * @returns frame number
  30898. */
  30899. static QueueNewFrame(func: () => void, requester?: any): number;
  30900. /**
  30901. * Ask the browser to promote the current element to fullscreen rendering mode
  30902. * @param element defines the DOM element to promote
  30903. */
  30904. static RequestFullscreen(element: HTMLElement): void;
  30905. /**
  30906. * Asks the browser to exit fullscreen mode
  30907. */
  30908. static ExitFullscreen(): void;
  30909. /**
  30910. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30911. * @param url define the url we are trying
  30912. * @param element define the dom element where to configure the cors policy
  30913. */
  30914. static SetCorsBehavior(url: string | string[], element: {
  30915. crossOrigin: string | null;
  30916. }): void;
  30917. /**
  30918. * Removes unwanted characters from an url
  30919. * @param url defines the url to clean
  30920. * @returns the cleaned url
  30921. */
  30922. static CleanUrl(url: string): string;
  30923. /**
  30924. * Gets or sets a function used to pre-process url before using them to load assets
  30925. */
  30926. static PreprocessUrl: (url: string) => string;
  30927. /**
  30928. * Loads an image as an HTMLImageElement.
  30929. * @param input url string, ArrayBuffer, or Blob to load
  30930. * @param onLoad callback called when the image successfully loads
  30931. * @param onError callback called when the image fails to load
  30932. * @param offlineProvider offline provider for caching
  30933. * @returns the HTMLImageElement of the loaded image
  30934. */
  30935. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30936. /**
  30937. * Loads a file
  30938. * @param url url string, ArrayBuffer, or Blob to load
  30939. * @param onSuccess callback called when the file successfully loads
  30940. * @param onProgress callback called while file is loading (if the server supports this mode)
  30941. * @param offlineProvider defines the offline provider for caching
  30942. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30943. * @param onError callback called when the file fails to load
  30944. * @returns a file request object
  30945. */
  30946. 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;
  30947. /**
  30948. * Load a script (identified by an url). When the url returns, the
  30949. * content of this file is added into a new script element, attached to the DOM (body element)
  30950. * @param scriptUrl defines the url of the script to laod
  30951. * @param onSuccess defines the callback called when the script is loaded
  30952. * @param onError defines the callback to call if an error occurs
  30953. * @param scriptId defines the id of the script element
  30954. */
  30955. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30956. /**
  30957. * Load an asynchronous script (identified by an url). When the url returns, the
  30958. * content of this file is added into a new script element, attached to the DOM (body element)
  30959. * @param scriptUrl defines the url of the script to laod
  30960. * @param scriptId defines the id of the script element
  30961. * @returns a promise request object
  30962. */
  30963. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30964. /**
  30965. * Loads a file from a blob
  30966. * @param fileToLoad defines the blob to use
  30967. * @param callback defines the callback to call when data is loaded
  30968. * @param progressCallback defines the callback to call during loading process
  30969. * @returns a file request object
  30970. */
  30971. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30972. /**
  30973. * Loads a file
  30974. * @param fileToLoad defines the file to load
  30975. * @param callback defines the callback to call when data is loaded
  30976. * @param progressCallBack defines the callback to call during loading process
  30977. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30978. * @returns a file request object
  30979. */
  30980. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30981. /**
  30982. * Creates a data url from a given string content
  30983. * @param content defines the content to convert
  30984. * @returns the new data url link
  30985. */
  30986. static FileAsURL(content: string): string;
  30987. /**
  30988. * Format the given number to a specific decimal format
  30989. * @param value defines the number to format
  30990. * @param decimals defines the number of decimals to use
  30991. * @returns the formatted string
  30992. */
  30993. static Format(value: number, decimals?: number): string;
  30994. /**
  30995. * Checks if a given vector is inside a specific range
  30996. * @param v defines the vector to test
  30997. * @param min defines the minimum range
  30998. * @param max defines the maximum range
  30999. */
  31000. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31001. /**
  31002. * Tries to copy an object by duplicating every property
  31003. * @param source defines the source object
  31004. * @param destination defines the target object
  31005. * @param doNotCopyList defines a list of properties to avoid
  31006. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31007. */
  31008. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31009. /**
  31010. * Gets a boolean indicating if the given object has no own property
  31011. * @param obj defines the object to test
  31012. * @returns true if object has no own property
  31013. */
  31014. static IsEmpty(obj: any): boolean;
  31015. /**
  31016. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31017. * @param str Source string
  31018. * @param suffix Suffix to search for in the source string
  31019. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31020. */
  31021. static EndsWith(str: string, suffix: string): boolean;
  31022. /**
  31023. * Function used to register events at window level
  31024. * @param events defines the events to register
  31025. */
  31026. static RegisterTopRootEvents(events: {
  31027. name: string;
  31028. handler: Nullable<(e: FocusEvent) => any>;
  31029. }[]): void;
  31030. /**
  31031. * Function used to unregister events from window level
  31032. * @param events defines the events to unregister
  31033. */
  31034. static UnregisterTopRootEvents(events: {
  31035. name: string;
  31036. handler: Nullable<(e: FocusEvent) => any>;
  31037. }[]): void;
  31038. /**
  31039. * @ignore
  31040. */
  31041. static _ScreenshotCanvas: HTMLCanvasElement;
  31042. /**
  31043. * Dumps the current bound framebuffer
  31044. * @param width defines the rendering width
  31045. * @param height defines the rendering height
  31046. * @param engine defines the hosting engine
  31047. * @param successCallback defines the callback triggered once the data are available
  31048. * @param mimeType defines the mime type of the result
  31049. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31050. */
  31051. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31052. /**
  31053. * Converts the canvas data to blob.
  31054. * This acts as a polyfill for browsers not supporting the to blob function.
  31055. * @param canvas Defines the canvas to extract the data from
  31056. * @param successCallback Defines the callback triggered once the data are available
  31057. * @param mimeType Defines the mime type of the result
  31058. */
  31059. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31060. /**
  31061. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31062. * @param successCallback defines the callback triggered once the data are available
  31063. * @param mimeType defines the mime type of the result
  31064. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31065. */
  31066. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31067. /**
  31068. * Downloads a blob in the browser
  31069. * @param blob defines the blob to download
  31070. * @param fileName defines the name of the downloaded file
  31071. */
  31072. static Download(blob: Blob, fileName: string): void;
  31073. /**
  31074. * Captures a screenshot of the current rendering
  31075. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31076. * @param engine defines the rendering engine
  31077. * @param camera defines the source camera
  31078. * @param size This parameter can be set to a single number or to an object with the
  31079. * following (optional) properties: precision, width, height. If a single number is passed,
  31080. * it will be used for both width and height. If an object is passed, the screenshot size
  31081. * will be derived from the parameters. The precision property is a multiplier allowing
  31082. * rendering at a higher or lower resolution
  31083. * @param successCallback defines the callback receives a single parameter which contains the
  31084. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31085. * src parameter of an <img> to display it
  31086. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31087. * Check your browser for supported MIME types
  31088. */
  31089. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31090. /**
  31091. * Generates an image screenshot from the specified camera.
  31092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31093. * @param engine The engine to use for rendering
  31094. * @param camera The camera to use for rendering
  31095. * @param size This parameter can be set to a single number or to an object with the
  31096. * following (optional) properties: precision, width, height. If a single number is passed,
  31097. * it will be used for both width and height. If an object is passed, the screenshot size
  31098. * will be derived from the parameters. The precision property is a multiplier allowing
  31099. * rendering at a higher or lower resolution
  31100. * @param successCallback The callback receives a single parameter which contains the
  31101. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31102. * src parameter of an <img> to display it
  31103. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31104. * Check your browser for supported MIME types
  31105. * @param samples Texture samples (default: 1)
  31106. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31107. * @param fileName A name for for the downloaded file.
  31108. */
  31109. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31110. /**
  31111. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31112. * Be aware Math.random() could cause collisions, but:
  31113. * "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"
  31114. * @returns a pseudo random id
  31115. */
  31116. static RandomId(): string;
  31117. /**
  31118. * Test if the given uri is a base64 string
  31119. * @param uri The uri to test
  31120. * @return True if the uri is a base64 string or false otherwise
  31121. */
  31122. static IsBase64(uri: string): boolean;
  31123. /**
  31124. * Decode the given base64 uri.
  31125. * @param uri The uri to decode
  31126. * @return The decoded base64 data.
  31127. */
  31128. static DecodeBase64(uri: string): ArrayBuffer;
  31129. /**
  31130. * Gets the absolute url.
  31131. * @param url the input url
  31132. * @return the absolute url
  31133. */
  31134. static GetAbsoluteUrl(url: string): string;
  31135. /**
  31136. * No log
  31137. */
  31138. static readonly NoneLogLevel: number;
  31139. /**
  31140. * Only message logs
  31141. */
  31142. static readonly MessageLogLevel: number;
  31143. /**
  31144. * Only warning logs
  31145. */
  31146. static readonly WarningLogLevel: number;
  31147. /**
  31148. * Only error logs
  31149. */
  31150. static readonly ErrorLogLevel: number;
  31151. /**
  31152. * All logs
  31153. */
  31154. static readonly AllLogLevel: number;
  31155. /**
  31156. * Gets a value indicating the number of loading errors
  31157. * @ignorenaming
  31158. */
  31159. static readonly errorsCount: number;
  31160. /**
  31161. * Callback called when a new log is added
  31162. */
  31163. static OnNewCacheEntry: (entry: string) => void;
  31164. /**
  31165. * Log a message to the console
  31166. * @param message defines the message to log
  31167. */
  31168. static Log(message: string): void;
  31169. /**
  31170. * Write a warning message to the console
  31171. * @param message defines the message to log
  31172. */
  31173. static Warn(message: string): void;
  31174. /**
  31175. * Write an error message to the console
  31176. * @param message defines the message to log
  31177. */
  31178. static Error(message: string): void;
  31179. /**
  31180. * Gets current log cache (list of logs)
  31181. */
  31182. static readonly LogCache: string;
  31183. /**
  31184. * Clears the log cache
  31185. */
  31186. static ClearLogCache(): void;
  31187. /**
  31188. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31189. */
  31190. static LogLevels: number;
  31191. /**
  31192. * Checks if the loaded document was accessed via `file:`-Protocol.
  31193. * @returns boolean
  31194. */
  31195. static IsFileURL(): boolean;
  31196. /**
  31197. * Checks if the window object exists
  31198. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31199. */
  31200. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31201. /**
  31202. * No performance log
  31203. */
  31204. static readonly PerformanceNoneLogLevel: number;
  31205. /**
  31206. * Use user marks to log performance
  31207. */
  31208. static readonly PerformanceUserMarkLogLevel: number;
  31209. /**
  31210. * Log performance to the console
  31211. */
  31212. static readonly PerformanceConsoleLogLevel: number;
  31213. private static _performance;
  31214. /**
  31215. * Sets the current performance log level
  31216. */
  31217. static PerformanceLogLevel: number;
  31218. private static _StartPerformanceCounterDisabled;
  31219. private static _EndPerformanceCounterDisabled;
  31220. private static _StartUserMark;
  31221. private static _EndUserMark;
  31222. private static _StartPerformanceConsole;
  31223. private static _EndPerformanceConsole;
  31224. /**
  31225. * Starts a performance counter
  31226. */
  31227. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31228. /**
  31229. * Ends a specific performance coutner
  31230. */
  31231. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31232. /**
  31233. * Gets either window.performance.now() if supported or Date.now() else
  31234. */
  31235. static readonly Now: number;
  31236. /**
  31237. * This method will return the name of the class used to create the instance of the given object.
  31238. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31239. * @param object the object to get the class name from
  31240. * @param isType defines if the object is actually a type
  31241. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31242. */
  31243. static GetClassName(object: any, isType?: boolean): string;
  31244. /**
  31245. * Gets the first element of an array satisfying a given predicate
  31246. * @param array defines the array to browse
  31247. * @param predicate defines the predicate to use
  31248. * @returns null if not found or the element
  31249. */
  31250. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31251. /**
  31252. * This method will return the name of the full name of the class, including its owning module (if any).
  31253. * 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).
  31254. * @param object the object to get the class name from
  31255. * @param isType defines if the object is actually a type
  31256. * @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.
  31257. * @ignorenaming
  31258. */
  31259. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31260. /**
  31261. * Returns a promise that resolves after the given amount of time.
  31262. * @param delay Number of milliseconds to delay
  31263. * @returns Promise that resolves after the given amount of time
  31264. */
  31265. static DelayAsync(delay: number): Promise<void>;
  31266. /**
  31267. * Gets the current gradient from an array of IValueGradient
  31268. * @param ratio defines the current ratio to get
  31269. * @param gradients defines the array of IValueGradient
  31270. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31271. */
  31272. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31273. }
  31274. /**
  31275. * This class is used to track a performance counter which is number based.
  31276. * The user has access to many properties which give statistics of different nature.
  31277. *
  31278. * The implementer can track two kinds of Performance Counter: time and count.
  31279. * 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.
  31280. * 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.
  31281. */
  31282. export class PerfCounter {
  31283. /**
  31284. * Gets or sets a global boolean to turn on and off all the counters
  31285. */
  31286. static Enabled: boolean;
  31287. /**
  31288. * Returns the smallest value ever
  31289. */
  31290. readonly min: number;
  31291. /**
  31292. * Returns the biggest value ever
  31293. */
  31294. readonly max: number;
  31295. /**
  31296. * Returns the average value since the performance counter is running
  31297. */
  31298. readonly average: number;
  31299. /**
  31300. * Returns the average value of the last second the counter was monitored
  31301. */
  31302. readonly lastSecAverage: number;
  31303. /**
  31304. * Returns the current value
  31305. */
  31306. readonly current: number;
  31307. /**
  31308. * Gets the accumulated total
  31309. */
  31310. readonly total: number;
  31311. /**
  31312. * Gets the total value count
  31313. */
  31314. readonly count: number;
  31315. /**
  31316. * Creates a new counter
  31317. */
  31318. constructor();
  31319. /**
  31320. * Call this method to start monitoring a new frame.
  31321. * 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.
  31322. */
  31323. fetchNewFrame(): void;
  31324. /**
  31325. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31326. * @param newCount the count value to add to the monitored count
  31327. * @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.
  31328. */
  31329. addCount(newCount: number, fetchResult: boolean): void;
  31330. /**
  31331. * Start monitoring this performance counter
  31332. */
  31333. beginMonitoring(): void;
  31334. /**
  31335. * Compute the time lapsed since the previous beginMonitoring() call.
  31336. * @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
  31337. */
  31338. endMonitoring(newFrame?: boolean): void;
  31339. private _fetchResult;
  31340. private _startMonitoringTime;
  31341. private _min;
  31342. private _max;
  31343. private _average;
  31344. private _current;
  31345. private _totalValueCount;
  31346. private _totalAccumulated;
  31347. private _lastSecAverage;
  31348. private _lastSecAccumulated;
  31349. private _lastSecTime;
  31350. private _lastSecValueCount;
  31351. }
  31352. /**
  31353. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31354. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31355. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31356. * @param name The name of the class, case should be preserved
  31357. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31358. */
  31359. export function className(name: string, module?: string): (target: Object) => void;
  31360. /**
  31361. * An implementation of a loop for asynchronous functions.
  31362. */
  31363. export class AsyncLoop {
  31364. /**
  31365. * Defines the number of iterations for the loop
  31366. */
  31367. iterations: number;
  31368. /**
  31369. * Defines the current index of the loop.
  31370. */
  31371. index: number;
  31372. private _done;
  31373. private _fn;
  31374. private _successCallback;
  31375. /**
  31376. * Constructor.
  31377. * @param iterations the number of iterations.
  31378. * @param func the function to run each iteration
  31379. * @param successCallback the callback that will be called upon succesful execution
  31380. * @param offset starting offset.
  31381. */
  31382. constructor(
  31383. /**
  31384. * Defines the number of iterations for the loop
  31385. */
  31386. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31387. /**
  31388. * Execute the next iteration. Must be called after the last iteration was finished.
  31389. */
  31390. executeNext(): void;
  31391. /**
  31392. * Break the loop and run the success callback.
  31393. */
  31394. breakLoop(): void;
  31395. /**
  31396. * Create and run an async loop.
  31397. * @param iterations the number of iterations.
  31398. * @param fn the function to run each iteration
  31399. * @param successCallback the callback that will be called upon succesful execution
  31400. * @param offset starting offset.
  31401. * @returns the created async loop object
  31402. */
  31403. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31404. /**
  31405. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31406. * @param iterations total number of iterations
  31407. * @param syncedIterations number of synchronous iterations in each async iteration.
  31408. * @param fn the function to call each iteration.
  31409. * @param callback a success call back that will be called when iterating stops.
  31410. * @param breakFunction a break condition (optional)
  31411. * @param timeout timeout settings for the setTimeout function. default - 0.
  31412. * @returns the created async loop object
  31413. */
  31414. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31415. }
  31416. }
  31417. declare module BABYLON {
  31418. /** @hidden */
  31419. export interface ICollisionCoordinator {
  31420. createCollider(): Collider;
  31421. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31422. init(scene: Scene): void;
  31423. }
  31424. /** @hidden */
  31425. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31426. private _scene;
  31427. private _scaledPosition;
  31428. private _scaledVelocity;
  31429. private _finalPosition;
  31430. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31431. createCollider(): Collider;
  31432. init(scene: Scene): void;
  31433. private _collideWithWorld;
  31434. }
  31435. }
  31436. declare module BABYLON {
  31437. /**
  31438. * This class defines the direct association between an animation and a target
  31439. */
  31440. export class TargetedAnimation {
  31441. /**
  31442. * Animation to perform
  31443. */
  31444. animation: Animation;
  31445. /**
  31446. * Target to animate
  31447. */
  31448. target: any;
  31449. }
  31450. /**
  31451. * Use this class to create coordinated animations on multiple targets
  31452. */
  31453. export class AnimationGroup implements IDisposable {
  31454. /** The name of the animation group */
  31455. name: string;
  31456. private _scene;
  31457. private _targetedAnimations;
  31458. private _animatables;
  31459. private _from;
  31460. private _to;
  31461. private _isStarted;
  31462. private _isPaused;
  31463. private _speedRatio;
  31464. /**
  31465. * Gets or sets the unique id of the node
  31466. */
  31467. uniqueId: number;
  31468. /**
  31469. * This observable will notify when one animation have ended
  31470. */
  31471. onAnimationEndObservable: Observable<TargetedAnimation>;
  31472. /**
  31473. * Observer raised when one animation loops
  31474. */
  31475. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31476. /**
  31477. * This observable will notify when all animations have ended.
  31478. */
  31479. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31480. /**
  31481. * This observable will notify when all animations have paused.
  31482. */
  31483. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31484. /**
  31485. * This observable will notify when all animations are playing.
  31486. */
  31487. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31488. /**
  31489. * Gets the first frame
  31490. */
  31491. readonly from: number;
  31492. /**
  31493. * Gets the last frame
  31494. */
  31495. readonly to: number;
  31496. /**
  31497. * Define if the animations are started
  31498. */
  31499. readonly isStarted: boolean;
  31500. /**
  31501. * Gets a value indicating that the current group is playing
  31502. */
  31503. readonly isPlaying: boolean;
  31504. /**
  31505. * Gets or sets the speed ratio to use for all animations
  31506. */
  31507. /**
  31508. * Gets or sets the speed ratio to use for all animations
  31509. */
  31510. speedRatio: number;
  31511. /**
  31512. * Gets the targeted animations for this animation group
  31513. */
  31514. readonly targetedAnimations: Array<TargetedAnimation>;
  31515. /**
  31516. * returning the list of animatables controlled by this animation group.
  31517. */
  31518. readonly animatables: Array<Animatable>;
  31519. /**
  31520. * Instantiates a new Animation Group.
  31521. * This helps managing several animations at once.
  31522. * @see http://doc.babylonjs.com/how_to/group
  31523. * @param name Defines the name of the group
  31524. * @param scene Defines the scene the group belongs to
  31525. */
  31526. constructor(
  31527. /** The name of the animation group */
  31528. name: string, scene?: Nullable<Scene>);
  31529. /**
  31530. * Add an animation (with its target) in the group
  31531. * @param animation defines the animation we want to add
  31532. * @param target defines the target of the animation
  31533. * @returns the TargetedAnimation object
  31534. */
  31535. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31536. /**
  31537. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31538. * It can add constant keys at begin or end
  31539. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31540. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31541. * @returns the animation group
  31542. */
  31543. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31544. /**
  31545. * Start all animations on given targets
  31546. * @param loop defines if animations must loop
  31547. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31548. * @param from defines the from key (optional)
  31549. * @param to defines the to key (optional)
  31550. * @returns the current animation group
  31551. */
  31552. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31553. /**
  31554. * Pause all animations
  31555. * @returns the animation group
  31556. */
  31557. pause(): AnimationGroup;
  31558. /**
  31559. * Play all animations to initial state
  31560. * This function will start() the animations if they were not started or will restart() them if they were paused
  31561. * @param loop defines if animations must loop
  31562. * @returns the animation group
  31563. */
  31564. play(loop?: boolean): AnimationGroup;
  31565. /**
  31566. * Reset all animations to initial state
  31567. * @returns the animation group
  31568. */
  31569. reset(): AnimationGroup;
  31570. /**
  31571. * Restart animations from key 0
  31572. * @returns the animation group
  31573. */
  31574. restart(): AnimationGroup;
  31575. /**
  31576. * Stop all animations
  31577. * @returns the animation group
  31578. */
  31579. stop(): AnimationGroup;
  31580. /**
  31581. * Set animation weight for all animatables
  31582. * @param weight defines the weight to use
  31583. * @return the animationGroup
  31584. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31585. */
  31586. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31587. /**
  31588. * Synchronize and normalize all animatables with a source animatable
  31589. * @param root defines the root animatable to synchronize with
  31590. * @return the animationGroup
  31591. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31592. */
  31593. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31594. /**
  31595. * Goes to a specific frame in this animation group
  31596. * @param frame the frame number to go to
  31597. * @return the animationGroup
  31598. */
  31599. goToFrame(frame: number): AnimationGroup;
  31600. /**
  31601. * Dispose all associated resources
  31602. */
  31603. dispose(): void;
  31604. private _checkAnimationGroupEnded;
  31605. /**
  31606. * Clone the current animation group and returns a copy
  31607. * @param newName defines the name of the new group
  31608. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31609. * @returns the new aniamtion group
  31610. */
  31611. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31612. /**
  31613. * Returns a new AnimationGroup object parsed from the source provided.
  31614. * @param parsedAnimationGroup defines the source
  31615. * @param scene defines the scene that will receive the animationGroup
  31616. * @returns a new AnimationGroup
  31617. */
  31618. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31619. /**
  31620. * Returns the string "AnimationGroup"
  31621. * @returns "AnimationGroup"
  31622. */
  31623. getClassName(): string;
  31624. /**
  31625. * Creates a detailled string about the object
  31626. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31627. * @returns a string representing the object
  31628. */
  31629. toString(fullDetails?: boolean): string;
  31630. }
  31631. }
  31632. declare module BABYLON {
  31633. /**
  31634. * Define an interface for all classes that will hold resources
  31635. */
  31636. export interface IDisposable {
  31637. /**
  31638. * Releases all held resources
  31639. */
  31640. dispose(): void;
  31641. }
  31642. /** Interface defining initialization parameters for Scene class */
  31643. export interface SceneOptions {
  31644. /**
  31645. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31646. * It will improve performance when the number of geometries becomes important.
  31647. */
  31648. useGeometryUniqueIdsMap?: boolean;
  31649. /**
  31650. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31651. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31652. */
  31653. useMaterialMeshMap?: boolean;
  31654. /**
  31655. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31656. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31657. */
  31658. useClonedMeshhMap?: boolean;
  31659. }
  31660. /**
  31661. * Represents a scene to be rendered by the engine.
  31662. * @see http://doc.babylonjs.com/features/scene
  31663. */
  31664. export class Scene extends AbstractScene implements IAnimatable {
  31665. private static _uniqueIdCounter;
  31666. /** The fog is deactivated */
  31667. static readonly FOGMODE_NONE: number;
  31668. /** The fog density is following an exponential function */
  31669. static readonly FOGMODE_EXP: number;
  31670. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31671. static readonly FOGMODE_EXP2: number;
  31672. /** The fog density is following a linear function. */
  31673. static readonly FOGMODE_LINEAR: number;
  31674. /**
  31675. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31676. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31677. */
  31678. static MinDeltaTime: number;
  31679. /**
  31680. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31681. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31682. */
  31683. static MaxDeltaTime: number;
  31684. /**
  31685. * Factory used to create the default material.
  31686. * @param name The name of the material to create
  31687. * @param scene The scene to create the material for
  31688. * @returns The default material
  31689. */
  31690. static DefaultMaterialFactory(scene: Scene): Material;
  31691. /**
  31692. * Factory used to create the a collision coordinator.
  31693. * @returns The collision coordinator
  31694. */
  31695. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31696. /** @hidden */
  31697. readonly _isScene: boolean;
  31698. /**
  31699. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31700. */
  31701. autoClear: boolean;
  31702. /**
  31703. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31704. */
  31705. autoClearDepthAndStencil: boolean;
  31706. /**
  31707. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31708. */
  31709. clearColor: Color4;
  31710. /**
  31711. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31712. */
  31713. ambientColor: Color3;
  31714. /**
  31715. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31716. * It should only be one of the following (if not the default embedded one):
  31717. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31718. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31719. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31720. * The material properties need to be setup according to the type of texture in use.
  31721. */
  31722. environmentBRDFTexture: BaseTexture;
  31723. /** @hidden */
  31724. protected _environmentTexture: Nullable<BaseTexture>;
  31725. /**
  31726. * Texture used in all pbr material as the reflection texture.
  31727. * As in the majority of the scene they are the same (exception for multi room and so on),
  31728. * this is easier to reference from here than from all the materials.
  31729. */
  31730. /**
  31731. * Texture used in all pbr material as the reflection texture.
  31732. * As in the majority of the scene they are the same (exception for multi room and so on),
  31733. * this is easier to set here than in all the materials.
  31734. */
  31735. environmentTexture: Nullable<BaseTexture>;
  31736. /** @hidden */
  31737. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31738. /**
  31739. * Default image processing configuration used either in the rendering
  31740. * Forward main pass or through the imageProcessingPostProcess if present.
  31741. * As in the majority of the scene they are the same (exception for multi camera),
  31742. * this is easier to reference from here than from all the materials and post process.
  31743. *
  31744. * No setter as we it is a shared configuration, you can set the values instead.
  31745. */
  31746. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31747. private _forceWireframe;
  31748. /**
  31749. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31750. */
  31751. forceWireframe: boolean;
  31752. private _forcePointsCloud;
  31753. /**
  31754. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31755. */
  31756. forcePointsCloud: boolean;
  31757. /**
  31758. * Gets or sets the active clipplane 1
  31759. */
  31760. clipPlane: Nullable<Plane>;
  31761. /**
  31762. * Gets or sets the active clipplane 2
  31763. */
  31764. clipPlane2: Nullable<Plane>;
  31765. /**
  31766. * Gets or sets the active clipplane 3
  31767. */
  31768. clipPlane3: Nullable<Plane>;
  31769. /**
  31770. * Gets or sets the active clipplane 4
  31771. */
  31772. clipPlane4: Nullable<Plane>;
  31773. /**
  31774. * Gets or sets a boolean indicating if animations are enabled
  31775. */
  31776. animationsEnabled: boolean;
  31777. private _animationPropertiesOverride;
  31778. /**
  31779. * Gets or sets the animation properties override
  31780. */
  31781. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31782. /**
  31783. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31784. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31785. */
  31786. useConstantAnimationDeltaTime: boolean;
  31787. /**
  31788. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31789. * Please note that it requires to run a ray cast through the scene on every frame
  31790. */
  31791. constantlyUpdateMeshUnderPointer: boolean;
  31792. /**
  31793. * Defines the HTML cursor to use when hovering over interactive elements
  31794. */
  31795. hoverCursor: string;
  31796. /**
  31797. * Defines the HTML default cursor to use (empty by default)
  31798. */
  31799. defaultCursor: string;
  31800. /**
  31801. * This is used to call preventDefault() on pointer down
  31802. * in order to block unwanted artifacts like system double clicks
  31803. */
  31804. preventDefaultOnPointerDown: boolean;
  31805. /**
  31806. * This is used to call preventDefault() on pointer up
  31807. * in order to block unwanted artifacts like system double clicks
  31808. */
  31809. preventDefaultOnPointerUp: boolean;
  31810. /**
  31811. * Gets or sets user defined metadata
  31812. */
  31813. metadata: any;
  31814. /**
  31815. * For internal use only. Please do not use.
  31816. */
  31817. reservedDataStore: any;
  31818. /**
  31819. * Gets the name of the plugin used to load this scene (null by default)
  31820. */
  31821. loadingPluginName: string;
  31822. /**
  31823. * Use this array to add regular expressions used to disable offline support for specific urls
  31824. */
  31825. disableOfflineSupportExceptionRules: RegExp[];
  31826. /**
  31827. * An event triggered when the scene is disposed.
  31828. */
  31829. onDisposeObservable: Observable<Scene>;
  31830. private _onDisposeObserver;
  31831. /** Sets a function to be executed when this scene is disposed. */
  31832. onDispose: () => void;
  31833. /**
  31834. * An event triggered before rendering the scene (right after animations and physics)
  31835. */
  31836. onBeforeRenderObservable: Observable<Scene>;
  31837. private _onBeforeRenderObserver;
  31838. /** Sets a function to be executed before rendering this scene */
  31839. beforeRender: Nullable<() => void>;
  31840. /**
  31841. * An event triggered after rendering the scene
  31842. */
  31843. onAfterRenderObservable: Observable<Scene>;
  31844. private _onAfterRenderObserver;
  31845. /** Sets a function to be executed after rendering this scene */
  31846. afterRender: Nullable<() => void>;
  31847. /**
  31848. * An event triggered before animating the scene
  31849. */
  31850. onBeforeAnimationsObservable: Observable<Scene>;
  31851. /**
  31852. * An event triggered after animations processing
  31853. */
  31854. onAfterAnimationsObservable: Observable<Scene>;
  31855. /**
  31856. * An event triggered before draw calls are ready to be sent
  31857. */
  31858. onBeforeDrawPhaseObservable: Observable<Scene>;
  31859. /**
  31860. * An event triggered after draw calls have been sent
  31861. */
  31862. onAfterDrawPhaseObservable: Observable<Scene>;
  31863. /**
  31864. * An event triggered when the scene is ready
  31865. */
  31866. onReadyObservable: Observable<Scene>;
  31867. /**
  31868. * An event triggered before rendering a camera
  31869. */
  31870. onBeforeCameraRenderObservable: Observable<Camera>;
  31871. private _onBeforeCameraRenderObserver;
  31872. /** Sets a function to be executed before rendering a camera*/
  31873. beforeCameraRender: () => void;
  31874. /**
  31875. * An event triggered after rendering a camera
  31876. */
  31877. onAfterCameraRenderObservable: Observable<Camera>;
  31878. private _onAfterCameraRenderObserver;
  31879. /** Sets a function to be executed after rendering a camera*/
  31880. afterCameraRender: () => void;
  31881. /**
  31882. * An event triggered when active meshes evaluation is about to start
  31883. */
  31884. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31885. /**
  31886. * An event triggered when active meshes evaluation is done
  31887. */
  31888. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31889. /**
  31890. * An event triggered when particles rendering is about to start
  31891. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31892. */
  31893. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31894. /**
  31895. * An event triggered when particles rendering is done
  31896. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31897. */
  31898. onAfterParticlesRenderingObservable: Observable<Scene>;
  31899. /**
  31900. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31901. */
  31902. onDataLoadedObservable: Observable<Scene>;
  31903. /**
  31904. * An event triggered when a camera is created
  31905. */
  31906. onNewCameraAddedObservable: Observable<Camera>;
  31907. /**
  31908. * An event triggered when a camera is removed
  31909. */
  31910. onCameraRemovedObservable: Observable<Camera>;
  31911. /**
  31912. * An event triggered when a light is created
  31913. */
  31914. onNewLightAddedObservable: Observable<Light>;
  31915. /**
  31916. * An event triggered when a light is removed
  31917. */
  31918. onLightRemovedObservable: Observable<Light>;
  31919. /**
  31920. * An event triggered when a geometry is created
  31921. */
  31922. onNewGeometryAddedObservable: Observable<Geometry>;
  31923. /**
  31924. * An event triggered when a geometry is removed
  31925. */
  31926. onGeometryRemovedObservable: Observable<Geometry>;
  31927. /**
  31928. * An event triggered when a transform node is created
  31929. */
  31930. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31931. /**
  31932. * An event triggered when a transform node is removed
  31933. */
  31934. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31935. /**
  31936. * An event triggered when a mesh is created
  31937. */
  31938. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31939. /**
  31940. * An event triggered when a mesh is removed
  31941. */
  31942. onMeshRemovedObservable: Observable<AbstractMesh>;
  31943. /**
  31944. * An event triggered when a skeleton is created
  31945. */
  31946. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31947. /**
  31948. * An event triggered when a skeleton is removed
  31949. */
  31950. onSkeletonRemovedObservable: Observable<Skeleton>;
  31951. /**
  31952. * An event triggered when a material is created
  31953. */
  31954. onNewMaterialAddedObservable: Observable<Material>;
  31955. /**
  31956. * An event triggered when a material is removed
  31957. */
  31958. onMaterialRemovedObservable: Observable<Material>;
  31959. /**
  31960. * An event triggered when a texture is created
  31961. */
  31962. onNewTextureAddedObservable: Observable<BaseTexture>;
  31963. /**
  31964. * An event triggered when a texture is removed
  31965. */
  31966. onTextureRemovedObservable: Observable<BaseTexture>;
  31967. /**
  31968. * An event triggered when render targets are about to be rendered
  31969. * Can happen multiple times per frame.
  31970. */
  31971. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31972. /**
  31973. * An event triggered when render targets were rendered.
  31974. * Can happen multiple times per frame.
  31975. */
  31976. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31977. /**
  31978. * An event triggered before calculating deterministic simulation step
  31979. */
  31980. onBeforeStepObservable: Observable<Scene>;
  31981. /**
  31982. * An event triggered after calculating deterministic simulation step
  31983. */
  31984. onAfterStepObservable: Observable<Scene>;
  31985. /**
  31986. * An event triggered when the activeCamera property is updated
  31987. */
  31988. onActiveCameraChanged: Observable<Scene>;
  31989. /**
  31990. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31991. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31992. * 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)
  31993. */
  31994. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31995. /**
  31996. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31997. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31998. * 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)
  31999. */
  32000. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32001. /**
  32002. * This Observable will when a mesh has been imported into the scene.
  32003. */
  32004. onMeshImportedObservable: Observable<AbstractMesh>;
  32005. /**
  32006. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32007. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32008. */
  32009. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32010. /** @hidden */
  32011. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32012. /**
  32013. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32014. */
  32015. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32016. /**
  32017. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32018. */
  32019. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32020. /**
  32021. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32022. */
  32023. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32024. private _onPointerMove;
  32025. private _onPointerDown;
  32026. private _onPointerUp;
  32027. /** Callback called when a pointer move is detected */
  32028. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32029. /** Callback called when a pointer down is detected */
  32030. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32031. /** Callback called when a pointer up is detected */
  32032. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32033. /** Callback called when a pointer pick is detected */
  32034. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32035. /**
  32036. * 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).
  32037. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32038. */
  32039. onPrePointerObservable: Observable<PointerInfoPre>;
  32040. /**
  32041. * Observable event triggered each time an input event is received from the rendering canvas
  32042. */
  32043. onPointerObservable: Observable<PointerInfo>;
  32044. /**
  32045. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32046. */
  32047. readonly unTranslatedPointer: Vector2;
  32048. /** The distance in pixel that you have to move to prevent some events */
  32049. static DragMovementThreshold: number;
  32050. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32051. static LongPressDelay: number;
  32052. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32053. static DoubleClickDelay: number;
  32054. /** If you need to check double click without raising a single click at first click, enable this flag */
  32055. static ExclusiveDoubleClickMode: boolean;
  32056. private _initClickEvent;
  32057. private _initActionManager;
  32058. private _delayedSimpleClick;
  32059. private _delayedSimpleClickTimeout;
  32060. private _previousDelayedSimpleClickTimeout;
  32061. private _meshPickProceed;
  32062. private _previousButtonPressed;
  32063. private _currentPickResult;
  32064. private _previousPickResult;
  32065. private _totalPointersPressed;
  32066. private _doubleClickOccured;
  32067. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32068. cameraToUseForPointers: Nullable<Camera>;
  32069. private _pointerX;
  32070. private _pointerY;
  32071. private _unTranslatedPointerX;
  32072. private _unTranslatedPointerY;
  32073. private _startingPointerPosition;
  32074. private _previousStartingPointerPosition;
  32075. private _startingPointerTime;
  32076. private _previousStartingPointerTime;
  32077. private _pointerCaptures;
  32078. private _timeAccumulator;
  32079. private _currentStepId;
  32080. private _currentInternalStep;
  32081. /** @hidden */
  32082. _mirroredCameraPosition: Nullable<Vector3>;
  32083. /**
  32084. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32085. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32086. */
  32087. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32088. /**
  32089. * Observable event triggered each time an keyboard event is received from the hosting window
  32090. */
  32091. onKeyboardObservable: Observable<KeyboardInfo>;
  32092. private _onKeyDown;
  32093. private _onKeyUp;
  32094. private _onCanvasFocusObserver;
  32095. private _onCanvasBlurObserver;
  32096. private _useRightHandedSystem;
  32097. /**
  32098. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32099. */
  32100. useRightHandedSystem: boolean;
  32101. /**
  32102. * Sets the step Id used by deterministic lock step
  32103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32104. * @param newStepId defines the step Id
  32105. */
  32106. setStepId(newStepId: number): void;
  32107. /**
  32108. * Gets the step Id used by deterministic lock step
  32109. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32110. * @returns the step Id
  32111. */
  32112. getStepId(): number;
  32113. /**
  32114. * Gets the internal step used by deterministic lock step
  32115. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32116. * @returns the internal step
  32117. */
  32118. getInternalStep(): number;
  32119. private _fogEnabled;
  32120. /**
  32121. * Gets or sets a boolean indicating if fog is enabled on this scene
  32122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32123. * (Default is true)
  32124. */
  32125. fogEnabled: boolean;
  32126. private _fogMode;
  32127. /**
  32128. * Gets or sets the fog mode to use
  32129. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32130. * | mode | value |
  32131. * | --- | --- |
  32132. * | FOGMODE_NONE | 0 |
  32133. * | FOGMODE_EXP | 1 |
  32134. * | FOGMODE_EXP2 | 2 |
  32135. * | FOGMODE_LINEAR | 3 |
  32136. */
  32137. fogMode: number;
  32138. /**
  32139. * Gets or sets the fog color to use
  32140. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32141. * (Default is Color3(0.2, 0.2, 0.3))
  32142. */
  32143. fogColor: Color3;
  32144. /**
  32145. * Gets or sets the fog density to use
  32146. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32147. * (Default is 0.1)
  32148. */
  32149. fogDensity: number;
  32150. /**
  32151. * Gets or sets the fog start distance to use
  32152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32153. * (Default is 0)
  32154. */
  32155. fogStart: number;
  32156. /**
  32157. * Gets or sets the fog end distance to use
  32158. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32159. * (Default is 1000)
  32160. */
  32161. fogEnd: number;
  32162. private _shadowsEnabled;
  32163. /**
  32164. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32165. */
  32166. shadowsEnabled: boolean;
  32167. private _lightsEnabled;
  32168. /**
  32169. * Gets or sets a boolean indicating if lights are enabled on this scene
  32170. */
  32171. lightsEnabled: boolean;
  32172. /** All of the active cameras added to this scene. */
  32173. activeCameras: Camera[];
  32174. /** @hidden */
  32175. _activeCamera: Nullable<Camera>;
  32176. /** Gets or sets the current active camera */
  32177. activeCamera: Nullable<Camera>;
  32178. private _defaultMaterial;
  32179. /** The default material used on meshes when no material is affected */
  32180. /** The default material used on meshes when no material is affected */
  32181. defaultMaterial: Material;
  32182. private _texturesEnabled;
  32183. /**
  32184. * Gets or sets a boolean indicating if textures are enabled on this scene
  32185. */
  32186. texturesEnabled: boolean;
  32187. /**
  32188. * Gets or sets a boolean indicating if particles are enabled on this scene
  32189. */
  32190. particlesEnabled: boolean;
  32191. /**
  32192. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32193. */
  32194. spritesEnabled: boolean;
  32195. private _skeletonsEnabled;
  32196. /**
  32197. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32198. */
  32199. skeletonsEnabled: boolean;
  32200. /**
  32201. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32202. */
  32203. lensFlaresEnabled: boolean;
  32204. /**
  32205. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32207. */
  32208. collisionsEnabled: boolean;
  32209. private _collisionCoordinator;
  32210. /** @hidden */
  32211. readonly collisionCoordinator: ICollisionCoordinator;
  32212. /**
  32213. * Defines the gravity applied to this scene (used only for collisions)
  32214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32215. */
  32216. gravity: Vector3;
  32217. /**
  32218. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32219. */
  32220. postProcessesEnabled: boolean;
  32221. /**
  32222. * The list of postprocesses added to the scene
  32223. */
  32224. postProcesses: PostProcess[];
  32225. /**
  32226. * Gets the current postprocess manager
  32227. */
  32228. postProcessManager: PostProcessManager;
  32229. /**
  32230. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32231. */
  32232. renderTargetsEnabled: boolean;
  32233. /**
  32234. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32235. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32236. */
  32237. dumpNextRenderTargets: boolean;
  32238. /**
  32239. * The list of user defined render targets added to the scene
  32240. */
  32241. customRenderTargets: RenderTargetTexture[];
  32242. /**
  32243. * Defines if texture loading must be delayed
  32244. * If true, textures will only be loaded when they need to be rendered
  32245. */
  32246. useDelayedTextureLoading: boolean;
  32247. /**
  32248. * Gets the list of meshes imported to the scene through SceneLoader
  32249. */
  32250. importedMeshesFiles: String[];
  32251. /**
  32252. * Gets or sets a boolean indicating if probes are enabled on this scene
  32253. */
  32254. probesEnabled: boolean;
  32255. /**
  32256. * Gets or sets the current offline provider to use to store scene data
  32257. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32258. */
  32259. offlineProvider: IOfflineProvider;
  32260. /**
  32261. * Gets or sets the action manager associated with the scene
  32262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32263. */
  32264. actionManager: AbstractActionManager;
  32265. private _meshesForIntersections;
  32266. /**
  32267. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32268. */
  32269. proceduralTexturesEnabled: boolean;
  32270. private _engine;
  32271. private _totalVertices;
  32272. /** @hidden */
  32273. _activeIndices: PerfCounter;
  32274. /** @hidden */
  32275. _activeParticles: PerfCounter;
  32276. /** @hidden */
  32277. _activeBones: PerfCounter;
  32278. private _animationRatio;
  32279. /** @hidden */
  32280. _animationTimeLast: number;
  32281. /** @hidden */
  32282. _animationTime: number;
  32283. /**
  32284. * Gets or sets a general scale for animation speed
  32285. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32286. */
  32287. animationTimeScale: number;
  32288. /** @hidden */
  32289. _cachedMaterial: Nullable<Material>;
  32290. /** @hidden */
  32291. _cachedEffect: Nullable<Effect>;
  32292. /** @hidden */
  32293. _cachedVisibility: Nullable<number>;
  32294. private _renderId;
  32295. private _frameId;
  32296. private _executeWhenReadyTimeoutId;
  32297. private _intermediateRendering;
  32298. private _viewUpdateFlag;
  32299. private _projectionUpdateFlag;
  32300. /** @hidden */
  32301. _toBeDisposed: Nullable<IDisposable>[];
  32302. private _activeRequests;
  32303. /** @hidden */
  32304. _pendingData: any[];
  32305. private _isDisposed;
  32306. /**
  32307. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32308. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32309. */
  32310. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32311. private _activeMeshes;
  32312. private _processedMaterials;
  32313. private _renderTargets;
  32314. /** @hidden */
  32315. _activeParticleSystems: SmartArray<IParticleSystem>;
  32316. private _activeSkeletons;
  32317. private _softwareSkinnedMeshes;
  32318. private _renderingManager;
  32319. /** @hidden */
  32320. _activeAnimatables: Animatable[];
  32321. private _transformMatrix;
  32322. private _sceneUbo;
  32323. /** @hidden */
  32324. _viewMatrix: Matrix;
  32325. private _projectionMatrix;
  32326. private _wheelEventName;
  32327. /** @hidden */
  32328. _forcedViewPosition: Nullable<Vector3>;
  32329. /** @hidden */
  32330. _frustumPlanes: Plane[];
  32331. /**
  32332. * Gets the list of frustum planes (built from the active camera)
  32333. */
  32334. readonly frustumPlanes: Plane[];
  32335. /**
  32336. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32337. * This is useful if there are more lights that the maximum simulteanous authorized
  32338. */
  32339. requireLightSorting: boolean;
  32340. /** @hidden */
  32341. readonly useMaterialMeshMap: boolean;
  32342. /** @hidden */
  32343. readonly useClonedMeshhMap: boolean;
  32344. private _pointerOverMesh;
  32345. private _pickedDownMesh;
  32346. private _pickedUpMesh;
  32347. private _externalData;
  32348. private _uid;
  32349. /**
  32350. * @hidden
  32351. * Backing store of defined scene components.
  32352. */
  32353. _components: ISceneComponent[];
  32354. /**
  32355. * @hidden
  32356. * Backing store of defined scene components.
  32357. */
  32358. _serializableComponents: ISceneSerializableComponent[];
  32359. /**
  32360. * List of components to register on the next registration step.
  32361. */
  32362. private _transientComponents;
  32363. /**
  32364. * Registers the transient components if needed.
  32365. */
  32366. private _registerTransientComponents;
  32367. /**
  32368. * @hidden
  32369. * Add a component to the scene.
  32370. * Note that the ccomponent could be registered on th next frame if this is called after
  32371. * the register component stage.
  32372. * @param component Defines the component to add to the scene
  32373. */
  32374. _addComponent(component: ISceneComponent): void;
  32375. /**
  32376. * @hidden
  32377. * Gets a component from the scene.
  32378. * @param name defines the name of the component to retrieve
  32379. * @returns the component or null if not present
  32380. */
  32381. _getComponent(name: string): Nullable<ISceneComponent>;
  32382. /**
  32383. * @hidden
  32384. * Defines the actions happening before camera updates.
  32385. */
  32386. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32387. /**
  32388. * @hidden
  32389. * Defines the actions happening before clear the canvas.
  32390. */
  32391. _beforeClearStage: Stage<SimpleStageAction>;
  32392. /**
  32393. * @hidden
  32394. * Defines the actions when collecting render targets for the frame.
  32395. */
  32396. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32397. /**
  32398. * @hidden
  32399. * Defines the actions happening for one camera in the frame.
  32400. */
  32401. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32402. /**
  32403. * @hidden
  32404. * Defines the actions happening during the per mesh ready checks.
  32405. */
  32406. _isReadyForMeshStage: Stage<MeshStageAction>;
  32407. /**
  32408. * @hidden
  32409. * Defines the actions happening before evaluate active mesh checks.
  32410. */
  32411. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32412. /**
  32413. * @hidden
  32414. * Defines the actions happening during the evaluate sub mesh checks.
  32415. */
  32416. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32417. /**
  32418. * @hidden
  32419. * Defines the actions happening during the active mesh stage.
  32420. */
  32421. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32422. /**
  32423. * @hidden
  32424. * Defines the actions happening during the per camera render target step.
  32425. */
  32426. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32427. /**
  32428. * @hidden
  32429. * Defines the actions happening just before the active camera is drawing.
  32430. */
  32431. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32432. /**
  32433. * @hidden
  32434. * Defines the actions happening just before a render target is drawing.
  32435. */
  32436. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32437. /**
  32438. * @hidden
  32439. * Defines the actions happening just before a rendering group is drawing.
  32440. */
  32441. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32442. /**
  32443. * @hidden
  32444. * Defines the actions happening just before a mesh is drawing.
  32445. */
  32446. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32447. /**
  32448. * @hidden
  32449. * Defines the actions happening just after a mesh has been drawn.
  32450. */
  32451. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32452. /**
  32453. * @hidden
  32454. * Defines the actions happening just after a rendering group has been drawn.
  32455. */
  32456. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32457. /**
  32458. * @hidden
  32459. * Defines the actions happening just after the active camera has been drawn.
  32460. */
  32461. _afterCameraDrawStage: Stage<CameraStageAction>;
  32462. /**
  32463. * @hidden
  32464. * Defines the actions happening just after a render target has been drawn.
  32465. */
  32466. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32467. /**
  32468. * @hidden
  32469. * Defines the actions happening just after rendering all cameras and computing intersections.
  32470. */
  32471. _afterRenderStage: Stage<SimpleStageAction>;
  32472. /**
  32473. * @hidden
  32474. * Defines the actions happening when a pointer move event happens.
  32475. */
  32476. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32477. /**
  32478. * @hidden
  32479. * Defines the actions happening when a pointer down event happens.
  32480. */
  32481. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32482. /**
  32483. * @hidden
  32484. * Defines the actions happening when a pointer up event happens.
  32485. */
  32486. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32487. /**
  32488. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32489. */
  32490. private geometriesByUniqueId;
  32491. /**
  32492. * Creates a new Scene
  32493. * @param engine defines the engine to use to render this scene
  32494. * @param options defines the scene options
  32495. */
  32496. constructor(engine: Engine, options?: SceneOptions);
  32497. /**
  32498. * Gets a string idenfifying the name of the class
  32499. * @returns "Scene" string
  32500. */
  32501. getClassName(): string;
  32502. private _defaultMeshCandidates;
  32503. /**
  32504. * @hidden
  32505. */
  32506. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32507. private _defaultSubMeshCandidates;
  32508. /**
  32509. * @hidden
  32510. */
  32511. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32512. /**
  32513. * Sets the default candidate providers for the scene.
  32514. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32515. * and getCollidingSubMeshCandidates to their default function
  32516. */
  32517. setDefaultCandidateProviders(): void;
  32518. /**
  32519. * Gets the mesh that is currently under the pointer
  32520. */
  32521. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32522. /**
  32523. * Gets or sets the current on-screen X position of the pointer
  32524. */
  32525. pointerX: number;
  32526. /**
  32527. * Gets or sets the current on-screen Y position of the pointer
  32528. */
  32529. pointerY: number;
  32530. /**
  32531. * Gets the cached material (ie. the latest rendered one)
  32532. * @returns the cached material
  32533. */
  32534. getCachedMaterial(): Nullable<Material>;
  32535. /**
  32536. * Gets the cached effect (ie. the latest rendered one)
  32537. * @returns the cached effect
  32538. */
  32539. getCachedEffect(): Nullable<Effect>;
  32540. /**
  32541. * Gets the cached visibility state (ie. the latest rendered one)
  32542. * @returns the cached visibility state
  32543. */
  32544. getCachedVisibility(): Nullable<number>;
  32545. /**
  32546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32547. * @param material defines the current material
  32548. * @param effect defines the current effect
  32549. * @param visibility defines the current visibility state
  32550. * @returns true if one parameter is not cached
  32551. */
  32552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32553. /**
  32554. * Gets the engine associated with the scene
  32555. * @returns an Engine
  32556. */
  32557. getEngine(): Engine;
  32558. /**
  32559. * Gets the total number of vertices rendered per frame
  32560. * @returns the total number of vertices rendered per frame
  32561. */
  32562. getTotalVertices(): number;
  32563. /**
  32564. * Gets the performance counter for total vertices
  32565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32566. */
  32567. readonly totalVerticesPerfCounter: PerfCounter;
  32568. /**
  32569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32570. * @returns the total number of active indices rendered per frame
  32571. */
  32572. getActiveIndices(): number;
  32573. /**
  32574. * Gets the performance counter for active indices
  32575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32576. */
  32577. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32578. /**
  32579. * Gets the total number of active particles rendered per frame
  32580. * @returns the total number of active particles rendered per frame
  32581. */
  32582. getActiveParticles(): number;
  32583. /**
  32584. * Gets the performance counter for active particles
  32585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32586. */
  32587. readonly activeParticlesPerfCounter: PerfCounter;
  32588. /**
  32589. * Gets the total number of active bones rendered per frame
  32590. * @returns the total number of active bones rendered per frame
  32591. */
  32592. getActiveBones(): number;
  32593. /**
  32594. * Gets the performance counter for active bones
  32595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32596. */
  32597. readonly activeBonesPerfCounter: PerfCounter;
  32598. /**
  32599. * Gets the array of active meshes
  32600. * @returns an array of AbstractMesh
  32601. */
  32602. getActiveMeshes(): SmartArray<AbstractMesh>;
  32603. /**
  32604. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32605. * @returns a number
  32606. */
  32607. getAnimationRatio(): number;
  32608. /**
  32609. * Gets an unique Id for the current render phase
  32610. * @returns a number
  32611. */
  32612. getRenderId(): number;
  32613. /**
  32614. * Gets an unique Id for the current frame
  32615. * @returns a number
  32616. */
  32617. getFrameId(): number;
  32618. /** Call this function if you want to manually increment the render Id*/
  32619. incrementRenderId(): void;
  32620. private _updatePointerPosition;
  32621. private _createUbo;
  32622. private _setRayOnPointerInfo;
  32623. /**
  32624. * Use this method to simulate a pointer move on a mesh
  32625. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32626. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32627. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32628. * @returns the current scene
  32629. */
  32630. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32631. private _processPointerMove;
  32632. private _checkPrePointerObservable;
  32633. /**
  32634. * Use this method to simulate a pointer down on a mesh
  32635. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32636. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32637. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32638. * @returns the current scene
  32639. */
  32640. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32641. private _processPointerDown;
  32642. /**
  32643. * Use this method to simulate a pointer up on a mesh
  32644. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32645. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32646. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32647. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32648. * @returns the current scene
  32649. */
  32650. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32651. private _processPointerUp;
  32652. /**
  32653. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32654. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32655. * @returns true if the pointer was captured
  32656. */
  32657. isPointerCaptured(pointerId?: number): boolean;
  32658. /** @hidden */
  32659. _isPointerSwiping(): boolean;
  32660. /**
  32661. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32662. * @param attachUp defines if you want to attach events to pointerup
  32663. * @param attachDown defines if you want to attach events to pointerdown
  32664. * @param attachMove defines if you want to attach events to pointermove
  32665. */
  32666. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32667. /** Detaches all event handlers*/
  32668. detachControl(): void;
  32669. /**
  32670. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32671. * Delay loaded resources are not taking in account
  32672. * @return true if all required resources are ready
  32673. */
  32674. isReady(): boolean;
  32675. /** Resets all cached information relative to material (including effect and visibility) */
  32676. resetCachedMaterial(): void;
  32677. /**
  32678. * Registers a function to be called before every frame render
  32679. * @param func defines the function to register
  32680. */
  32681. registerBeforeRender(func: () => void): void;
  32682. /**
  32683. * Unregisters a function called before every frame render
  32684. * @param func defines the function to unregister
  32685. */
  32686. unregisterBeforeRender(func: () => void): void;
  32687. /**
  32688. * Registers a function to be called after every frame render
  32689. * @param func defines the function to register
  32690. */
  32691. registerAfterRender(func: () => void): void;
  32692. /**
  32693. * Unregisters a function called after every frame render
  32694. * @param func defines the function to unregister
  32695. */
  32696. unregisterAfterRender(func: () => void): void;
  32697. private _executeOnceBeforeRender;
  32698. /**
  32699. * The provided function will run before render once and will be disposed afterwards.
  32700. * A timeout delay can be provided so that the function will be executed in N ms.
  32701. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32702. * @param func The function to be executed.
  32703. * @param timeout optional delay in ms
  32704. */
  32705. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32706. /** @hidden */
  32707. _addPendingData(data: any): void;
  32708. /** @hidden */
  32709. _removePendingData(data: any): void;
  32710. /**
  32711. * Returns the number of items waiting to be loaded
  32712. * @returns the number of items waiting to be loaded
  32713. */
  32714. getWaitingItemsCount(): number;
  32715. /**
  32716. * Returns a boolean indicating if the scene is still loading data
  32717. */
  32718. readonly isLoading: boolean;
  32719. /**
  32720. * Registers a function to be executed when the scene is ready
  32721. * @param {Function} func - the function to be executed
  32722. */
  32723. executeWhenReady(func: () => void): void;
  32724. /**
  32725. * Returns a promise that resolves when the scene is ready
  32726. * @returns A promise that resolves when the scene is ready
  32727. */
  32728. whenReadyAsync(): Promise<void>;
  32729. /** @hidden */
  32730. _checkIsReady(): void;
  32731. /**
  32732. * Gets all animatable attached to the scene
  32733. */
  32734. readonly animatables: Animatable[];
  32735. /**
  32736. * Resets the last animation time frame.
  32737. * Useful to override when animations start running when loading a scene for the first time.
  32738. */
  32739. resetLastAnimationTimeFrame(): void;
  32740. /**
  32741. * Gets the current view matrix
  32742. * @returns a Matrix
  32743. */
  32744. getViewMatrix(): Matrix;
  32745. /**
  32746. * Gets the current projection matrix
  32747. * @returns a Matrix
  32748. */
  32749. getProjectionMatrix(): Matrix;
  32750. /**
  32751. * Gets the current transform matrix
  32752. * @returns a Matrix made of View * Projection
  32753. */
  32754. getTransformMatrix(): Matrix;
  32755. /**
  32756. * Sets the current transform matrix
  32757. * @param viewL defines the View matrix to use
  32758. * @param projectionL defines the Projection matrix to use
  32759. * @param viewR defines the right View matrix to use (if provided)
  32760. * @param projectionR defines the right Projection matrix to use (if provided)
  32761. */
  32762. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32763. /**
  32764. * Gets the uniform buffer used to store scene data
  32765. * @returns a UniformBuffer
  32766. */
  32767. getSceneUniformBuffer(): UniformBuffer;
  32768. /**
  32769. * Gets an unique (relatively to the current scene) Id
  32770. * @returns an unique number for the scene
  32771. */
  32772. getUniqueId(): number;
  32773. /**
  32774. * Add a mesh to the list of scene's meshes
  32775. * @param newMesh defines the mesh to add
  32776. * @param recursive if all child meshes should also be added to the scene
  32777. */
  32778. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32779. /**
  32780. * Remove a mesh for the list of scene's meshes
  32781. * @param toRemove defines the mesh to remove
  32782. * @param recursive if all child meshes should also be removed from the scene
  32783. * @returns the index where the mesh was in the mesh list
  32784. */
  32785. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32786. /**
  32787. * Add a transform node to the list of scene's transform nodes
  32788. * @param newTransformNode defines the transform node to add
  32789. */
  32790. addTransformNode(newTransformNode: TransformNode): void;
  32791. /**
  32792. * Remove a transform node for the list of scene's transform nodes
  32793. * @param toRemove defines the transform node to remove
  32794. * @returns the index where the transform node was in the transform node list
  32795. */
  32796. removeTransformNode(toRemove: TransformNode): number;
  32797. /**
  32798. * Remove a skeleton for the list of scene's skeletons
  32799. * @param toRemove defines the skeleton to remove
  32800. * @returns the index where the skeleton was in the skeleton list
  32801. */
  32802. removeSkeleton(toRemove: Skeleton): number;
  32803. /**
  32804. * Remove a morph target for the list of scene's morph targets
  32805. * @param toRemove defines the morph target to remove
  32806. * @returns the index where the morph target was in the morph target list
  32807. */
  32808. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32809. /**
  32810. * Remove a light for the list of scene's lights
  32811. * @param toRemove defines the light to remove
  32812. * @returns the index where the light was in the light list
  32813. */
  32814. removeLight(toRemove: Light): number;
  32815. /**
  32816. * Remove a camera for the list of scene's cameras
  32817. * @param toRemove defines the camera to remove
  32818. * @returns the index where the camera was in the camera list
  32819. */
  32820. removeCamera(toRemove: Camera): number;
  32821. /**
  32822. * Remove a particle system for the list of scene's particle systems
  32823. * @param toRemove defines the particle system to remove
  32824. * @returns the index where the particle system was in the particle system list
  32825. */
  32826. removeParticleSystem(toRemove: IParticleSystem): number;
  32827. /**
  32828. * Remove a animation for the list of scene's animations
  32829. * @param toRemove defines the animation to remove
  32830. * @returns the index where the animation was in the animation list
  32831. */
  32832. removeAnimation(toRemove: Animation): number;
  32833. /**
  32834. * Removes the given animation group from this scene.
  32835. * @param toRemove The animation group to remove
  32836. * @returns The index of the removed animation group
  32837. */
  32838. removeAnimationGroup(toRemove: AnimationGroup): number;
  32839. /**
  32840. * Removes the given multi-material from this scene.
  32841. * @param toRemove The multi-material to remove
  32842. * @returns The index of the removed multi-material
  32843. */
  32844. removeMultiMaterial(toRemove: MultiMaterial): number;
  32845. /**
  32846. * Removes the given material from this scene.
  32847. * @param toRemove The material to remove
  32848. * @returns The index of the removed material
  32849. */
  32850. removeMaterial(toRemove: Material): number;
  32851. /**
  32852. * Removes the given action manager from this scene.
  32853. * @param toRemove The action manager to remove
  32854. * @returns The index of the removed action manager
  32855. */
  32856. removeActionManager(toRemove: AbstractActionManager): number;
  32857. /**
  32858. * Removes the given texture from this scene.
  32859. * @param toRemove The texture to remove
  32860. * @returns The index of the removed texture
  32861. */
  32862. removeTexture(toRemove: BaseTexture): number;
  32863. /**
  32864. * Adds the given light to this scene
  32865. * @param newLight The light to add
  32866. */
  32867. addLight(newLight: Light): void;
  32868. /**
  32869. * Sorts the list list based on light priorities
  32870. */
  32871. sortLightsByPriority(): void;
  32872. /**
  32873. * Adds the given camera to this scene
  32874. * @param newCamera The camera to add
  32875. */
  32876. addCamera(newCamera: Camera): void;
  32877. /**
  32878. * Adds the given skeleton to this scene
  32879. * @param newSkeleton The skeleton to add
  32880. */
  32881. addSkeleton(newSkeleton: Skeleton): void;
  32882. /**
  32883. * Adds the given particle system to this scene
  32884. * @param newParticleSystem The particle system to add
  32885. */
  32886. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32887. /**
  32888. * Adds the given animation to this scene
  32889. * @param newAnimation The animation to add
  32890. */
  32891. addAnimation(newAnimation: Animation): void;
  32892. /**
  32893. * Adds the given animation group to this scene.
  32894. * @param newAnimationGroup The animation group to add
  32895. */
  32896. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32897. /**
  32898. * Adds the given multi-material to this scene
  32899. * @param newMultiMaterial The multi-material to add
  32900. */
  32901. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32902. /**
  32903. * Adds the given material to this scene
  32904. * @param newMaterial The material to add
  32905. */
  32906. addMaterial(newMaterial: Material): void;
  32907. /**
  32908. * Adds the given morph target to this scene
  32909. * @param newMorphTargetManager The morph target to add
  32910. */
  32911. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32912. /**
  32913. * Adds the given geometry to this scene
  32914. * @param newGeometry The geometry to add
  32915. */
  32916. addGeometry(newGeometry: Geometry): void;
  32917. /**
  32918. * Adds the given action manager to this scene
  32919. * @param newActionManager The action manager to add
  32920. */
  32921. addActionManager(newActionManager: AbstractActionManager): void;
  32922. /**
  32923. * Adds the given texture to this scene.
  32924. * @param newTexture The texture to add
  32925. */
  32926. addTexture(newTexture: BaseTexture): void;
  32927. /**
  32928. * Switch active camera
  32929. * @param newCamera defines the new active camera
  32930. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32931. */
  32932. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32933. /**
  32934. * sets the active camera of the scene using its ID
  32935. * @param id defines the camera's ID
  32936. * @return the new active camera or null if none found.
  32937. */
  32938. setActiveCameraByID(id: string): Nullable<Camera>;
  32939. /**
  32940. * sets the active camera of the scene using its name
  32941. * @param name defines the camera's name
  32942. * @returns the new active camera or null if none found.
  32943. */
  32944. setActiveCameraByName(name: string): Nullable<Camera>;
  32945. /**
  32946. * get an animation group using its name
  32947. * @param name defines the material's name
  32948. * @return the animation group or null if none found.
  32949. */
  32950. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32951. /**
  32952. * Get a material using its unique id
  32953. * @param uniqueId defines the material's unique id
  32954. * @return the material or null if none found.
  32955. */
  32956. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32957. /**
  32958. * get a material using its id
  32959. * @param id defines the material's ID
  32960. * @return the material or null if none found.
  32961. */
  32962. getMaterialByID(id: string): Nullable<Material>;
  32963. /**
  32964. * Gets a material using its name
  32965. * @param name defines the material's name
  32966. * @return the material or null if none found.
  32967. */
  32968. getMaterialByName(name: string): Nullable<Material>;
  32969. /**
  32970. * Gets a camera using its id
  32971. * @param id defines the id to look for
  32972. * @returns the camera or null if not found
  32973. */
  32974. getCameraByID(id: string): Nullable<Camera>;
  32975. /**
  32976. * Gets a camera using its unique id
  32977. * @param uniqueId defines the unique id to look for
  32978. * @returns the camera or null if not found
  32979. */
  32980. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32981. /**
  32982. * Gets a camera using its name
  32983. * @param name defines the camera's name
  32984. * @return the camera or null if none found.
  32985. */
  32986. getCameraByName(name: string): Nullable<Camera>;
  32987. /**
  32988. * Gets a bone using its id
  32989. * @param id defines the bone's id
  32990. * @return the bone or null if not found
  32991. */
  32992. getBoneByID(id: string): Nullable<Bone>;
  32993. /**
  32994. * Gets a bone using its id
  32995. * @param name defines the bone's name
  32996. * @return the bone or null if not found
  32997. */
  32998. getBoneByName(name: string): Nullable<Bone>;
  32999. /**
  33000. * Gets a light node using its name
  33001. * @param name defines the the light's name
  33002. * @return the light or null if none found.
  33003. */
  33004. getLightByName(name: string): Nullable<Light>;
  33005. /**
  33006. * Gets a light node using its id
  33007. * @param id defines the light's id
  33008. * @return the light or null if none found.
  33009. */
  33010. getLightByID(id: string): Nullable<Light>;
  33011. /**
  33012. * Gets a light node using its scene-generated unique ID
  33013. * @param uniqueId defines the light's unique id
  33014. * @return the light or null if none found.
  33015. */
  33016. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33017. /**
  33018. * Gets a particle system by id
  33019. * @param id defines the particle system id
  33020. * @return the corresponding system or null if none found
  33021. */
  33022. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33023. /**
  33024. * Gets a geometry using its ID
  33025. * @param id defines the geometry's id
  33026. * @return the geometry or null if none found.
  33027. */
  33028. getGeometryByID(id: string): Nullable<Geometry>;
  33029. private _getGeometryByUniqueID;
  33030. /**
  33031. * Add a new geometry to this scene
  33032. * @param geometry defines the geometry to be added to the scene.
  33033. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33034. * @return a boolean defining if the geometry was added or not
  33035. */
  33036. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33037. /**
  33038. * Removes an existing geometry
  33039. * @param geometry defines the geometry to be removed from the scene
  33040. * @return a boolean defining if the geometry was removed or not
  33041. */
  33042. removeGeometry(geometry: Geometry): boolean;
  33043. /**
  33044. * Gets the list of geometries attached to the scene
  33045. * @returns an array of Geometry
  33046. */
  33047. getGeometries(): Geometry[];
  33048. /**
  33049. * Gets the first added mesh found of a given ID
  33050. * @param id defines the id to search for
  33051. * @return the mesh found or null if not found at all
  33052. */
  33053. getMeshByID(id: string): Nullable<AbstractMesh>;
  33054. /**
  33055. * Gets a list of meshes using their id
  33056. * @param id defines the id to search for
  33057. * @returns a list of meshes
  33058. */
  33059. getMeshesByID(id: string): Array<AbstractMesh>;
  33060. /**
  33061. * Gets the first added transform node found of a given ID
  33062. * @param id defines the id to search for
  33063. * @return the found transform node or null if not found at all.
  33064. */
  33065. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33066. /**
  33067. * Gets a transform node with its auto-generated unique id
  33068. * @param uniqueId efines the unique id to search for
  33069. * @return the found transform node or null if not found at all.
  33070. */
  33071. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33072. /**
  33073. * Gets a list of transform nodes using their id
  33074. * @param id defines the id to search for
  33075. * @returns a list of transform nodes
  33076. */
  33077. getTransformNodesByID(id: string): Array<TransformNode>;
  33078. /**
  33079. * Gets a mesh with its auto-generated unique id
  33080. * @param uniqueId defines the unique id to search for
  33081. * @return the found mesh or null if not found at all.
  33082. */
  33083. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33084. /**
  33085. * Gets a the last added mesh using a given id
  33086. * @param id defines the id to search for
  33087. * @return the found mesh or null if not found at all.
  33088. */
  33089. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33090. /**
  33091. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33092. * @param id defines the id to search for
  33093. * @return the found node or null if not found at all
  33094. */
  33095. getLastEntryByID(id: string): Nullable<Node>;
  33096. /**
  33097. * Gets a node (Mesh, Camera, Light) using a given id
  33098. * @param id defines the id to search for
  33099. * @return the found node or null if not found at all
  33100. */
  33101. getNodeByID(id: string): Nullable<Node>;
  33102. /**
  33103. * Gets a node (Mesh, Camera, Light) using a given name
  33104. * @param name defines the name to search for
  33105. * @return the found node or null if not found at all.
  33106. */
  33107. getNodeByName(name: string): Nullable<Node>;
  33108. /**
  33109. * Gets a mesh using a given name
  33110. * @param name defines the name to search for
  33111. * @return the found mesh or null if not found at all.
  33112. */
  33113. getMeshByName(name: string): Nullable<AbstractMesh>;
  33114. /**
  33115. * Gets a transform node using a given name
  33116. * @param name defines the name to search for
  33117. * @return the found transform node or null if not found at all.
  33118. */
  33119. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33120. /**
  33121. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33122. * @param id defines the id to search for
  33123. * @return the found skeleton or null if not found at all.
  33124. */
  33125. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33126. /**
  33127. * Gets a skeleton using a given auto generated unique id
  33128. * @param uniqueId defines the unique id to search for
  33129. * @return the found skeleton or null if not found at all.
  33130. */
  33131. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33132. /**
  33133. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33134. * @param id defines the id to search for
  33135. * @return the found skeleton or null if not found at all.
  33136. */
  33137. getSkeletonById(id: string): Nullable<Skeleton>;
  33138. /**
  33139. * Gets a skeleton using a given name
  33140. * @param name defines the name to search for
  33141. * @return the found skeleton or null if not found at all.
  33142. */
  33143. getSkeletonByName(name: string): Nullable<Skeleton>;
  33144. /**
  33145. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33146. * @param id defines the id to search for
  33147. * @return the found morph target manager or null if not found at all.
  33148. */
  33149. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33150. /**
  33151. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33152. * @param id defines the id to search for
  33153. * @return the found morph target or null if not found at all.
  33154. */
  33155. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33156. /**
  33157. * Gets a boolean indicating if the given mesh is active
  33158. * @param mesh defines the mesh to look for
  33159. * @returns true if the mesh is in the active list
  33160. */
  33161. isActiveMesh(mesh: AbstractMesh): boolean;
  33162. /**
  33163. * Return a unique id as a string which can serve as an identifier for the scene
  33164. */
  33165. readonly uid: string;
  33166. /**
  33167. * Add an externaly attached data from its key.
  33168. * This method call will fail and return false, if such key already exists.
  33169. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33170. * @param key the unique key that identifies the data
  33171. * @param data the data object to associate to the key for this Engine instance
  33172. * @return true if no such key were already present and the data was added successfully, false otherwise
  33173. */
  33174. addExternalData<T>(key: string, data: T): boolean;
  33175. /**
  33176. * Get an externaly attached data from its key
  33177. * @param key the unique key that identifies the data
  33178. * @return the associated data, if present (can be null), or undefined if not present
  33179. */
  33180. getExternalData<T>(key: string): Nullable<T>;
  33181. /**
  33182. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33183. * @param key the unique key that identifies the data
  33184. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33185. * @return the associated data, can be null if the factory returned null.
  33186. */
  33187. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33188. /**
  33189. * Remove an externaly attached data from the Engine instance
  33190. * @param key the unique key that identifies the data
  33191. * @return true if the data was successfully removed, false if it doesn't exist
  33192. */
  33193. removeExternalData(key: string): boolean;
  33194. private _evaluateSubMesh;
  33195. /**
  33196. * Clear the processed materials smart array preventing retention point in material dispose.
  33197. */
  33198. freeProcessedMaterials(): void;
  33199. private _preventFreeActiveMeshesAndRenderingGroups;
  33200. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33201. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33202. * when disposing several meshes in a row or a hierarchy of meshes.
  33203. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33204. */
  33205. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33206. /**
  33207. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33208. */
  33209. freeActiveMeshes(): void;
  33210. /**
  33211. * Clear the info related to rendering groups preventing retention points during dispose.
  33212. */
  33213. freeRenderingGroups(): void;
  33214. /** @hidden */
  33215. _isInIntermediateRendering(): boolean;
  33216. /**
  33217. * Lambda returning the list of potentially active meshes.
  33218. */
  33219. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33220. /**
  33221. * Lambda returning the list of potentially active sub meshes.
  33222. */
  33223. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33224. /**
  33225. * Lambda returning the list of potentially intersecting sub meshes.
  33226. */
  33227. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33228. /**
  33229. * Lambda returning the list of potentially colliding sub meshes.
  33230. */
  33231. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33232. private _activeMeshesFrozen;
  33233. /**
  33234. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33235. * @returns the current scene
  33236. */
  33237. freezeActiveMeshes(): Scene;
  33238. /**
  33239. * Use this function to restart evaluating active meshes on every frame
  33240. * @returns the current scene
  33241. */
  33242. unfreezeActiveMeshes(): Scene;
  33243. private _evaluateActiveMeshes;
  33244. private _activeMesh;
  33245. /**
  33246. * Update the transform matrix to update from the current active camera
  33247. * @param force defines a boolean used to force the update even if cache is up to date
  33248. */
  33249. updateTransformMatrix(force?: boolean): void;
  33250. private _bindFrameBuffer;
  33251. /** @hidden */
  33252. _allowPostProcessClearColor: boolean;
  33253. /** @hidden */
  33254. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33255. private _processSubCameras;
  33256. private _checkIntersections;
  33257. /** @hidden */
  33258. _advancePhysicsEngineStep(step: number): void;
  33259. /**
  33260. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33261. */
  33262. getDeterministicFrameTime: () => number;
  33263. /** @hidden */
  33264. _animate(): void;
  33265. /** Execute all animations (for a frame) */
  33266. animate(): void;
  33267. /**
  33268. * Render the scene
  33269. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33270. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33271. */
  33272. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33273. /**
  33274. * Freeze all materials
  33275. * A frozen material will not be updatable but should be faster to render
  33276. */
  33277. freezeMaterials(): void;
  33278. /**
  33279. * Unfreeze all materials
  33280. * A frozen material will not be updatable but should be faster to render
  33281. */
  33282. unfreezeMaterials(): void;
  33283. /**
  33284. * Releases all held ressources
  33285. */
  33286. dispose(): void;
  33287. /**
  33288. * Gets if the scene is already disposed
  33289. */
  33290. readonly isDisposed: boolean;
  33291. /**
  33292. * Call this function to reduce memory footprint of the scene.
  33293. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33294. */
  33295. clearCachedVertexData(): void;
  33296. /**
  33297. * This function will remove the local cached buffer data from texture.
  33298. * It will save memory but will prevent the texture from being rebuilt
  33299. */
  33300. cleanCachedTextureBuffer(): void;
  33301. /**
  33302. * Get the world extend vectors with an optional filter
  33303. *
  33304. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33305. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33306. */
  33307. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33308. min: Vector3;
  33309. max: Vector3;
  33310. };
  33311. /**
  33312. * Creates a ray that can be used to pick in the scene
  33313. * @param x defines the x coordinate of the origin (on-screen)
  33314. * @param y defines the y coordinate of the origin (on-screen)
  33315. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33316. * @param camera defines the camera to use for the picking
  33317. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33318. * @returns a Ray
  33319. */
  33320. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33321. /**
  33322. * Creates a ray that can be used to pick in the scene
  33323. * @param x defines the x coordinate of the origin (on-screen)
  33324. * @param y defines the y coordinate of the origin (on-screen)
  33325. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33326. * @param result defines the ray where to store the picking ray
  33327. * @param camera defines the camera to use for the picking
  33328. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33329. * @returns the current scene
  33330. */
  33331. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33332. /**
  33333. * Creates a ray that can be used to pick in the scene
  33334. * @param x defines the x coordinate of the origin (on-screen)
  33335. * @param y defines the y coordinate of the origin (on-screen)
  33336. * @param camera defines the camera to use for the picking
  33337. * @returns a Ray
  33338. */
  33339. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33340. /**
  33341. * Creates a ray that can be used to pick in the scene
  33342. * @param x defines the x coordinate of the origin (on-screen)
  33343. * @param y defines the y coordinate of the origin (on-screen)
  33344. * @param result defines the ray where to store the picking ray
  33345. * @param camera defines the camera to use for the picking
  33346. * @returns the current scene
  33347. */
  33348. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33349. /** Launch a ray to try to pick a mesh in the scene
  33350. * @param x position on screen
  33351. * @param y position on screen
  33352. * @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
  33353. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33354. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33355. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33356. * @returns a PickingInfo
  33357. */
  33358. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33359. /** Use the given ray to pick a mesh in the scene
  33360. * @param ray The ray to use to pick meshes
  33361. * @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
  33362. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33363. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33364. * @returns a PickingInfo
  33365. */
  33366. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33367. /**
  33368. * Launch a ray to try to pick a mesh in the scene
  33369. * @param x X position on screen
  33370. * @param y Y position on screen
  33371. * @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
  33372. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33374. * @returns an array of PickingInfo
  33375. */
  33376. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33377. /**
  33378. * Launch a ray to try to pick a mesh in the scene
  33379. * @param ray Ray to use
  33380. * @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
  33381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33382. * @returns an array of PickingInfo
  33383. */
  33384. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33385. /**
  33386. * Force the value of meshUnderPointer
  33387. * @param mesh defines the mesh to use
  33388. */
  33389. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33390. /**
  33391. * Gets the mesh under the pointer
  33392. * @returns a Mesh or null if no mesh is under the pointer
  33393. */
  33394. getPointerOverMesh(): Nullable<AbstractMesh>;
  33395. /** @hidden */
  33396. _rebuildGeometries(): void;
  33397. /** @hidden */
  33398. _rebuildTextures(): void;
  33399. private _getByTags;
  33400. /**
  33401. * Get a list of meshes by tags
  33402. * @param tagsQuery defines the tags query to use
  33403. * @param forEach defines a predicate used to filter results
  33404. * @returns an array of Mesh
  33405. */
  33406. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33407. /**
  33408. * Get a list of cameras by tags
  33409. * @param tagsQuery defines the tags query to use
  33410. * @param forEach defines a predicate used to filter results
  33411. * @returns an array of Camera
  33412. */
  33413. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33414. /**
  33415. * Get a list of lights by tags
  33416. * @param tagsQuery defines the tags query to use
  33417. * @param forEach defines a predicate used to filter results
  33418. * @returns an array of Light
  33419. */
  33420. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33421. /**
  33422. * Get a list of materials by tags
  33423. * @param tagsQuery defines the tags query to use
  33424. * @param forEach defines a predicate used to filter results
  33425. * @returns an array of Material
  33426. */
  33427. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33428. /**
  33429. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33430. * This allowed control for front to back rendering or reversly depending of the special needs.
  33431. *
  33432. * @param renderingGroupId The rendering group id corresponding to its index
  33433. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33434. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33435. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33436. */
  33437. 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;
  33438. /**
  33439. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33440. *
  33441. * @param renderingGroupId The rendering group id corresponding to its index
  33442. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33443. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33444. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33445. */
  33446. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33447. /**
  33448. * Gets the current auto clear configuration for one rendering group of the rendering
  33449. * manager.
  33450. * @param index the rendering group index to get the information for
  33451. * @returns The auto clear setup for the requested rendering group
  33452. */
  33453. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33454. private _blockMaterialDirtyMechanism;
  33455. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33456. blockMaterialDirtyMechanism: boolean;
  33457. /**
  33458. * Will flag all materials as dirty to trigger new shader compilation
  33459. * @param flag defines the flag used to specify which material part must be marked as dirty
  33460. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33461. */
  33462. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33463. /** @hidden */
  33464. _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;
  33465. /** @hidden */
  33466. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33467. }
  33468. }
  33469. declare module BABYLON {
  33470. /**
  33471. * Set of assets to keep when moving a scene into an asset container.
  33472. */
  33473. export class KeepAssets extends AbstractScene {
  33474. }
  33475. /**
  33476. * Container with a set of assets that can be added or removed from a scene.
  33477. */
  33478. export class AssetContainer extends AbstractScene {
  33479. /**
  33480. * The scene the AssetContainer belongs to.
  33481. */
  33482. scene: Scene;
  33483. /**
  33484. * Instantiates an AssetContainer.
  33485. * @param scene The scene the AssetContainer belongs to.
  33486. */
  33487. constructor(scene: Scene);
  33488. /**
  33489. * Adds all the assets from the container to the scene.
  33490. */
  33491. addAllToScene(): void;
  33492. /**
  33493. * Removes all the assets in the container from the scene
  33494. */
  33495. removeAllFromScene(): void;
  33496. /**
  33497. * Disposes all the assets in the container
  33498. */
  33499. dispose(): void;
  33500. private _moveAssets;
  33501. /**
  33502. * Removes all the assets contained in the scene and adds them to the container.
  33503. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33504. */
  33505. moveAllFromScene(keepAssets?: KeepAssets): void;
  33506. /**
  33507. * 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.
  33508. * @returns the root mesh
  33509. */
  33510. createRootMesh(): Mesh;
  33511. }
  33512. }
  33513. declare module BABYLON {
  33514. /**
  33515. * Defines how the parser contract is defined.
  33516. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33517. */
  33518. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33519. /**
  33520. * Defines how the individual parser contract is defined.
  33521. * These parser can parse an individual asset
  33522. */
  33523. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33524. /**
  33525. * Base class of the scene acting as a container for the different elements composing a scene.
  33526. * This class is dynamically extended by the different components of the scene increasing
  33527. * flexibility and reducing coupling
  33528. */
  33529. export abstract class AbstractScene {
  33530. /**
  33531. * Stores the list of available parsers in the application.
  33532. */
  33533. private static _BabylonFileParsers;
  33534. /**
  33535. * Stores the list of available individual parsers in the application.
  33536. */
  33537. private static _IndividualBabylonFileParsers;
  33538. /**
  33539. * Adds a parser in the list of available ones
  33540. * @param name Defines the name of the parser
  33541. * @param parser Defines the parser to add
  33542. */
  33543. static AddParser(name: string, parser: BabylonFileParser): void;
  33544. /**
  33545. * Gets a general parser from the list of avaialble ones
  33546. * @param name Defines the name of the parser
  33547. * @returns the requested parser or null
  33548. */
  33549. static GetParser(name: string): Nullable<BabylonFileParser>;
  33550. /**
  33551. * Adds n individual parser in the list of available ones
  33552. * @param name Defines the name of the parser
  33553. * @param parser Defines the parser to add
  33554. */
  33555. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33556. /**
  33557. * Gets an individual parser from the list of avaialble ones
  33558. * @param name Defines the name of the parser
  33559. * @returns the requested parser or null
  33560. */
  33561. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33562. /**
  33563. * Parser json data and populate both a scene and its associated container object
  33564. * @param jsonData Defines the data to parse
  33565. * @param scene Defines the scene to parse the data for
  33566. * @param container Defines the container attached to the parsing sequence
  33567. * @param rootUrl Defines the root url of the data
  33568. */
  33569. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33570. /**
  33571. * Gets the list of root nodes (ie. nodes with no parent)
  33572. */
  33573. rootNodes: Node[];
  33574. /** All of the cameras added to this scene
  33575. * @see http://doc.babylonjs.com/babylon101/cameras
  33576. */
  33577. cameras: Camera[];
  33578. /**
  33579. * All of the lights added to this scene
  33580. * @see http://doc.babylonjs.com/babylon101/lights
  33581. */
  33582. lights: Light[];
  33583. /**
  33584. * All of the (abstract) meshes added to this scene
  33585. */
  33586. meshes: AbstractMesh[];
  33587. /**
  33588. * The list of skeletons added to the scene
  33589. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33590. */
  33591. skeletons: Skeleton[];
  33592. /**
  33593. * All of the particle systems added to this scene
  33594. * @see http://doc.babylonjs.com/babylon101/particles
  33595. */
  33596. particleSystems: IParticleSystem[];
  33597. /**
  33598. * Gets a list of Animations associated with the scene
  33599. */
  33600. animations: Animation[];
  33601. /**
  33602. * All of the animation groups added to this scene
  33603. * @see http://doc.babylonjs.com/how_to/group
  33604. */
  33605. animationGroups: AnimationGroup[];
  33606. /**
  33607. * All of the multi-materials added to this scene
  33608. * @see http://doc.babylonjs.com/how_to/multi_materials
  33609. */
  33610. multiMaterials: MultiMaterial[];
  33611. /**
  33612. * All of the materials added to this scene
  33613. * In the context of a Scene, it is not supposed to be modified manually.
  33614. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33615. * Note also that the order of the Material wihin the array is not significant and might change.
  33616. * @see http://doc.babylonjs.com/babylon101/materials
  33617. */
  33618. materials: Material[];
  33619. /**
  33620. * The list of morph target managers added to the scene
  33621. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33622. */
  33623. morphTargetManagers: MorphTargetManager[];
  33624. /**
  33625. * The list of geometries used in the scene.
  33626. */
  33627. geometries: Geometry[];
  33628. /**
  33629. * All of the tranform nodes added to this scene
  33630. * In the context of a Scene, it is not supposed to be modified manually.
  33631. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33632. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33633. * @see http://doc.babylonjs.com/how_to/transformnode
  33634. */
  33635. transformNodes: TransformNode[];
  33636. /**
  33637. * ActionManagers available on the scene.
  33638. */
  33639. actionManagers: AbstractActionManager[];
  33640. /**
  33641. * Textures to keep.
  33642. */
  33643. textures: BaseTexture[];
  33644. /**
  33645. * Environment texture for the scene
  33646. */
  33647. environmentTexture: Nullable<BaseTexture>;
  33648. }
  33649. }
  33650. declare module BABYLON {
  33651. /**
  33652. * Defines a sound that can be played in the application.
  33653. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33655. */
  33656. export class Sound {
  33657. /**
  33658. * The name of the sound in the scene.
  33659. */
  33660. name: string;
  33661. /**
  33662. * Does the sound autoplay once loaded.
  33663. */
  33664. autoplay: boolean;
  33665. /**
  33666. * Does the sound loop after it finishes playing once.
  33667. */
  33668. loop: boolean;
  33669. /**
  33670. * Does the sound use a custom attenuation curve to simulate the falloff
  33671. * happening when the source gets further away from the camera.
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33673. */
  33674. useCustomAttenuation: boolean;
  33675. /**
  33676. * The sound track id this sound belongs to.
  33677. */
  33678. soundTrackId: number;
  33679. /**
  33680. * Is this sound currently played.
  33681. */
  33682. isPlaying: boolean;
  33683. /**
  33684. * Is this sound currently paused.
  33685. */
  33686. isPaused: boolean;
  33687. /**
  33688. * Does this sound enables spatial sound.
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33690. */
  33691. spatialSound: boolean;
  33692. /**
  33693. * Define the reference distance the sound should be heard perfectly.
  33694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33695. */
  33696. refDistance: number;
  33697. /**
  33698. * Define the roll off factor of spatial sounds.
  33699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33700. */
  33701. rolloffFactor: number;
  33702. /**
  33703. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33705. */
  33706. maxDistance: number;
  33707. /**
  33708. * Define the distance attenuation model the sound will follow.
  33709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33710. */
  33711. distanceModel: string;
  33712. /**
  33713. * @hidden
  33714. * Back Compat
  33715. **/
  33716. onended: () => any;
  33717. /**
  33718. * Observable event when the current playing sound finishes.
  33719. */
  33720. onEndedObservable: Observable<Sound>;
  33721. private _panningModel;
  33722. private _playbackRate;
  33723. private _streaming;
  33724. private _startTime;
  33725. private _startOffset;
  33726. private _position;
  33727. /** @hidden */
  33728. _positionInEmitterSpace: boolean;
  33729. private _localDirection;
  33730. private _volume;
  33731. private _isReadyToPlay;
  33732. private _isDirectional;
  33733. private _readyToPlayCallback;
  33734. private _audioBuffer;
  33735. private _soundSource;
  33736. private _streamingSource;
  33737. private _soundPanner;
  33738. private _soundGain;
  33739. private _inputAudioNode;
  33740. private _outputAudioNode;
  33741. private _coneInnerAngle;
  33742. private _coneOuterAngle;
  33743. private _coneOuterGain;
  33744. private _scene;
  33745. private _connectedTransformNode;
  33746. private _customAttenuationFunction;
  33747. private _registerFunc;
  33748. private _isOutputConnected;
  33749. private _htmlAudioElement;
  33750. private _urlType;
  33751. /** @hidden */
  33752. static _SceneComponentInitialization: (scene: Scene) => void;
  33753. /**
  33754. * Create a sound and attach it to a scene
  33755. * @param name Name of your sound
  33756. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33757. * @param scene defines the scene the sound belongs to
  33758. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33759. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33760. */
  33761. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33762. /**
  33763. * Release the sound and its associated resources
  33764. */
  33765. dispose(): void;
  33766. /**
  33767. * Gets if the sounds is ready to be played or not.
  33768. * @returns true if ready, otherwise false
  33769. */
  33770. isReady(): boolean;
  33771. private _soundLoaded;
  33772. /**
  33773. * Sets the data of the sound from an audiobuffer
  33774. * @param audioBuffer The audioBuffer containing the data
  33775. */
  33776. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33777. /**
  33778. * Updates the current sounds options such as maxdistance, loop...
  33779. * @param options A JSON object containing values named as the object properties
  33780. */
  33781. updateOptions(options: any): void;
  33782. private _createSpatialParameters;
  33783. private _updateSpatialParameters;
  33784. /**
  33785. * Switch the panning model to HRTF:
  33786. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33788. */
  33789. switchPanningModelToHRTF(): void;
  33790. /**
  33791. * Switch the panning model to Equal Power:
  33792. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33794. */
  33795. switchPanningModelToEqualPower(): void;
  33796. private _switchPanningModel;
  33797. /**
  33798. * Connect this sound to a sound track audio node like gain...
  33799. * @param soundTrackAudioNode the sound track audio node to connect to
  33800. */
  33801. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33802. /**
  33803. * Transform this sound into a directional source
  33804. * @param coneInnerAngle Size of the inner cone in degree
  33805. * @param coneOuterAngle Size of the outer cone in degree
  33806. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33807. */
  33808. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33809. /**
  33810. * Gets or sets the inner angle for the directional cone.
  33811. */
  33812. /**
  33813. * Gets or sets the inner angle for the directional cone.
  33814. */
  33815. directionalConeInnerAngle: number;
  33816. /**
  33817. * Gets or sets the outer angle for the directional cone.
  33818. */
  33819. /**
  33820. * Gets or sets the outer angle for the directional cone.
  33821. */
  33822. directionalConeOuterAngle: number;
  33823. /**
  33824. * Sets the position of the emitter if spatial sound is enabled
  33825. * @param newPosition Defines the new posisiton
  33826. */
  33827. setPosition(newPosition: Vector3): void;
  33828. /**
  33829. * Sets the local direction of the emitter if spatial sound is enabled
  33830. * @param newLocalDirection Defines the new local direction
  33831. */
  33832. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33833. private _updateDirection;
  33834. /** @hidden */
  33835. updateDistanceFromListener(): void;
  33836. /**
  33837. * Sets a new custom attenuation function for the sound.
  33838. * @param callback Defines the function used for the attenuation
  33839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33840. */
  33841. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33842. /**
  33843. * Play the sound
  33844. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33845. * @param offset (optional) Start the sound setting it at a specific time
  33846. */
  33847. play(time?: number, offset?: number): void;
  33848. private _onended;
  33849. /**
  33850. * Stop the sound
  33851. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33852. */
  33853. stop(time?: number): void;
  33854. /**
  33855. * Put the sound in pause
  33856. */
  33857. pause(): void;
  33858. /**
  33859. * Sets a dedicated volume for this sounds
  33860. * @param newVolume Define the new volume of the sound
  33861. * @param time Define in how long the sound should be at this value
  33862. */
  33863. setVolume(newVolume: number, time?: number): void;
  33864. /**
  33865. * Set the sound play back rate
  33866. * @param newPlaybackRate Define the playback rate the sound should be played at
  33867. */
  33868. setPlaybackRate(newPlaybackRate: number): void;
  33869. /**
  33870. * Gets the volume of the sound.
  33871. * @returns the volume of the sound
  33872. */
  33873. getVolume(): number;
  33874. /**
  33875. * Attach the sound to a dedicated mesh
  33876. * @param transformNode The transform node to connect the sound with
  33877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33878. */
  33879. attachToMesh(transformNode: TransformNode): void;
  33880. /**
  33881. * Detach the sound from the previously attached mesh
  33882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33883. */
  33884. detachFromMesh(): void;
  33885. private _onRegisterAfterWorldMatrixUpdate;
  33886. /**
  33887. * Clone the current sound in the scene.
  33888. * @returns the new sound clone
  33889. */
  33890. clone(): Nullable<Sound>;
  33891. /**
  33892. * Gets the current underlying audio buffer containing the data
  33893. * @returns the audio buffer
  33894. */
  33895. getAudioBuffer(): Nullable<AudioBuffer>;
  33896. /**
  33897. * Serializes the Sound in a JSON representation
  33898. * @returns the JSON representation of the sound
  33899. */
  33900. serialize(): any;
  33901. /**
  33902. * Parse a JSON representation of a sound to innstantiate in a given scene
  33903. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33904. * @param scene Define the scene the new parsed sound should be created in
  33905. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33906. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33907. * @returns the newly parsed sound
  33908. */
  33909. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33910. }
  33911. }
  33912. declare module BABYLON {
  33913. /**
  33914. * This defines an action helpful to play a defined sound on a triggered action.
  33915. */
  33916. export class PlaySoundAction extends Action {
  33917. private _sound;
  33918. /**
  33919. * Instantiate the action
  33920. * @param triggerOptions defines the trigger options
  33921. * @param sound defines the sound to play
  33922. * @param condition defines the trigger related conditions
  33923. */
  33924. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33925. /** @hidden */
  33926. _prepare(): void;
  33927. /**
  33928. * Execute the action and play the sound.
  33929. */
  33930. execute(): void;
  33931. /**
  33932. * Serializes the actions and its related information.
  33933. * @param parent defines the object to serialize in
  33934. * @returns the serialized object
  33935. */
  33936. serialize(parent: any): any;
  33937. }
  33938. /**
  33939. * This defines an action helpful to stop a defined sound on a triggered action.
  33940. */
  33941. export class StopSoundAction extends Action {
  33942. private _sound;
  33943. /**
  33944. * Instantiate the action
  33945. * @param triggerOptions defines the trigger options
  33946. * @param sound defines the sound to stop
  33947. * @param condition defines the trigger related conditions
  33948. */
  33949. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33950. /** @hidden */
  33951. _prepare(): void;
  33952. /**
  33953. * Execute the action and stop the sound.
  33954. */
  33955. execute(): void;
  33956. /**
  33957. * Serializes the actions and its related information.
  33958. * @param parent defines the object to serialize in
  33959. * @returns the serialized object
  33960. */
  33961. serialize(parent: any): any;
  33962. }
  33963. }
  33964. declare module BABYLON {
  33965. /**
  33966. * This defines an action responsible to change the value of a property
  33967. * by interpolating between its current value and the newly set one once triggered.
  33968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33969. */
  33970. export class InterpolateValueAction extends Action {
  33971. /**
  33972. * Defines the path of the property where the value should be interpolated
  33973. */
  33974. propertyPath: string;
  33975. /**
  33976. * Defines the target value at the end of the interpolation.
  33977. */
  33978. value: any;
  33979. /**
  33980. * Defines the time it will take for the property to interpolate to the value.
  33981. */
  33982. duration: number;
  33983. /**
  33984. * Defines if the other scene animations should be stopped when the action has been triggered
  33985. */
  33986. stopOtherAnimations?: boolean;
  33987. /**
  33988. * Defines a callback raised once the interpolation animation has been done.
  33989. */
  33990. onInterpolationDone?: () => void;
  33991. /**
  33992. * Observable triggered once the interpolation animation has been done.
  33993. */
  33994. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33995. private _target;
  33996. private _effectiveTarget;
  33997. private _property;
  33998. /**
  33999. * Instantiate the action
  34000. * @param triggerOptions defines the trigger options
  34001. * @param target defines the object containing the value to interpolate
  34002. * @param propertyPath defines the path to the property in the target object
  34003. * @param value defines the target value at the end of the interpolation
  34004. * @param duration deines the time it will take for the property to interpolate to the value.
  34005. * @param condition defines the trigger related conditions
  34006. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34007. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34008. */
  34009. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34010. /** @hidden */
  34011. _prepare(): void;
  34012. /**
  34013. * Execute the action starts the value interpolation.
  34014. */
  34015. execute(): void;
  34016. /**
  34017. * Serializes the actions and its related information.
  34018. * @param parent defines the object to serialize in
  34019. * @returns the serialized object
  34020. */
  34021. serialize(parent: any): any;
  34022. }
  34023. }
  34024. declare module BABYLON {
  34025. /**
  34026. * Options allowed during the creation of a sound track.
  34027. */
  34028. export interface ISoundTrackOptions {
  34029. /**
  34030. * The volume the sound track should take during creation
  34031. */
  34032. volume?: number;
  34033. /**
  34034. * Define if the sound track is the main sound track of the scene
  34035. */
  34036. mainTrack?: boolean;
  34037. }
  34038. /**
  34039. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34040. * It will be also used in a future release to apply effects on a specific track.
  34041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34042. */
  34043. export class SoundTrack {
  34044. /**
  34045. * The unique identifier of the sound track in the scene.
  34046. */
  34047. id: number;
  34048. /**
  34049. * The list of sounds included in the sound track.
  34050. */
  34051. soundCollection: Array<Sound>;
  34052. private _outputAudioNode;
  34053. private _scene;
  34054. private _isMainTrack;
  34055. private _connectedAnalyser;
  34056. private _options;
  34057. private _isInitialized;
  34058. /**
  34059. * Creates a new sound track.
  34060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34061. * @param scene Define the scene the sound track belongs to
  34062. * @param options
  34063. */
  34064. constructor(scene: Scene, options?: ISoundTrackOptions);
  34065. private _initializeSoundTrackAudioGraph;
  34066. /**
  34067. * Release the sound track and its associated resources
  34068. */
  34069. dispose(): void;
  34070. /**
  34071. * Adds a sound to this sound track
  34072. * @param sound define the cound to add
  34073. * @ignoreNaming
  34074. */
  34075. AddSound(sound: Sound): void;
  34076. /**
  34077. * Removes a sound to this sound track
  34078. * @param sound define the cound to remove
  34079. * @ignoreNaming
  34080. */
  34081. RemoveSound(sound: Sound): void;
  34082. /**
  34083. * Set a global volume for the full sound track.
  34084. * @param newVolume Define the new volume of the sound track
  34085. */
  34086. setVolume(newVolume: number): void;
  34087. /**
  34088. * Switch the panning model to HRTF:
  34089. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34091. */
  34092. switchPanningModelToHRTF(): void;
  34093. /**
  34094. * Switch the panning model to Equal Power:
  34095. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34097. */
  34098. switchPanningModelToEqualPower(): void;
  34099. /**
  34100. * Connect the sound track to an audio analyser allowing some amazing
  34101. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34103. * @param analyser The analyser to connect to the engine
  34104. */
  34105. connectToAnalyser(analyser: Analyser): void;
  34106. }
  34107. }
  34108. declare module BABYLON {
  34109. interface AbstractScene {
  34110. /**
  34111. * The list of sounds used in the scene.
  34112. */
  34113. sounds: Nullable<Array<Sound>>;
  34114. }
  34115. interface Scene {
  34116. /**
  34117. * @hidden
  34118. * Backing field
  34119. */
  34120. _mainSoundTrack: SoundTrack;
  34121. /**
  34122. * The main sound track played by the scene.
  34123. * It cotains your primary collection of sounds.
  34124. */
  34125. mainSoundTrack: SoundTrack;
  34126. /**
  34127. * The list of sound tracks added to the scene
  34128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34129. */
  34130. soundTracks: Nullable<Array<SoundTrack>>;
  34131. /**
  34132. * Gets a sound using a given name
  34133. * @param name defines the name to search for
  34134. * @return the found sound or null if not found at all.
  34135. */
  34136. getSoundByName(name: string): Nullable<Sound>;
  34137. /**
  34138. * Gets or sets if audio support is enabled
  34139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34140. */
  34141. audioEnabled: boolean;
  34142. /**
  34143. * Gets or sets if audio will be output to headphones
  34144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34145. */
  34146. headphone: boolean;
  34147. }
  34148. /**
  34149. * Defines the sound scene component responsible to manage any sounds
  34150. * in a given scene.
  34151. */
  34152. export class AudioSceneComponent implements ISceneSerializableComponent {
  34153. /**
  34154. * The component name helpfull to identify the component in the list of scene components.
  34155. */
  34156. readonly name: string;
  34157. /**
  34158. * The scene the component belongs to.
  34159. */
  34160. scene: Scene;
  34161. private _audioEnabled;
  34162. /**
  34163. * Gets whether audio is enabled or not.
  34164. * Please use related enable/disable method to switch state.
  34165. */
  34166. readonly audioEnabled: boolean;
  34167. private _headphone;
  34168. /**
  34169. * Gets whether audio is outputing to headphone or not.
  34170. * Please use the according Switch methods to change output.
  34171. */
  34172. readonly headphone: boolean;
  34173. /**
  34174. * Creates a new instance of the component for the given scene
  34175. * @param scene Defines the scene to register the component in
  34176. */
  34177. constructor(scene: Scene);
  34178. /**
  34179. * Registers the component in a given scene
  34180. */
  34181. register(): void;
  34182. /**
  34183. * Rebuilds the elements related to this component in case of
  34184. * context lost for instance.
  34185. */
  34186. rebuild(): void;
  34187. /**
  34188. * Serializes the component data to the specified json object
  34189. * @param serializationObject The object to serialize to
  34190. */
  34191. serialize(serializationObject: any): void;
  34192. /**
  34193. * Adds all the element from the container to the scene
  34194. * @param container the container holding the elements
  34195. */
  34196. addFromContainer(container: AbstractScene): void;
  34197. /**
  34198. * Removes all the elements in the container from the scene
  34199. * @param container contains the elements to remove
  34200. * @param dispose if the removed element should be disposed (default: false)
  34201. */
  34202. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34203. /**
  34204. * Disposes the component and the associated ressources.
  34205. */
  34206. dispose(): void;
  34207. /**
  34208. * Disables audio in the associated scene.
  34209. */
  34210. disableAudio(): void;
  34211. /**
  34212. * Enables audio in the associated scene.
  34213. */
  34214. enableAudio(): void;
  34215. /**
  34216. * Switch audio to headphone output.
  34217. */
  34218. switchAudioModeForHeadphones(): void;
  34219. /**
  34220. * Switch audio to normal speakers.
  34221. */
  34222. switchAudioModeForNormalSpeakers(): void;
  34223. private _afterRender;
  34224. }
  34225. }
  34226. declare module BABYLON {
  34227. /**
  34228. * Wraps one or more Sound objects and selects one with random weight for playback.
  34229. */
  34230. export class WeightedSound {
  34231. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34232. loop: boolean;
  34233. private _coneInnerAngle;
  34234. private _coneOuterAngle;
  34235. private _volume;
  34236. /** A Sound is currently playing. */
  34237. isPlaying: boolean;
  34238. /** A Sound is currently paused. */
  34239. isPaused: boolean;
  34240. private _sounds;
  34241. private _weights;
  34242. private _currentIndex?;
  34243. /**
  34244. * Creates a new WeightedSound from the list of sounds given.
  34245. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34246. * @param sounds Array of Sounds that will be selected from.
  34247. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34248. */
  34249. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34250. /**
  34251. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34252. */
  34253. /**
  34254. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34255. */
  34256. directionalConeInnerAngle: number;
  34257. /**
  34258. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34259. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34260. */
  34261. /**
  34262. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34263. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34264. */
  34265. directionalConeOuterAngle: number;
  34266. /**
  34267. * Playback volume.
  34268. */
  34269. /**
  34270. * Playback volume.
  34271. */
  34272. volume: number;
  34273. private _onended;
  34274. /**
  34275. * Suspend playback
  34276. */
  34277. pause(): void;
  34278. /**
  34279. * Stop playback
  34280. */
  34281. stop(): void;
  34282. /**
  34283. * Start playback.
  34284. * @param startOffset Position the clip head at a specific time in seconds.
  34285. */
  34286. play(startOffset?: number): void;
  34287. }
  34288. }
  34289. declare module BABYLON {
  34290. /**
  34291. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34293. */
  34294. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34295. /**
  34296. * Gets the name of the behavior.
  34297. */
  34298. readonly name: string;
  34299. /**
  34300. * The easing function used by animations
  34301. */
  34302. static EasingFunction: BackEase;
  34303. /**
  34304. * The easing mode used by animations
  34305. */
  34306. static EasingMode: number;
  34307. /**
  34308. * The duration of the animation, in milliseconds
  34309. */
  34310. transitionDuration: number;
  34311. /**
  34312. * Length of the distance animated by the transition when lower radius is reached
  34313. */
  34314. lowerRadiusTransitionRange: number;
  34315. /**
  34316. * Length of the distance animated by the transition when upper radius is reached
  34317. */
  34318. upperRadiusTransitionRange: number;
  34319. private _autoTransitionRange;
  34320. /**
  34321. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34322. */
  34323. /**
  34324. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34325. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34326. */
  34327. autoTransitionRange: boolean;
  34328. private _attachedCamera;
  34329. private _onAfterCheckInputsObserver;
  34330. private _onMeshTargetChangedObserver;
  34331. /**
  34332. * Initializes the behavior.
  34333. */
  34334. init(): void;
  34335. /**
  34336. * Attaches the behavior to its arc rotate camera.
  34337. * @param camera Defines the camera to attach the behavior to
  34338. */
  34339. attach(camera: ArcRotateCamera): void;
  34340. /**
  34341. * Detaches the behavior from its current arc rotate camera.
  34342. */
  34343. detach(): void;
  34344. private _radiusIsAnimating;
  34345. private _radiusBounceTransition;
  34346. private _animatables;
  34347. private _cachedWheelPrecision;
  34348. /**
  34349. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34350. * @param radiusLimit The limit to check against.
  34351. * @return Bool to indicate if at limit.
  34352. */
  34353. private _isRadiusAtLimit;
  34354. /**
  34355. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34356. * @param radiusDelta The delta by which to animate to. Can be negative.
  34357. */
  34358. private _applyBoundRadiusAnimation;
  34359. /**
  34360. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34361. */
  34362. protected _clearAnimationLocks(): void;
  34363. /**
  34364. * Stops and removes all animations that have been applied to the camera
  34365. */
  34366. stopAllAnimations(): void;
  34367. }
  34368. }
  34369. declare module BABYLON {
  34370. /**
  34371. * 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.
  34372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34373. */
  34374. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34375. /**
  34376. * Gets the name of the behavior.
  34377. */
  34378. readonly name: string;
  34379. private _mode;
  34380. private _radiusScale;
  34381. private _positionScale;
  34382. private _defaultElevation;
  34383. private _elevationReturnTime;
  34384. private _elevationReturnWaitTime;
  34385. private _zoomStopsAnimation;
  34386. private _framingTime;
  34387. /**
  34388. * The easing function used by animations
  34389. */
  34390. static EasingFunction: ExponentialEase;
  34391. /**
  34392. * The easing mode used by animations
  34393. */
  34394. static EasingMode: number;
  34395. /**
  34396. * Sets the current mode used by the behavior
  34397. */
  34398. /**
  34399. * Gets current mode used by the behavior.
  34400. */
  34401. mode: number;
  34402. /**
  34403. * Sets the scale applied to the radius (1 by default)
  34404. */
  34405. /**
  34406. * Gets the scale applied to the radius
  34407. */
  34408. radiusScale: number;
  34409. /**
  34410. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34411. */
  34412. /**
  34413. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34414. */
  34415. positionScale: number;
  34416. /**
  34417. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34418. * behaviour is triggered, in radians.
  34419. */
  34420. /**
  34421. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34422. * behaviour is triggered, in radians.
  34423. */
  34424. defaultElevation: number;
  34425. /**
  34426. * Sets the time (in milliseconds) taken to return to the default beta position.
  34427. * Negative value indicates camera should not return to default.
  34428. */
  34429. /**
  34430. * Gets the time (in milliseconds) taken to return to the default beta position.
  34431. * Negative value indicates camera should not return to default.
  34432. */
  34433. elevationReturnTime: number;
  34434. /**
  34435. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34436. */
  34437. /**
  34438. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34439. */
  34440. elevationReturnWaitTime: number;
  34441. /**
  34442. * Sets the flag that indicates if user zooming should stop animation.
  34443. */
  34444. /**
  34445. * Gets the flag that indicates if user zooming should stop animation.
  34446. */
  34447. zoomStopsAnimation: boolean;
  34448. /**
  34449. * Sets the transition time when framing the mesh, in milliseconds
  34450. */
  34451. /**
  34452. * Gets the transition time when framing the mesh, in milliseconds
  34453. */
  34454. framingTime: number;
  34455. /**
  34456. * Define if the behavior should automatically change the configured
  34457. * camera limits and sensibilities.
  34458. */
  34459. autoCorrectCameraLimitsAndSensibility: boolean;
  34460. private _onPrePointerObservableObserver;
  34461. private _onAfterCheckInputsObserver;
  34462. private _onMeshTargetChangedObserver;
  34463. private _attachedCamera;
  34464. private _isPointerDown;
  34465. private _lastInteractionTime;
  34466. /**
  34467. * Initializes the behavior.
  34468. */
  34469. init(): void;
  34470. /**
  34471. * Attaches the behavior to its arc rotate camera.
  34472. * @param camera Defines the camera to attach the behavior to
  34473. */
  34474. attach(camera: ArcRotateCamera): void;
  34475. /**
  34476. * Detaches the behavior from its current arc rotate camera.
  34477. */
  34478. detach(): void;
  34479. private _animatables;
  34480. private _betaIsAnimating;
  34481. private _betaTransition;
  34482. private _radiusTransition;
  34483. private _vectorTransition;
  34484. /**
  34485. * Targets the given mesh and updates zoom level accordingly.
  34486. * @param mesh The mesh to target.
  34487. * @param radius Optional. If a cached radius position already exists, overrides default.
  34488. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34491. */
  34492. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34493. /**
  34494. * Targets the given mesh with its children and updates zoom level accordingly.
  34495. * @param mesh The mesh to target.
  34496. * @param radius Optional. If a cached radius position already exists, overrides default.
  34497. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34498. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34499. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34500. */
  34501. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34502. /**
  34503. * Targets the given meshes with their children and updates zoom level accordingly.
  34504. * @param meshes The mesh to target.
  34505. * @param radius Optional. If a cached radius position already exists, overrides default.
  34506. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34507. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34508. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34509. */
  34510. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34511. /**
  34512. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34513. * @param minimumWorld Determines the smaller position of the bounding box extend
  34514. * @param maximumWorld Determines the bigger position of the bounding box extend
  34515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34517. */
  34518. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34519. /**
  34520. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34521. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34522. * frustum width.
  34523. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34524. * to fully enclose the mesh in the viewing frustum.
  34525. */
  34526. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34527. /**
  34528. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34529. * is automatically returned to its default position (expected to be above ground plane).
  34530. */
  34531. private _maintainCameraAboveGround;
  34532. /**
  34533. * Returns the frustum slope based on the canvas ratio and camera FOV
  34534. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34535. */
  34536. private _getFrustumSlope;
  34537. /**
  34538. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34539. */
  34540. private _clearAnimationLocks;
  34541. /**
  34542. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34543. */
  34544. private _applyUserInteraction;
  34545. /**
  34546. * Stops and removes all animations that have been applied to the camera
  34547. */
  34548. stopAllAnimations(): void;
  34549. /**
  34550. * Gets a value indicating if the user is moving the camera
  34551. */
  34552. readonly isUserIsMoving: boolean;
  34553. /**
  34554. * The camera can move all the way towards the mesh.
  34555. */
  34556. static IgnoreBoundsSizeMode: number;
  34557. /**
  34558. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34559. */
  34560. static FitFrustumSidesMode: number;
  34561. }
  34562. }
  34563. declare module BABYLON {
  34564. /**
  34565. * Base class for Camera Pointer Inputs.
  34566. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34567. * for example usage.
  34568. */
  34569. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34570. /**
  34571. * Defines the camera the input is attached to.
  34572. */
  34573. abstract camera: Camera;
  34574. /**
  34575. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34576. */
  34577. protected _altKey: boolean;
  34578. protected _ctrlKey: boolean;
  34579. protected _metaKey: boolean;
  34580. protected _shiftKey: boolean;
  34581. /**
  34582. * Which mouse buttons were pressed at time of last mouse event.
  34583. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34584. */
  34585. protected _buttonsPressed: number;
  34586. /**
  34587. * Defines the buttons associated with the input to handle camera move.
  34588. */
  34589. buttons: number[];
  34590. /**
  34591. * Attach the input controls to a specific dom element to get the input from.
  34592. * @param element Defines the element the controls should be listened from
  34593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34594. */
  34595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34596. /**
  34597. * Detach the current controls from the specified dom element.
  34598. * @param element Defines the element to stop listening the inputs from
  34599. */
  34600. detachControl(element: Nullable<HTMLElement>): void;
  34601. /**
  34602. * Gets the class name of the current input.
  34603. * @returns the class name
  34604. */
  34605. getClassName(): string;
  34606. /**
  34607. * Get the friendly name associated with the input class.
  34608. * @returns the input friendly name
  34609. */
  34610. getSimpleName(): string;
  34611. /**
  34612. * Called on pointer POINTERDOUBLETAP event.
  34613. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34614. */
  34615. protected onDoubleTap(type: string): void;
  34616. /**
  34617. * Called on pointer POINTERMOVE event if only a single touch is active.
  34618. * Override this method to provide functionality.
  34619. */
  34620. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34621. /**
  34622. * Called on pointer POINTERMOVE event if multiple touches are active.
  34623. * Override this method to provide functionality.
  34624. */
  34625. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34626. /**
  34627. * Called on JS contextmenu event.
  34628. * Override this method to provide functionality.
  34629. */
  34630. protected onContextMenu(evt: PointerEvent): void;
  34631. /**
  34632. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34633. * press.
  34634. * Override this method to provide functionality.
  34635. */
  34636. protected onButtonDown(evt: PointerEvent): void;
  34637. /**
  34638. * Called each time a new POINTERUP event occurs. Ie, for each button
  34639. * release.
  34640. * Override this method to provide functionality.
  34641. */
  34642. protected onButtonUp(evt: PointerEvent): void;
  34643. /**
  34644. * Called when window becomes inactive.
  34645. * Override this method to provide functionality.
  34646. */
  34647. protected onLostFocus(): void;
  34648. private _pointerInput;
  34649. private _observer;
  34650. private _onLostFocus;
  34651. private pointA;
  34652. private pointB;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /**
  34657. * Manage the pointers inputs to control an arc rotate camera.
  34658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34659. */
  34660. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34661. /**
  34662. * Defines the camera the input is attached to.
  34663. */
  34664. camera: ArcRotateCamera;
  34665. /**
  34666. * Gets the class name of the current input.
  34667. * @returns the class name
  34668. */
  34669. getClassName(): string;
  34670. /**
  34671. * Defines the buttons associated with the input to handle camera move.
  34672. */
  34673. buttons: number[];
  34674. /**
  34675. * Defines the pointer angular sensibility along the X axis or how fast is
  34676. * the camera rotating.
  34677. */
  34678. angularSensibilityX: number;
  34679. /**
  34680. * Defines the pointer angular sensibility along the Y axis or how fast is
  34681. * the camera rotating.
  34682. */
  34683. angularSensibilityY: number;
  34684. /**
  34685. * Defines the pointer pinch precision or how fast is the camera zooming.
  34686. */
  34687. pinchPrecision: number;
  34688. /**
  34689. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34690. * from 0.
  34691. * It defines the percentage of current camera.radius to use as delta when
  34692. * pinch zoom is used.
  34693. */
  34694. pinchDeltaPercentage: number;
  34695. /**
  34696. * Defines the pointer panning sensibility or how fast is the camera moving.
  34697. */
  34698. panningSensibility: number;
  34699. /**
  34700. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34701. */
  34702. multiTouchPanning: boolean;
  34703. /**
  34704. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34705. * zoom (pinch) through multitouch.
  34706. */
  34707. multiTouchPanAndZoom: boolean;
  34708. /**
  34709. * Revers pinch action direction.
  34710. */
  34711. pinchInwards: boolean;
  34712. private _isPanClick;
  34713. private _twoFingerActivityCount;
  34714. private _isPinching;
  34715. /**
  34716. * Called on pointer POINTERMOVE event if only a single touch is active.
  34717. */
  34718. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34719. /**
  34720. * Called on pointer POINTERDOUBLETAP event.
  34721. */
  34722. protected onDoubleTap(type: string): void;
  34723. /**
  34724. * Called on pointer POINTERMOVE event if multiple touches are active.
  34725. */
  34726. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34727. /**
  34728. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34729. * press.
  34730. */
  34731. protected onButtonDown(evt: PointerEvent): void;
  34732. /**
  34733. * Called each time a new POINTERUP event occurs. Ie, for each button
  34734. * release.
  34735. */
  34736. protected onButtonUp(evt: PointerEvent): void;
  34737. /**
  34738. * Called when window becomes inactive.
  34739. */
  34740. protected onLostFocus(): void;
  34741. }
  34742. }
  34743. declare module BABYLON {
  34744. /**
  34745. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34746. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34747. */
  34748. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34749. /**
  34750. * Defines the camera the input is attached to.
  34751. */
  34752. camera: ArcRotateCamera;
  34753. /**
  34754. * Defines the list of key codes associated with the up action (increase alpha)
  34755. */
  34756. keysUp: number[];
  34757. /**
  34758. * Defines the list of key codes associated with the down action (decrease alpha)
  34759. */
  34760. keysDown: number[];
  34761. /**
  34762. * Defines the list of key codes associated with the left action (increase beta)
  34763. */
  34764. keysLeft: number[];
  34765. /**
  34766. * Defines the list of key codes associated with the right action (decrease beta)
  34767. */
  34768. keysRight: number[];
  34769. /**
  34770. * Defines the list of key codes associated with the reset action.
  34771. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34772. */
  34773. keysReset: number[];
  34774. /**
  34775. * Defines the panning sensibility of the inputs.
  34776. * (How fast is the camera paning)
  34777. */
  34778. panningSensibility: number;
  34779. /**
  34780. * Defines the zooming sensibility of the inputs.
  34781. * (How fast is the camera zooming)
  34782. */
  34783. zoomingSensibility: number;
  34784. /**
  34785. * Defines wether maintaining the alt key down switch the movement mode from
  34786. * orientation to zoom.
  34787. */
  34788. useAltToZoom: boolean;
  34789. /**
  34790. * Rotation speed of the camera
  34791. */
  34792. angularSpeed: number;
  34793. private _keys;
  34794. private _ctrlPressed;
  34795. private _altPressed;
  34796. private _onCanvasBlurObserver;
  34797. private _onKeyboardObserver;
  34798. private _engine;
  34799. private _scene;
  34800. /**
  34801. * Attach the input controls to a specific dom element to get the input from.
  34802. * @param element Defines the element the controls should be listened from
  34803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34804. */
  34805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34806. /**
  34807. * Detach the current controls from the specified dom element.
  34808. * @param element Defines the element to stop listening the inputs from
  34809. */
  34810. detachControl(element: Nullable<HTMLElement>): void;
  34811. /**
  34812. * Update the current camera state depending on the inputs that have been used this frame.
  34813. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34814. */
  34815. checkInputs(): void;
  34816. /**
  34817. * Gets the class name of the current intput.
  34818. * @returns the class name
  34819. */
  34820. getClassName(): string;
  34821. /**
  34822. * Get the friendly name associated with the input class.
  34823. * @returns the input friendly name
  34824. */
  34825. getSimpleName(): string;
  34826. }
  34827. }
  34828. declare module BABYLON {
  34829. /**
  34830. * Manage the mouse wheel inputs to control an arc rotate camera.
  34831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34832. */
  34833. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34834. /**
  34835. * Defines the camera the input is attached to.
  34836. */
  34837. camera: ArcRotateCamera;
  34838. /**
  34839. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34840. */
  34841. wheelPrecision: number;
  34842. /**
  34843. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34844. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34845. */
  34846. wheelDeltaPercentage: number;
  34847. private _wheel;
  34848. private _observer;
  34849. /**
  34850. * Attach the input controls to a specific dom element to get the input from.
  34851. * @param element Defines the element the controls should be listened from
  34852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34853. */
  34854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34855. /**
  34856. * Detach the current controls from the specified dom element.
  34857. * @param element Defines the element to stop listening the inputs from
  34858. */
  34859. detachControl(element: Nullable<HTMLElement>): void;
  34860. /**
  34861. * Gets the class name of the current intput.
  34862. * @returns the class name
  34863. */
  34864. getClassName(): string;
  34865. /**
  34866. * Get the friendly name associated with the input class.
  34867. * @returns the input friendly name
  34868. */
  34869. getSimpleName(): string;
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. * Default Inputs manager for the ArcRotateCamera.
  34875. * It groups all the default supported inputs for ease of use.
  34876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34877. */
  34878. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34879. /**
  34880. * Instantiates a new ArcRotateCameraInputsManager.
  34881. * @param camera Defines the camera the inputs belong to
  34882. */
  34883. constructor(camera: ArcRotateCamera);
  34884. /**
  34885. * Add mouse wheel input support to the input manager.
  34886. * @returns the current input manager
  34887. */
  34888. addMouseWheel(): ArcRotateCameraInputsManager;
  34889. /**
  34890. * Add pointers input support to the input manager.
  34891. * @returns the current input manager
  34892. */
  34893. addPointers(): ArcRotateCameraInputsManager;
  34894. /**
  34895. * Add keyboard input support to the input manager.
  34896. * @returns the current input manager
  34897. */
  34898. addKeyboard(): ArcRotateCameraInputsManager;
  34899. }
  34900. }
  34901. declare module BABYLON {
  34902. /**
  34903. * This represents an orbital type of camera.
  34904. *
  34905. * 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.
  34906. * 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.
  34907. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34908. */
  34909. export class ArcRotateCamera extends TargetCamera {
  34910. /**
  34911. * Defines the rotation angle of the camera along the longitudinal axis.
  34912. */
  34913. alpha: number;
  34914. /**
  34915. * Defines the rotation angle of the camera along the latitudinal axis.
  34916. */
  34917. beta: number;
  34918. /**
  34919. * Defines the radius of the camera from it s target point.
  34920. */
  34921. radius: number;
  34922. protected _target: Vector3;
  34923. protected _targetHost: Nullable<AbstractMesh>;
  34924. /**
  34925. * Defines the target point of the camera.
  34926. * The camera looks towards it form the radius distance.
  34927. */
  34928. target: Vector3;
  34929. /**
  34930. * Define the current local position of the camera in the scene
  34931. */
  34932. position: Vector3;
  34933. protected _upVector: Vector3;
  34934. protected _upToYMatrix: Matrix;
  34935. protected _YToUpMatrix: Matrix;
  34936. /**
  34937. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34938. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34939. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34940. */
  34941. upVector: Vector3;
  34942. /**
  34943. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34944. */
  34945. setMatUp(): void;
  34946. /**
  34947. * Current inertia value on the longitudinal axis.
  34948. * The bigger this number the longer it will take for the camera to stop.
  34949. */
  34950. inertialAlphaOffset: number;
  34951. /**
  34952. * Current inertia value on the latitudinal axis.
  34953. * The bigger this number the longer it will take for the camera to stop.
  34954. */
  34955. inertialBetaOffset: number;
  34956. /**
  34957. * Current inertia value on the radius axis.
  34958. * The bigger this number the longer it will take for the camera to stop.
  34959. */
  34960. inertialRadiusOffset: number;
  34961. /**
  34962. * Minimum allowed angle on the longitudinal axis.
  34963. * This can help limiting how the Camera is able to move in the scene.
  34964. */
  34965. lowerAlphaLimit: Nullable<number>;
  34966. /**
  34967. * Maximum allowed angle on the longitudinal axis.
  34968. * This can help limiting how the Camera is able to move in the scene.
  34969. */
  34970. upperAlphaLimit: Nullable<number>;
  34971. /**
  34972. * Minimum allowed angle on the latitudinal axis.
  34973. * This can help limiting how the Camera is able to move in the scene.
  34974. */
  34975. lowerBetaLimit: number;
  34976. /**
  34977. * Maximum allowed angle on the latitudinal axis.
  34978. * This can help limiting how the Camera is able to move in the scene.
  34979. */
  34980. upperBetaLimit: number;
  34981. /**
  34982. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34983. * This can help limiting how the Camera is able to move in the scene.
  34984. */
  34985. lowerRadiusLimit: Nullable<number>;
  34986. /**
  34987. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34988. * This can help limiting how the Camera is able to move in the scene.
  34989. */
  34990. upperRadiusLimit: Nullable<number>;
  34991. /**
  34992. * Defines the current inertia value used during panning of the camera along the X axis.
  34993. */
  34994. inertialPanningX: number;
  34995. /**
  34996. * Defines the current inertia value used during panning of the camera along the Y axis.
  34997. */
  34998. inertialPanningY: number;
  34999. /**
  35000. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35001. * Basically if your fingers moves away from more than this distance you will be considered
  35002. * in pinch mode.
  35003. */
  35004. pinchToPanMaxDistance: number;
  35005. /**
  35006. * Defines the maximum distance the camera can pan.
  35007. * This could help keeping the cammera always in your scene.
  35008. */
  35009. panningDistanceLimit: Nullable<number>;
  35010. /**
  35011. * Defines the target of the camera before paning.
  35012. */
  35013. panningOriginTarget: Vector3;
  35014. /**
  35015. * Defines the value of the inertia used during panning.
  35016. * 0 would mean stop inertia and one would mean no decelleration at all.
  35017. */
  35018. panningInertia: number;
  35019. /**
  35020. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35021. */
  35022. angularSensibilityX: number;
  35023. /**
  35024. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35025. */
  35026. angularSensibilityY: number;
  35027. /**
  35028. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35029. */
  35030. pinchPrecision: number;
  35031. /**
  35032. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35033. * It will be used instead of pinchDeltaPrecision if different from 0.
  35034. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35035. */
  35036. pinchDeltaPercentage: number;
  35037. /**
  35038. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35039. */
  35040. panningSensibility: number;
  35041. /**
  35042. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35043. */
  35044. keysUp: number[];
  35045. /**
  35046. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35047. */
  35048. keysDown: number[];
  35049. /**
  35050. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35051. */
  35052. keysLeft: number[];
  35053. /**
  35054. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35055. */
  35056. keysRight: number[];
  35057. /**
  35058. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35059. */
  35060. wheelPrecision: number;
  35061. /**
  35062. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35063. * It will be used instead of pinchDeltaPrecision if different from 0.
  35064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35065. */
  35066. wheelDeltaPercentage: number;
  35067. /**
  35068. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35069. */
  35070. zoomOnFactor: number;
  35071. /**
  35072. * Defines a screen offset for the camera position.
  35073. */
  35074. targetScreenOffset: Vector2;
  35075. /**
  35076. * Allows the camera to be completely reversed.
  35077. * If false the camera can not arrive upside down.
  35078. */
  35079. allowUpsideDown: boolean;
  35080. /**
  35081. * Define if double tap/click is used to restore the previously saved state of the camera.
  35082. */
  35083. useInputToRestoreState: boolean;
  35084. /** @hidden */
  35085. _viewMatrix: Matrix;
  35086. /** @hidden */
  35087. _useCtrlForPanning: boolean;
  35088. /** @hidden */
  35089. _panningMouseButton: number;
  35090. /**
  35091. * Defines the input associated to the camera.
  35092. */
  35093. inputs: ArcRotateCameraInputsManager;
  35094. /** @hidden */
  35095. _reset: () => void;
  35096. /**
  35097. * Defines the allowed panning axis.
  35098. */
  35099. panningAxis: Vector3;
  35100. protected _localDirection: Vector3;
  35101. protected _transformedDirection: Vector3;
  35102. private _bouncingBehavior;
  35103. /**
  35104. * Gets the bouncing behavior of the camera if it has been enabled.
  35105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35106. */
  35107. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35108. /**
  35109. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35110. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35111. */
  35112. useBouncingBehavior: boolean;
  35113. private _framingBehavior;
  35114. /**
  35115. * Gets the framing behavior of the camera if it has been enabled.
  35116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35117. */
  35118. readonly framingBehavior: Nullable<FramingBehavior>;
  35119. /**
  35120. * Defines if the framing behavior of the camera is enabled on the camera.
  35121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35122. */
  35123. useFramingBehavior: boolean;
  35124. private _autoRotationBehavior;
  35125. /**
  35126. * Gets the auto rotation behavior of the camera if it has been enabled.
  35127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35128. */
  35129. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35130. /**
  35131. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35133. */
  35134. useAutoRotationBehavior: boolean;
  35135. /**
  35136. * Observable triggered when the mesh target has been changed on the camera.
  35137. */
  35138. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35139. /**
  35140. * Event raised when the camera is colliding with a mesh.
  35141. */
  35142. onCollide: (collidedMesh: AbstractMesh) => void;
  35143. /**
  35144. * Defines whether the camera should check collision with the objects oh the scene.
  35145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35146. */
  35147. checkCollisions: boolean;
  35148. /**
  35149. * Defines the collision radius of the camera.
  35150. * This simulates a sphere around the camera.
  35151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35152. */
  35153. collisionRadius: Vector3;
  35154. protected _collider: Collider;
  35155. protected _previousPosition: Vector3;
  35156. protected _collisionVelocity: Vector3;
  35157. protected _newPosition: Vector3;
  35158. protected _previousAlpha: number;
  35159. protected _previousBeta: number;
  35160. protected _previousRadius: number;
  35161. protected _collisionTriggered: boolean;
  35162. protected _targetBoundingCenter: Nullable<Vector3>;
  35163. private _computationVector;
  35164. /**
  35165. * Instantiates a new ArcRotateCamera in a given scene
  35166. * @param name Defines the name of the camera
  35167. * @param alpha Defines the camera rotation along the logitudinal axis
  35168. * @param beta Defines the camera rotation along the latitudinal axis
  35169. * @param radius Defines the camera distance from its target
  35170. * @param target Defines the camera target
  35171. * @param scene Defines the scene the camera belongs to
  35172. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35173. */
  35174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35175. /** @hidden */
  35176. _initCache(): void;
  35177. /** @hidden */
  35178. _updateCache(ignoreParentClass?: boolean): void;
  35179. protected _getTargetPosition(): Vector3;
  35180. private _storedAlpha;
  35181. private _storedBeta;
  35182. private _storedRadius;
  35183. private _storedTarget;
  35184. /**
  35185. * Stores the current state of the camera (alpha, beta, radius and target)
  35186. * @returns the camera itself
  35187. */
  35188. storeState(): Camera;
  35189. /**
  35190. * @hidden
  35191. * Restored camera state. You must call storeState() first
  35192. */
  35193. _restoreStateValues(): boolean;
  35194. /** @hidden */
  35195. _isSynchronizedViewMatrix(): boolean;
  35196. /**
  35197. * Attached controls to the current camera.
  35198. * @param element Defines the element the controls should be listened from
  35199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35200. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35201. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35202. */
  35203. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35204. /**
  35205. * Detach the current controls from the camera.
  35206. * The camera will stop reacting to inputs.
  35207. * @param element Defines the element to stop listening the inputs from
  35208. */
  35209. detachControl(element: HTMLElement): void;
  35210. /** @hidden */
  35211. _checkInputs(): void;
  35212. protected _checkLimits(): void;
  35213. /**
  35214. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35215. */
  35216. rebuildAnglesAndRadius(): void;
  35217. /**
  35218. * Use a position to define the current camera related information like aplha, beta and radius
  35219. * @param position Defines the position to set the camera at
  35220. */
  35221. setPosition(position: Vector3): void;
  35222. /**
  35223. * Defines the target the camera should look at.
  35224. * This will automatically adapt alpha beta and radius to fit within the new target.
  35225. * @param target Defines the new target as a Vector or a mesh
  35226. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35227. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35228. */
  35229. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35230. /** @hidden */
  35231. _getViewMatrix(): Matrix;
  35232. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35233. /**
  35234. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35235. * @param meshes Defines the mesh to zoom on
  35236. * @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)
  35237. */
  35238. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35239. /**
  35240. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35241. * The target will be changed but the radius
  35242. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35243. * @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)
  35244. */
  35245. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35246. min: Vector3;
  35247. max: Vector3;
  35248. distance: number;
  35249. }, doNotUpdateMaxZ?: boolean): void;
  35250. /**
  35251. * @override
  35252. * Override Camera.createRigCamera
  35253. */
  35254. createRigCamera(name: string, cameraIndex: number): Camera;
  35255. /**
  35256. * @hidden
  35257. * @override
  35258. * Override Camera._updateRigCameras
  35259. */
  35260. _updateRigCameras(): void;
  35261. /**
  35262. * Destroy the camera and release the current resources hold by it.
  35263. */
  35264. dispose(): void;
  35265. /**
  35266. * Gets the current object class name.
  35267. * @return the class name
  35268. */
  35269. getClassName(): string;
  35270. }
  35271. }
  35272. declare module BABYLON {
  35273. /**
  35274. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35275. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35276. */
  35277. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35278. /**
  35279. * Gets the name of the behavior.
  35280. */
  35281. readonly name: string;
  35282. private _zoomStopsAnimation;
  35283. private _idleRotationSpeed;
  35284. private _idleRotationWaitTime;
  35285. private _idleRotationSpinupTime;
  35286. /**
  35287. * Sets the flag that indicates if user zooming should stop animation.
  35288. */
  35289. /**
  35290. * Gets the flag that indicates if user zooming should stop animation.
  35291. */
  35292. zoomStopsAnimation: boolean;
  35293. /**
  35294. * Sets the default speed at which the camera rotates around the model.
  35295. */
  35296. /**
  35297. * Gets the default speed at which the camera rotates around the model.
  35298. */
  35299. idleRotationSpeed: number;
  35300. /**
  35301. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35302. */
  35303. /**
  35304. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35305. */
  35306. idleRotationWaitTime: number;
  35307. /**
  35308. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35309. */
  35310. /**
  35311. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35312. */
  35313. idleRotationSpinupTime: number;
  35314. /**
  35315. * Gets a value indicating if the camera is currently rotating because of this behavior
  35316. */
  35317. readonly rotationInProgress: boolean;
  35318. private _onPrePointerObservableObserver;
  35319. private _onAfterCheckInputsObserver;
  35320. private _attachedCamera;
  35321. private _isPointerDown;
  35322. private _lastFrameTime;
  35323. private _lastInteractionTime;
  35324. private _cameraRotationSpeed;
  35325. /**
  35326. * Initializes the behavior.
  35327. */
  35328. init(): void;
  35329. /**
  35330. * Attaches the behavior to its arc rotate camera.
  35331. * @param camera Defines the camera to attach the behavior to
  35332. */
  35333. attach(camera: ArcRotateCamera): void;
  35334. /**
  35335. * Detaches the behavior from its current arc rotate camera.
  35336. */
  35337. detach(): void;
  35338. /**
  35339. * Returns true if user is scrolling.
  35340. * @return true if user is scrolling.
  35341. */
  35342. private _userIsZooming;
  35343. private _lastFrameRadius;
  35344. private _shouldAnimationStopForInteraction;
  35345. /**
  35346. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35347. */
  35348. private _applyUserInteraction;
  35349. private _userIsMoving;
  35350. }
  35351. }
  35352. declare module BABYLON {
  35353. /**
  35354. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35355. */
  35356. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35357. private ui;
  35358. /**
  35359. * The name of the behavior
  35360. */
  35361. name: string;
  35362. /**
  35363. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35364. */
  35365. distanceAwayFromFace: number;
  35366. /**
  35367. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35368. */
  35369. distanceAwayFromBottomOfFace: number;
  35370. private _faceVectors;
  35371. private _target;
  35372. private _scene;
  35373. private _onRenderObserver;
  35374. private _tmpMatrix;
  35375. private _tmpVector;
  35376. /**
  35377. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35378. * @param ui The transform node that should be attched to the mesh
  35379. */
  35380. constructor(ui: TransformNode);
  35381. /**
  35382. * Initializes the behavior
  35383. */
  35384. init(): void;
  35385. private _closestFace;
  35386. private _zeroVector;
  35387. private _lookAtTmpMatrix;
  35388. private _lookAtToRef;
  35389. /**
  35390. * Attaches the AttachToBoxBehavior to the passed in mesh
  35391. * @param target The mesh that the specified node will be attached to
  35392. */
  35393. attach(target: Mesh): void;
  35394. /**
  35395. * Detaches the behavior from the mesh
  35396. */
  35397. detach(): void;
  35398. }
  35399. }
  35400. declare module BABYLON {
  35401. /**
  35402. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35403. */
  35404. export class FadeInOutBehavior implements Behavior<Mesh> {
  35405. /**
  35406. * Time in milliseconds to delay before fading in (Default: 0)
  35407. */
  35408. delay: number;
  35409. /**
  35410. * Time in milliseconds for the mesh to fade in (Default: 300)
  35411. */
  35412. fadeInTime: number;
  35413. private _millisecondsPerFrame;
  35414. private _hovered;
  35415. private _hoverValue;
  35416. private _ownerNode;
  35417. /**
  35418. * Instatiates the FadeInOutBehavior
  35419. */
  35420. constructor();
  35421. /**
  35422. * The name of the behavior
  35423. */
  35424. readonly name: string;
  35425. /**
  35426. * Initializes the behavior
  35427. */
  35428. init(): void;
  35429. /**
  35430. * Attaches the fade behavior on the passed in mesh
  35431. * @param ownerNode The mesh that will be faded in/out once attached
  35432. */
  35433. attach(ownerNode: Mesh): void;
  35434. /**
  35435. * Detaches the behavior from the mesh
  35436. */
  35437. detach(): void;
  35438. /**
  35439. * Triggers the mesh to begin fading in or out
  35440. * @param value if the object should fade in or out (true to fade in)
  35441. */
  35442. fadeIn(value: boolean): void;
  35443. private _update;
  35444. private _setAllVisibility;
  35445. }
  35446. }
  35447. declare module BABYLON {
  35448. /**
  35449. * Class containing a set of static utilities functions for managing Pivots
  35450. * @hidden
  35451. */
  35452. export class PivotTools {
  35453. private static _PivotCached;
  35454. private static _OldPivotPoint;
  35455. private static _PivotTranslation;
  35456. private static _PivotTmpVector;
  35457. /** @hidden */
  35458. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35459. /** @hidden */
  35460. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35461. }
  35462. }
  35463. declare module BABYLON {
  35464. /**
  35465. * Class containing static functions to help procedurally build meshes
  35466. */
  35467. export class PlaneBuilder {
  35468. /**
  35469. * Creates a plane mesh
  35470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35474. * * 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
  35475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35476. * @param name defines the name of the mesh
  35477. * @param options defines the options used to create the mesh
  35478. * @param scene defines the hosting scene
  35479. * @returns the plane mesh
  35480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35481. */
  35482. static CreatePlane(name: string, options: {
  35483. size?: number;
  35484. width?: number;
  35485. height?: number;
  35486. sideOrientation?: number;
  35487. frontUVs?: Vector4;
  35488. backUVs?: Vector4;
  35489. updatable?: boolean;
  35490. sourcePlane?: Plane;
  35491. }, scene?: Nullable<Scene>): Mesh;
  35492. }
  35493. }
  35494. declare module BABYLON {
  35495. /**
  35496. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35497. */
  35498. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35499. private static _AnyMouseID;
  35500. private _attachedNode;
  35501. private _dragPlane;
  35502. private _scene;
  35503. private _pointerObserver;
  35504. private _beforeRenderObserver;
  35505. private static _planeScene;
  35506. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35507. /**
  35508. * 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)
  35509. */
  35510. maxDragAngle: number;
  35511. /**
  35512. * @hidden
  35513. */
  35514. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35515. /**
  35516. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35517. */
  35518. currentDraggingPointerID: number;
  35519. /**
  35520. * The last position where the pointer hit the drag plane in world space
  35521. */
  35522. lastDragPosition: Vector3;
  35523. /**
  35524. * If the behavior is currently in a dragging state
  35525. */
  35526. dragging: boolean;
  35527. /**
  35528. * 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)
  35529. */
  35530. dragDeltaRatio: number;
  35531. /**
  35532. * If the drag plane orientation should be updated during the dragging (Default: true)
  35533. */
  35534. updateDragPlane: boolean;
  35535. private _debugMode;
  35536. private _moving;
  35537. /**
  35538. * Fires each time the attached mesh is dragged with the pointer
  35539. * * delta between last drag position and current drag position in world space
  35540. * * dragDistance along the drag axis
  35541. * * dragPlaneNormal normal of the current drag plane used during the drag
  35542. * * dragPlanePoint in world space where the drag intersects the drag plane
  35543. */
  35544. onDragObservable: Observable<{
  35545. delta: Vector3;
  35546. dragPlanePoint: Vector3;
  35547. dragPlaneNormal: Vector3;
  35548. dragDistance: number;
  35549. pointerId: number;
  35550. }>;
  35551. /**
  35552. * Fires each time a drag begins (eg. mouse down on mesh)
  35553. */
  35554. onDragStartObservable: Observable<{
  35555. dragPlanePoint: Vector3;
  35556. pointerId: number;
  35557. }>;
  35558. /**
  35559. * Fires each time a drag ends (eg. mouse release after drag)
  35560. */
  35561. onDragEndObservable: Observable<{
  35562. dragPlanePoint: Vector3;
  35563. pointerId: number;
  35564. }>;
  35565. /**
  35566. * If the attached mesh should be moved when dragged
  35567. */
  35568. moveAttached: boolean;
  35569. /**
  35570. * If the drag behavior will react to drag events (Default: true)
  35571. */
  35572. enabled: boolean;
  35573. /**
  35574. * If camera controls should be detached during the drag
  35575. */
  35576. detachCameraControls: boolean;
  35577. /**
  35578. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35579. */
  35580. useObjectOrienationForDragging: boolean;
  35581. private _options;
  35582. /**
  35583. * Creates a pointer drag behavior that can be attached to a mesh
  35584. * @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)
  35585. */
  35586. constructor(options?: {
  35587. dragAxis?: Vector3;
  35588. dragPlaneNormal?: Vector3;
  35589. });
  35590. /**
  35591. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35592. */
  35593. validateDrag: (targetPosition: Vector3) => boolean;
  35594. /**
  35595. * The name of the behavior
  35596. */
  35597. readonly name: string;
  35598. /**
  35599. * Initializes the behavior
  35600. */
  35601. init(): void;
  35602. private _tmpVector;
  35603. private _alternatePickedPoint;
  35604. private _worldDragAxis;
  35605. private _targetPosition;
  35606. private _attachedElement;
  35607. /**
  35608. * Attaches the drag behavior the passed in mesh
  35609. * @param ownerNode The mesh that will be dragged around once attached
  35610. */
  35611. attach(ownerNode: AbstractMesh): void;
  35612. /**
  35613. * Force relase the drag action by code.
  35614. */
  35615. releaseDrag(): void;
  35616. private _startDragRay;
  35617. private _lastPointerRay;
  35618. /**
  35619. * Simulates the start of a pointer drag event on the behavior
  35620. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35621. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35622. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35623. */
  35624. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35625. private _startDrag;
  35626. private _dragDelta;
  35627. private _moveDrag;
  35628. private _pickWithRayOnDragPlane;
  35629. private _pointA;
  35630. private _pointB;
  35631. private _pointC;
  35632. private _lineA;
  35633. private _lineB;
  35634. private _localAxis;
  35635. private _lookAt;
  35636. private _updateDragPlanePosition;
  35637. /**
  35638. * Detaches the behavior from the mesh
  35639. */
  35640. detach(): void;
  35641. }
  35642. }
  35643. declare module BABYLON {
  35644. /**
  35645. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35646. */
  35647. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35648. private _dragBehaviorA;
  35649. private _dragBehaviorB;
  35650. private _startDistance;
  35651. private _initialScale;
  35652. private _targetScale;
  35653. private _ownerNode;
  35654. private _sceneRenderObserver;
  35655. /**
  35656. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35657. */
  35658. constructor();
  35659. /**
  35660. * The name of the behavior
  35661. */
  35662. readonly name: string;
  35663. /**
  35664. * Initializes the behavior
  35665. */
  35666. init(): void;
  35667. private _getCurrentDistance;
  35668. /**
  35669. * Attaches the scale behavior the passed in mesh
  35670. * @param ownerNode The mesh that will be scaled around once attached
  35671. */
  35672. attach(ownerNode: Mesh): void;
  35673. /**
  35674. * Detaches the behavior from the mesh
  35675. */
  35676. detach(): void;
  35677. }
  35678. }
  35679. declare module BABYLON {
  35680. /**
  35681. * 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
  35682. */
  35683. export class SixDofDragBehavior implements Behavior<Mesh> {
  35684. private static _virtualScene;
  35685. private _ownerNode;
  35686. private _sceneRenderObserver;
  35687. private _scene;
  35688. private _targetPosition;
  35689. private _virtualOriginMesh;
  35690. private _virtualDragMesh;
  35691. private _pointerObserver;
  35692. private _moving;
  35693. private _startingOrientation;
  35694. /**
  35695. * 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)
  35696. */
  35697. private zDragFactor;
  35698. /**
  35699. * If the object should rotate to face the drag origin
  35700. */
  35701. rotateDraggedObject: boolean;
  35702. /**
  35703. * If the behavior is currently in a dragging state
  35704. */
  35705. dragging: boolean;
  35706. /**
  35707. * 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)
  35708. */
  35709. dragDeltaRatio: number;
  35710. /**
  35711. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35712. */
  35713. currentDraggingPointerID: number;
  35714. /**
  35715. * If camera controls should be detached during the drag
  35716. */
  35717. detachCameraControls: boolean;
  35718. /**
  35719. * Fires each time a drag starts
  35720. */
  35721. onDragStartObservable: Observable<{}>;
  35722. /**
  35723. * Fires each time a drag ends (eg. mouse release after drag)
  35724. */
  35725. onDragEndObservable: Observable<{}>;
  35726. /**
  35727. * 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
  35728. */
  35729. constructor();
  35730. /**
  35731. * The name of the behavior
  35732. */
  35733. readonly name: string;
  35734. /**
  35735. * Initializes the behavior
  35736. */
  35737. init(): void;
  35738. /**
  35739. * Attaches the scale behavior the passed in mesh
  35740. * @param ownerNode The mesh that will be scaled around once attached
  35741. */
  35742. attach(ownerNode: Mesh): void;
  35743. /**
  35744. * Detaches the behavior from the mesh
  35745. */
  35746. detach(): void;
  35747. }
  35748. }
  35749. declare module BABYLON {
  35750. /**
  35751. * Class used to apply inverse kinematics to bones
  35752. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35753. */
  35754. export class BoneIKController {
  35755. private static _tmpVecs;
  35756. private static _tmpQuat;
  35757. private static _tmpMats;
  35758. /**
  35759. * Gets or sets the target mesh
  35760. */
  35761. targetMesh: AbstractMesh;
  35762. /** Gets or sets the mesh used as pole */
  35763. poleTargetMesh: AbstractMesh;
  35764. /**
  35765. * Gets or sets the bone used as pole
  35766. */
  35767. poleTargetBone: Nullable<Bone>;
  35768. /**
  35769. * Gets or sets the target position
  35770. */
  35771. targetPosition: Vector3;
  35772. /**
  35773. * Gets or sets the pole target position
  35774. */
  35775. poleTargetPosition: Vector3;
  35776. /**
  35777. * Gets or sets the pole target local offset
  35778. */
  35779. poleTargetLocalOffset: Vector3;
  35780. /**
  35781. * Gets or sets the pole angle
  35782. */
  35783. poleAngle: number;
  35784. /**
  35785. * Gets or sets the mesh associated with the controller
  35786. */
  35787. mesh: AbstractMesh;
  35788. /**
  35789. * 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)
  35790. */
  35791. slerpAmount: number;
  35792. private _bone1Quat;
  35793. private _bone1Mat;
  35794. private _bone2Ang;
  35795. private _bone1;
  35796. private _bone2;
  35797. private _bone1Length;
  35798. private _bone2Length;
  35799. private _maxAngle;
  35800. private _maxReach;
  35801. private _rightHandedSystem;
  35802. private _bendAxis;
  35803. private _slerping;
  35804. private _adjustRoll;
  35805. /**
  35806. * Gets or sets maximum allowed angle
  35807. */
  35808. maxAngle: number;
  35809. /**
  35810. * Creates a new BoneIKController
  35811. * @param mesh defines the mesh to control
  35812. * @param bone defines the bone to control
  35813. * @param options defines options to set up the controller
  35814. */
  35815. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35816. targetMesh?: AbstractMesh;
  35817. poleTargetMesh?: AbstractMesh;
  35818. poleTargetBone?: Bone;
  35819. poleTargetLocalOffset?: Vector3;
  35820. poleAngle?: number;
  35821. bendAxis?: Vector3;
  35822. maxAngle?: number;
  35823. slerpAmount?: number;
  35824. });
  35825. private _setMaxAngle;
  35826. /**
  35827. * Force the controller to update the bones
  35828. */
  35829. update(): void;
  35830. }
  35831. }
  35832. declare module BABYLON {
  35833. /**
  35834. * Class used to make a bone look toward a point in space
  35835. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35836. */
  35837. export class BoneLookController {
  35838. private static _tmpVecs;
  35839. private static _tmpQuat;
  35840. private static _tmpMats;
  35841. /**
  35842. * The target Vector3 that the bone will look at
  35843. */
  35844. target: Vector3;
  35845. /**
  35846. * The mesh that the bone is attached to
  35847. */
  35848. mesh: AbstractMesh;
  35849. /**
  35850. * The bone that will be looking to the target
  35851. */
  35852. bone: Bone;
  35853. /**
  35854. * The up axis of the coordinate system that is used when the bone is rotated
  35855. */
  35856. upAxis: Vector3;
  35857. /**
  35858. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35859. */
  35860. upAxisSpace: Space;
  35861. /**
  35862. * Used to make an adjustment to the yaw of the bone
  35863. */
  35864. adjustYaw: number;
  35865. /**
  35866. * Used to make an adjustment to the pitch of the bone
  35867. */
  35868. adjustPitch: number;
  35869. /**
  35870. * Used to make an adjustment to the roll of the bone
  35871. */
  35872. adjustRoll: number;
  35873. /**
  35874. * 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)
  35875. */
  35876. slerpAmount: number;
  35877. private _minYaw;
  35878. private _maxYaw;
  35879. private _minPitch;
  35880. private _maxPitch;
  35881. private _minYawSin;
  35882. private _minYawCos;
  35883. private _maxYawSin;
  35884. private _maxYawCos;
  35885. private _midYawConstraint;
  35886. private _minPitchTan;
  35887. private _maxPitchTan;
  35888. private _boneQuat;
  35889. private _slerping;
  35890. private _transformYawPitch;
  35891. private _transformYawPitchInv;
  35892. private _firstFrameSkipped;
  35893. private _yawRange;
  35894. private _fowardAxis;
  35895. /**
  35896. * Gets or sets the minimum yaw angle that the bone can look to
  35897. */
  35898. minYaw: number;
  35899. /**
  35900. * Gets or sets the maximum yaw angle that the bone can look to
  35901. */
  35902. maxYaw: number;
  35903. /**
  35904. * Gets or sets the minimum pitch angle that the bone can look to
  35905. */
  35906. minPitch: number;
  35907. /**
  35908. * Gets or sets the maximum pitch angle that the bone can look to
  35909. */
  35910. maxPitch: number;
  35911. /**
  35912. * Create a BoneLookController
  35913. * @param mesh the mesh that the bone belongs to
  35914. * @param bone the bone that will be looking to the target
  35915. * @param target the target Vector3 to look at
  35916. * @param options optional settings:
  35917. * * maxYaw: the maximum angle the bone will yaw to
  35918. * * minYaw: the minimum angle the bone will yaw to
  35919. * * maxPitch: the maximum angle the bone will pitch to
  35920. * * minPitch: the minimum angle the bone will yaw to
  35921. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35922. * * upAxis: the up axis of the coordinate system
  35923. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35924. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35925. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35926. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35927. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35928. * * adjustRoll: used to make an adjustment to the roll of the bone
  35929. **/
  35930. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35931. maxYaw?: number;
  35932. minYaw?: number;
  35933. maxPitch?: number;
  35934. minPitch?: number;
  35935. slerpAmount?: number;
  35936. upAxis?: Vector3;
  35937. upAxisSpace?: Space;
  35938. yawAxis?: Vector3;
  35939. pitchAxis?: Vector3;
  35940. adjustYaw?: number;
  35941. adjustPitch?: number;
  35942. adjustRoll?: number;
  35943. });
  35944. /**
  35945. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35946. */
  35947. update(): void;
  35948. private _getAngleDiff;
  35949. private _getAngleBetween;
  35950. private _isAngleBetween;
  35951. }
  35952. }
  35953. declare module BABYLON {
  35954. /**
  35955. * Manage the gamepad inputs to control an arc rotate camera.
  35956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35957. */
  35958. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35959. /**
  35960. * Defines the camera the input is attached to.
  35961. */
  35962. camera: ArcRotateCamera;
  35963. /**
  35964. * Defines the gamepad the input is gathering event from.
  35965. */
  35966. gamepad: Nullable<Gamepad>;
  35967. /**
  35968. * Defines the gamepad rotation sensiblity.
  35969. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35970. */
  35971. gamepadRotationSensibility: number;
  35972. /**
  35973. * Defines the gamepad move sensiblity.
  35974. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35975. */
  35976. gamepadMoveSensibility: number;
  35977. private _onGamepadConnectedObserver;
  35978. private _onGamepadDisconnectedObserver;
  35979. /**
  35980. * Attach the input controls to a specific dom element to get the input from.
  35981. * @param element Defines the element the controls should be listened from
  35982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35983. */
  35984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35985. /**
  35986. * Detach the current controls from the specified dom element.
  35987. * @param element Defines the element to stop listening the inputs from
  35988. */
  35989. detachControl(element: Nullable<HTMLElement>): void;
  35990. /**
  35991. * Update the current camera state depending on the inputs that have been used this frame.
  35992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35993. */
  35994. checkInputs(): void;
  35995. /**
  35996. * Gets the class name of the current intput.
  35997. * @returns the class name
  35998. */
  35999. getClassName(): string;
  36000. /**
  36001. * Get the friendly name associated with the input class.
  36002. * @returns the input friendly name
  36003. */
  36004. getSimpleName(): string;
  36005. }
  36006. }
  36007. declare module BABYLON {
  36008. interface ArcRotateCameraInputsManager {
  36009. /**
  36010. * Add orientation input support to the input manager.
  36011. * @returns the current input manager
  36012. */
  36013. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36014. }
  36015. /**
  36016. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36018. */
  36019. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36020. /**
  36021. * Defines the camera the input is attached to.
  36022. */
  36023. camera: ArcRotateCamera;
  36024. /**
  36025. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36026. */
  36027. alphaCorrection: number;
  36028. /**
  36029. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36030. */
  36031. gammaCorrection: number;
  36032. private _alpha;
  36033. private _gamma;
  36034. private _dirty;
  36035. private _deviceOrientationHandler;
  36036. /**
  36037. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36038. */
  36039. constructor();
  36040. /**
  36041. * Attach the input controls to a specific dom element to get the input from.
  36042. * @param element Defines the element the controls should be listened from
  36043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36044. */
  36045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36046. /** @hidden */
  36047. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36048. /**
  36049. * Update the current camera state depending on the inputs that have been used this frame.
  36050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36051. */
  36052. checkInputs(): void;
  36053. /**
  36054. * Detach the current controls from the specified dom element.
  36055. * @param element Defines the element to stop listening the inputs from
  36056. */
  36057. detachControl(element: Nullable<HTMLElement>): void;
  36058. /**
  36059. * Gets the class name of the current intput.
  36060. * @returns the class name
  36061. */
  36062. getClassName(): string;
  36063. /**
  36064. * Get the friendly name associated with the input class.
  36065. * @returns the input friendly name
  36066. */
  36067. getSimpleName(): string;
  36068. }
  36069. }
  36070. declare module BABYLON {
  36071. /**
  36072. * Listen to mouse events to control the camera.
  36073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36074. */
  36075. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36076. /**
  36077. * Defines the camera the input is attached to.
  36078. */
  36079. camera: FlyCamera;
  36080. /**
  36081. * Defines if touch is enabled. (Default is true.)
  36082. */
  36083. touchEnabled: boolean;
  36084. /**
  36085. * Defines the buttons associated with the input to handle camera rotation.
  36086. */
  36087. buttons: number[];
  36088. /**
  36089. * Assign buttons for Yaw control.
  36090. */
  36091. buttonsYaw: number[];
  36092. /**
  36093. * Assign buttons for Pitch control.
  36094. */
  36095. buttonsPitch: number[];
  36096. /**
  36097. * Assign buttons for Roll control.
  36098. */
  36099. buttonsRoll: number[];
  36100. /**
  36101. * Detect if any button is being pressed while mouse is moved.
  36102. * -1 = Mouse locked.
  36103. * 0 = Left button.
  36104. * 1 = Middle Button.
  36105. * 2 = Right Button.
  36106. */
  36107. activeButton: number;
  36108. /**
  36109. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36110. * Higher values reduce its sensitivity.
  36111. */
  36112. angularSensibility: number;
  36113. private _mousemoveCallback;
  36114. private _observer;
  36115. private _rollObserver;
  36116. private previousPosition;
  36117. private noPreventDefault;
  36118. private element;
  36119. /**
  36120. * Listen to mouse events to control the camera.
  36121. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36123. */
  36124. constructor(touchEnabled?: boolean);
  36125. /**
  36126. * Attach the mouse control to the HTML DOM element.
  36127. * @param element Defines the element that listens to the input events.
  36128. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36129. */
  36130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36131. /**
  36132. * Detach the current controls from the specified dom element.
  36133. * @param element Defines the element to stop listening the inputs from
  36134. */
  36135. detachControl(element: Nullable<HTMLElement>): void;
  36136. /**
  36137. * Gets the class name of the current input.
  36138. * @returns the class name.
  36139. */
  36140. getClassName(): string;
  36141. /**
  36142. * Get the friendly name associated with the input class.
  36143. * @returns the input's friendly name.
  36144. */
  36145. getSimpleName(): string;
  36146. private _pointerInput;
  36147. private _onMouseMove;
  36148. /**
  36149. * Rotate camera by mouse offset.
  36150. */
  36151. private rotateCamera;
  36152. }
  36153. }
  36154. declare module BABYLON {
  36155. /**
  36156. * Default Inputs manager for the FlyCamera.
  36157. * It groups all the default supported inputs for ease of use.
  36158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36159. */
  36160. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36161. /**
  36162. * Instantiates a new FlyCameraInputsManager.
  36163. * @param camera Defines the camera the inputs belong to.
  36164. */
  36165. constructor(camera: FlyCamera);
  36166. /**
  36167. * Add keyboard input support to the input manager.
  36168. * @returns the new FlyCameraKeyboardMoveInput().
  36169. */
  36170. addKeyboard(): FlyCameraInputsManager;
  36171. /**
  36172. * Add mouse input support to the input manager.
  36173. * @param touchEnabled Enable touch screen support.
  36174. * @returns the new FlyCameraMouseInput().
  36175. */
  36176. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36177. }
  36178. }
  36179. declare module BABYLON {
  36180. /**
  36181. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36182. * such as in a 3D Space Shooter or a Flight Simulator.
  36183. */
  36184. export class FlyCamera extends TargetCamera {
  36185. /**
  36186. * Define the collision ellipsoid of the camera.
  36187. * This is helpful for simulating a camera body, like a player's body.
  36188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36189. */
  36190. ellipsoid: Vector3;
  36191. /**
  36192. * Define an offset for the position of the ellipsoid around the camera.
  36193. * This can be helpful if the camera is attached away from the player's body center,
  36194. * such as at its head.
  36195. */
  36196. ellipsoidOffset: Vector3;
  36197. /**
  36198. * Enable or disable collisions of the camera with the rest of the scene objects.
  36199. */
  36200. checkCollisions: boolean;
  36201. /**
  36202. * Enable or disable gravity on the camera.
  36203. */
  36204. applyGravity: boolean;
  36205. /**
  36206. * Define the current direction the camera is moving to.
  36207. */
  36208. cameraDirection: Vector3;
  36209. /**
  36210. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36211. * This overrides and empties cameraRotation.
  36212. */
  36213. rotationQuaternion: Quaternion;
  36214. /**
  36215. * Track Roll to maintain the wanted Rolling when looking around.
  36216. */
  36217. _trackRoll: number;
  36218. /**
  36219. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36220. */
  36221. rollCorrect: number;
  36222. /**
  36223. * Mimic a banked turn, Rolling the camera when Yawing.
  36224. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36225. */
  36226. bankedTurn: boolean;
  36227. /**
  36228. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36229. */
  36230. bankedTurnLimit: number;
  36231. /**
  36232. * Value of 0 disables the banked Roll.
  36233. * Value of 1 is equal to the Yaw angle in radians.
  36234. */
  36235. bankedTurnMultiplier: number;
  36236. /**
  36237. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36238. */
  36239. inputs: FlyCameraInputsManager;
  36240. /**
  36241. * Gets the input sensibility for mouse input.
  36242. * Higher values reduce sensitivity.
  36243. */
  36244. /**
  36245. * Sets the input sensibility for a mouse input.
  36246. * Higher values reduce sensitivity.
  36247. */
  36248. angularSensibility: number;
  36249. /**
  36250. * Get the keys for camera movement forward.
  36251. */
  36252. /**
  36253. * Set the keys for camera movement forward.
  36254. */
  36255. keysForward: number[];
  36256. /**
  36257. * Get the keys for camera movement backward.
  36258. */
  36259. keysBackward: number[];
  36260. /**
  36261. * Get the keys for camera movement up.
  36262. */
  36263. /**
  36264. * Set the keys for camera movement up.
  36265. */
  36266. keysUp: number[];
  36267. /**
  36268. * Get the keys for camera movement down.
  36269. */
  36270. /**
  36271. * Set the keys for camera movement down.
  36272. */
  36273. keysDown: number[];
  36274. /**
  36275. * Get the keys for camera movement left.
  36276. */
  36277. /**
  36278. * Set the keys for camera movement left.
  36279. */
  36280. keysLeft: number[];
  36281. /**
  36282. * Set the keys for camera movement right.
  36283. */
  36284. /**
  36285. * Set the keys for camera movement right.
  36286. */
  36287. keysRight: number[];
  36288. /**
  36289. * Event raised when the camera collides with a mesh in the scene.
  36290. */
  36291. onCollide: (collidedMesh: AbstractMesh) => void;
  36292. private _collider;
  36293. private _needMoveForGravity;
  36294. private _oldPosition;
  36295. private _diffPosition;
  36296. private _newPosition;
  36297. /** @hidden */
  36298. _localDirection: Vector3;
  36299. /** @hidden */
  36300. _transformedDirection: Vector3;
  36301. /**
  36302. * Instantiates a FlyCamera.
  36303. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36304. * such as in a 3D Space Shooter or a Flight Simulator.
  36305. * @param name Define the name of the camera in the scene.
  36306. * @param position Define the starting position of the camera in the scene.
  36307. * @param scene Define the scene the camera belongs to.
  36308. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36309. */
  36310. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36311. /**
  36312. * Attach a control to the HTML DOM element.
  36313. * @param element Defines the element that listens to the input events.
  36314. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36315. */
  36316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36317. /**
  36318. * Detach a control from the HTML DOM element.
  36319. * The camera will stop reacting to that input.
  36320. * @param element Defines the element that listens to the input events.
  36321. */
  36322. detachControl(element: HTMLElement): void;
  36323. private _collisionMask;
  36324. /**
  36325. * Get the mask that the camera ignores in collision events.
  36326. */
  36327. /**
  36328. * Set the mask that the camera ignores in collision events.
  36329. */
  36330. collisionMask: number;
  36331. /** @hidden */
  36332. _collideWithWorld(displacement: Vector3): void;
  36333. /** @hidden */
  36334. private _onCollisionPositionChange;
  36335. /** @hidden */
  36336. _checkInputs(): void;
  36337. /** @hidden */
  36338. _decideIfNeedsToMove(): boolean;
  36339. /** @hidden */
  36340. _updatePosition(): void;
  36341. /**
  36342. * Restore the Roll to its target value at the rate specified.
  36343. * @param rate - Higher means slower restoring.
  36344. * @hidden
  36345. */
  36346. restoreRoll(rate: number): void;
  36347. /**
  36348. * Destroy the camera and release the current resources held by it.
  36349. */
  36350. dispose(): void;
  36351. /**
  36352. * Get the current object class name.
  36353. * @returns the class name.
  36354. */
  36355. getClassName(): string;
  36356. }
  36357. }
  36358. declare module BABYLON {
  36359. /**
  36360. * Listen to keyboard events to control the camera.
  36361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36362. */
  36363. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36364. /**
  36365. * Defines the camera the input is attached to.
  36366. */
  36367. camera: FlyCamera;
  36368. /**
  36369. * The list of keyboard keys used to control the forward move of the camera.
  36370. */
  36371. keysForward: number[];
  36372. /**
  36373. * The list of keyboard keys used to control the backward move of the camera.
  36374. */
  36375. keysBackward: number[];
  36376. /**
  36377. * The list of keyboard keys used to control the forward move of the camera.
  36378. */
  36379. keysUp: number[];
  36380. /**
  36381. * The list of keyboard keys used to control the backward move of the camera.
  36382. */
  36383. keysDown: number[];
  36384. /**
  36385. * The list of keyboard keys used to control the right strafe move of the camera.
  36386. */
  36387. keysRight: number[];
  36388. /**
  36389. * The list of keyboard keys used to control the left strafe move of the camera.
  36390. */
  36391. keysLeft: number[];
  36392. private _keys;
  36393. private _onCanvasBlurObserver;
  36394. private _onKeyboardObserver;
  36395. private _engine;
  36396. private _scene;
  36397. /**
  36398. * Attach the input controls to a specific dom element to get the input from.
  36399. * @param element Defines the element the controls should be listened from
  36400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36401. */
  36402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36403. /**
  36404. * Detach the current controls from the specified dom element.
  36405. * @param element Defines the element to stop listening the inputs from
  36406. */
  36407. detachControl(element: Nullable<HTMLElement>): void;
  36408. /**
  36409. * Gets the class name of the current intput.
  36410. * @returns the class name
  36411. */
  36412. getClassName(): string;
  36413. /** @hidden */
  36414. _onLostFocus(e: FocusEvent): void;
  36415. /**
  36416. * Get the friendly name associated with the input class.
  36417. * @returns the input friendly name
  36418. */
  36419. getSimpleName(): string;
  36420. /**
  36421. * Update the current camera state depending on the inputs that have been used this frame.
  36422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36423. */
  36424. checkInputs(): void;
  36425. }
  36426. }
  36427. declare module BABYLON {
  36428. /**
  36429. * Manage the mouse wheel inputs to control a follow camera.
  36430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36431. */
  36432. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36433. /**
  36434. * Defines the camera the input is attached to.
  36435. */
  36436. camera: FollowCamera;
  36437. /**
  36438. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36439. */
  36440. axisControlRadius: boolean;
  36441. /**
  36442. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36443. */
  36444. axisControlHeight: boolean;
  36445. /**
  36446. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36447. */
  36448. axisControlRotation: boolean;
  36449. /**
  36450. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36451. * relation to mouseWheel events.
  36452. */
  36453. wheelPrecision: number;
  36454. /**
  36455. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36456. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36457. */
  36458. wheelDeltaPercentage: number;
  36459. private _wheel;
  36460. private _observer;
  36461. /**
  36462. * Attach the input controls to a specific dom element to get the input from.
  36463. * @param element Defines the element the controls should be listened from
  36464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36465. */
  36466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36467. /**
  36468. * Detach the current controls from the specified dom element.
  36469. * @param element Defines the element to stop listening the inputs from
  36470. */
  36471. detachControl(element: Nullable<HTMLElement>): void;
  36472. /**
  36473. * Gets the class name of the current intput.
  36474. * @returns the class name
  36475. */
  36476. getClassName(): string;
  36477. /**
  36478. * Get the friendly name associated with the input class.
  36479. * @returns the input friendly name
  36480. */
  36481. getSimpleName(): string;
  36482. }
  36483. }
  36484. declare module BABYLON {
  36485. /**
  36486. * Manage the pointers inputs to control an follow camera.
  36487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36488. */
  36489. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36490. /**
  36491. * Defines the camera the input is attached to.
  36492. */
  36493. camera: FollowCamera;
  36494. /**
  36495. * Gets the class name of the current input.
  36496. * @returns the class name
  36497. */
  36498. getClassName(): string;
  36499. /**
  36500. * Defines the pointer angular sensibility along the X axis or how fast is
  36501. * the camera rotating.
  36502. * A negative number will reverse the axis direction.
  36503. */
  36504. angularSensibilityX: number;
  36505. /**
  36506. * Defines the pointer angular sensibility along the Y axis or how fast is
  36507. * the camera rotating.
  36508. * A negative number will reverse the axis direction.
  36509. */
  36510. angularSensibilityY: number;
  36511. /**
  36512. * Defines the pointer pinch precision or how fast is the camera zooming.
  36513. * A negative number will reverse the axis direction.
  36514. */
  36515. pinchPrecision: number;
  36516. /**
  36517. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36518. * from 0.
  36519. * It defines the percentage of current camera.radius to use as delta when
  36520. * pinch zoom is used.
  36521. */
  36522. pinchDeltaPercentage: number;
  36523. /**
  36524. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36525. */
  36526. axisXControlRadius: boolean;
  36527. /**
  36528. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36529. */
  36530. axisXControlHeight: boolean;
  36531. /**
  36532. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36533. */
  36534. axisXControlRotation: boolean;
  36535. /**
  36536. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36537. */
  36538. axisYControlRadius: boolean;
  36539. /**
  36540. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36541. */
  36542. axisYControlHeight: boolean;
  36543. /**
  36544. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36545. */
  36546. axisYControlRotation: boolean;
  36547. /**
  36548. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36549. */
  36550. axisPinchControlRadius: boolean;
  36551. /**
  36552. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36553. */
  36554. axisPinchControlHeight: boolean;
  36555. /**
  36556. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36557. */
  36558. axisPinchControlRotation: boolean;
  36559. /**
  36560. * Log error messages if basic misconfiguration has occurred.
  36561. */
  36562. warningEnable: boolean;
  36563. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36564. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36565. private _warningCounter;
  36566. private _warning;
  36567. }
  36568. }
  36569. declare module BABYLON {
  36570. /**
  36571. * Default Inputs manager for the FollowCamera.
  36572. * It groups all the default supported inputs for ease of use.
  36573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36574. */
  36575. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36576. /**
  36577. * Instantiates a new FollowCameraInputsManager.
  36578. * @param camera Defines the camera the inputs belong to
  36579. */
  36580. constructor(camera: FollowCamera);
  36581. /**
  36582. * Add keyboard input support to the input manager.
  36583. * @returns the current input manager
  36584. */
  36585. addKeyboard(): FollowCameraInputsManager;
  36586. /**
  36587. * Add mouse wheel input support to the input manager.
  36588. * @returns the current input manager
  36589. */
  36590. addMouseWheel(): FollowCameraInputsManager;
  36591. /**
  36592. * Add pointers input support to the input manager.
  36593. * @returns the current input manager
  36594. */
  36595. addPointers(): FollowCameraInputsManager;
  36596. /**
  36597. * Add orientation input support to the input manager.
  36598. * @returns the current input manager
  36599. */
  36600. addVRDeviceOrientation(): FollowCameraInputsManager;
  36601. }
  36602. }
  36603. declare module BABYLON {
  36604. /**
  36605. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36606. * an arc rotate version arcFollowCamera are available.
  36607. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36608. */
  36609. export class FollowCamera extends TargetCamera {
  36610. /**
  36611. * Distance the follow camera should follow an object at
  36612. */
  36613. radius: number;
  36614. /**
  36615. * Minimum allowed distance of the camera to the axis of rotation
  36616. * (The camera can not get closer).
  36617. * This can help limiting how the Camera is able to move in the scene.
  36618. */
  36619. lowerRadiusLimit: Nullable<number>;
  36620. /**
  36621. * Maximum allowed distance of the camera to the axis of rotation
  36622. * (The camera can not get further).
  36623. * This can help limiting how the Camera is able to move in the scene.
  36624. */
  36625. upperRadiusLimit: Nullable<number>;
  36626. /**
  36627. * Define a rotation offset between the camera and the object it follows
  36628. */
  36629. rotationOffset: number;
  36630. /**
  36631. * Minimum allowed angle to camera position relative to target object.
  36632. * This can help limiting how the Camera is able to move in the scene.
  36633. */
  36634. lowerRotationOffsetLimit: Nullable<number>;
  36635. /**
  36636. * Maximum allowed angle to camera position relative to target object.
  36637. * This can help limiting how the Camera is able to move in the scene.
  36638. */
  36639. upperRotationOffsetLimit: Nullable<number>;
  36640. /**
  36641. * Define a height offset between the camera and the object it follows.
  36642. * It can help following an object from the top (like a car chaing a plane)
  36643. */
  36644. heightOffset: number;
  36645. /**
  36646. * Minimum allowed height of camera position relative to target object.
  36647. * This can help limiting how the Camera is able to move in the scene.
  36648. */
  36649. lowerHeightOffsetLimit: Nullable<number>;
  36650. /**
  36651. * Maximum allowed height of camera position relative to target object.
  36652. * This can help limiting how the Camera is able to move in the scene.
  36653. */
  36654. upperHeightOffsetLimit: Nullable<number>;
  36655. /**
  36656. * Define how fast the camera can accelerate to follow it s target.
  36657. */
  36658. cameraAcceleration: number;
  36659. /**
  36660. * Define the speed limit of the camera following an object.
  36661. */
  36662. maxCameraSpeed: number;
  36663. /**
  36664. * Define the target of the camera.
  36665. */
  36666. lockedTarget: Nullable<AbstractMesh>;
  36667. /**
  36668. * Defines the input associated with the camera.
  36669. */
  36670. inputs: FollowCameraInputsManager;
  36671. /**
  36672. * Instantiates the follow camera.
  36673. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36674. * @param name Define the name of the camera in the scene
  36675. * @param position Define the position of the camera
  36676. * @param scene Define the scene the camera belong to
  36677. * @param lockedTarget Define the target of the camera
  36678. */
  36679. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36680. private _follow;
  36681. /**
  36682. * Attached controls to the current camera.
  36683. * @param element Defines the element the controls should be listened from
  36684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36685. */
  36686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36687. /**
  36688. * Detach the current controls from the camera.
  36689. * The camera will stop reacting to inputs.
  36690. * @param element Defines the element to stop listening the inputs from
  36691. */
  36692. detachControl(element: HTMLElement): void;
  36693. /** @hidden */
  36694. _checkInputs(): void;
  36695. private _checkLimits;
  36696. /**
  36697. * Gets the camera class name.
  36698. * @returns the class name
  36699. */
  36700. getClassName(): string;
  36701. }
  36702. /**
  36703. * Arc Rotate version of the follow camera.
  36704. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36705. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36706. */
  36707. export class ArcFollowCamera extends TargetCamera {
  36708. /** The longitudinal angle of the camera */
  36709. alpha: number;
  36710. /** The latitudinal angle of the camera */
  36711. beta: number;
  36712. /** The radius of the camera from its target */
  36713. radius: number;
  36714. /** Define the camera target (the messh it should follow) */
  36715. target: Nullable<AbstractMesh>;
  36716. private _cartesianCoordinates;
  36717. /**
  36718. * Instantiates a new ArcFollowCamera
  36719. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36720. * @param name Define the name of the camera
  36721. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36722. * @param beta Define the rotation angle of the camera around the elevation axis
  36723. * @param radius Define the radius of the camera from its target point
  36724. * @param target Define the target of the camera
  36725. * @param scene Define the scene the camera belongs to
  36726. */
  36727. constructor(name: string,
  36728. /** The longitudinal angle of the camera */
  36729. alpha: number,
  36730. /** The latitudinal angle of the camera */
  36731. beta: number,
  36732. /** The radius of the camera from its target */
  36733. radius: number,
  36734. /** Define the camera target (the messh it should follow) */
  36735. target: Nullable<AbstractMesh>, scene: Scene);
  36736. private _follow;
  36737. /** @hidden */
  36738. _checkInputs(): void;
  36739. /**
  36740. * Returns the class name of the object.
  36741. * It is mostly used internally for serialization purposes.
  36742. */
  36743. getClassName(): string;
  36744. }
  36745. }
  36746. declare module BABYLON {
  36747. /**
  36748. * Manage the keyboard inputs to control the movement of a follow camera.
  36749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36750. */
  36751. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36752. /**
  36753. * Defines the camera the input is attached to.
  36754. */
  36755. camera: FollowCamera;
  36756. /**
  36757. * Defines the list of key codes associated with the up action (increase heightOffset)
  36758. */
  36759. keysHeightOffsetIncr: number[];
  36760. /**
  36761. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36762. */
  36763. keysHeightOffsetDecr: number[];
  36764. /**
  36765. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36766. */
  36767. keysHeightOffsetModifierAlt: boolean;
  36768. /**
  36769. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36770. */
  36771. keysHeightOffsetModifierCtrl: boolean;
  36772. /**
  36773. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36774. */
  36775. keysHeightOffsetModifierShift: boolean;
  36776. /**
  36777. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36778. */
  36779. keysRotationOffsetIncr: number[];
  36780. /**
  36781. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36782. */
  36783. keysRotationOffsetDecr: number[];
  36784. /**
  36785. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36786. */
  36787. keysRotationOffsetModifierAlt: boolean;
  36788. /**
  36789. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36790. */
  36791. keysRotationOffsetModifierCtrl: boolean;
  36792. /**
  36793. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36794. */
  36795. keysRotationOffsetModifierShift: boolean;
  36796. /**
  36797. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36798. */
  36799. keysRadiusIncr: number[];
  36800. /**
  36801. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36802. */
  36803. keysRadiusDecr: number[];
  36804. /**
  36805. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36806. */
  36807. keysRadiusModifierAlt: boolean;
  36808. /**
  36809. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36810. */
  36811. keysRadiusModifierCtrl: boolean;
  36812. /**
  36813. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36814. */
  36815. keysRadiusModifierShift: boolean;
  36816. /**
  36817. * Defines the rate of change of heightOffset.
  36818. */
  36819. heightSensibility: number;
  36820. /**
  36821. * Defines the rate of change of rotationOffset.
  36822. */
  36823. rotationSensibility: number;
  36824. /**
  36825. * Defines the rate of change of radius.
  36826. */
  36827. radiusSensibility: number;
  36828. private _keys;
  36829. private _ctrlPressed;
  36830. private _altPressed;
  36831. private _shiftPressed;
  36832. private _onCanvasBlurObserver;
  36833. private _onKeyboardObserver;
  36834. private _engine;
  36835. private _scene;
  36836. /**
  36837. * Attach the input controls to a specific dom element to get the input from.
  36838. * @param element Defines the element the controls should be listened from
  36839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36840. */
  36841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36842. /**
  36843. * Detach the current controls from the specified dom element.
  36844. * @param element Defines the element to stop listening the inputs from
  36845. */
  36846. detachControl(element: Nullable<HTMLElement>): void;
  36847. /**
  36848. * Update the current camera state depending on the inputs that have been used this frame.
  36849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36850. */
  36851. checkInputs(): void;
  36852. /**
  36853. * Gets the class name of the current input.
  36854. * @returns the class name
  36855. */
  36856. getClassName(): string;
  36857. /**
  36858. * Get the friendly name associated with the input class.
  36859. * @returns the input friendly name
  36860. */
  36861. getSimpleName(): string;
  36862. /**
  36863. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36864. * allow modification of the heightOffset value.
  36865. */
  36866. private _modifierHeightOffset;
  36867. /**
  36868. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36869. * allow modification of the rotationOffset value.
  36870. */
  36871. private _modifierRotationOffset;
  36872. /**
  36873. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36874. * allow modification of the radius value.
  36875. */
  36876. private _modifierRadius;
  36877. }
  36878. }
  36879. declare module BABYLON {
  36880. interface FreeCameraInputsManager {
  36881. /**
  36882. * @hidden
  36883. */
  36884. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36885. /**
  36886. * Add orientation input support to the input manager.
  36887. * @returns the current input manager
  36888. */
  36889. addDeviceOrientation(): FreeCameraInputsManager;
  36890. }
  36891. /**
  36892. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36893. * Screen rotation is taken into account.
  36894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36895. */
  36896. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36897. private _camera;
  36898. private _screenOrientationAngle;
  36899. private _constantTranform;
  36900. private _screenQuaternion;
  36901. private _alpha;
  36902. private _beta;
  36903. private _gamma;
  36904. /**
  36905. * @hidden
  36906. */
  36907. _onDeviceOrientationChangedObservable: Observable<void>;
  36908. /**
  36909. * Instantiates a new input
  36910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36911. */
  36912. constructor();
  36913. /**
  36914. * Define the camera controlled by the input.
  36915. */
  36916. camera: FreeCamera;
  36917. /**
  36918. * Attach the input controls to a specific dom element to get the input from.
  36919. * @param element Defines the element the controls should be listened from
  36920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36921. */
  36922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36923. private _orientationChanged;
  36924. private _deviceOrientation;
  36925. /**
  36926. * Detach the current controls from the specified dom element.
  36927. * @param element Defines the element to stop listening the inputs from
  36928. */
  36929. detachControl(element: Nullable<HTMLElement>): void;
  36930. /**
  36931. * Update the current camera state depending on the inputs that have been used this frame.
  36932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36933. */
  36934. checkInputs(): void;
  36935. /**
  36936. * Gets the class name of the current intput.
  36937. * @returns the class name
  36938. */
  36939. getClassName(): string;
  36940. /**
  36941. * Get the friendly name associated with the input class.
  36942. * @returns the input friendly name
  36943. */
  36944. getSimpleName(): string;
  36945. }
  36946. }
  36947. declare module BABYLON {
  36948. /**
  36949. * Manage the gamepad inputs to control a free camera.
  36950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36951. */
  36952. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36953. /**
  36954. * Define the camera the input is attached to.
  36955. */
  36956. camera: FreeCamera;
  36957. /**
  36958. * Define the Gamepad controlling the input
  36959. */
  36960. gamepad: Nullable<Gamepad>;
  36961. /**
  36962. * Defines the gamepad rotation sensiblity.
  36963. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36964. */
  36965. gamepadAngularSensibility: number;
  36966. /**
  36967. * Defines the gamepad move sensiblity.
  36968. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36969. */
  36970. gamepadMoveSensibility: number;
  36971. private _onGamepadConnectedObserver;
  36972. private _onGamepadDisconnectedObserver;
  36973. private _cameraTransform;
  36974. private _deltaTransform;
  36975. private _vector3;
  36976. private _vector2;
  36977. /**
  36978. * Attach the input controls to a specific dom element to get the input from.
  36979. * @param element Defines the element the controls should be listened from
  36980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36981. */
  36982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36983. /**
  36984. * Detach the current controls from the specified dom element.
  36985. * @param element Defines the element to stop listening the inputs from
  36986. */
  36987. detachControl(element: Nullable<HTMLElement>): void;
  36988. /**
  36989. * Update the current camera state depending on the inputs that have been used this frame.
  36990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36991. */
  36992. checkInputs(): void;
  36993. /**
  36994. * Gets the class name of the current intput.
  36995. * @returns the class name
  36996. */
  36997. getClassName(): string;
  36998. /**
  36999. * Get the friendly name associated with the input class.
  37000. * @returns the input friendly name
  37001. */
  37002. getSimpleName(): string;
  37003. }
  37004. }
  37005. declare module BABYLON {
  37006. /**
  37007. * Defines the potential axis of a Joystick
  37008. */
  37009. export enum JoystickAxis {
  37010. /** X axis */
  37011. X = 0,
  37012. /** Y axis */
  37013. Y = 1,
  37014. /** Z axis */
  37015. Z = 2
  37016. }
  37017. /**
  37018. * Class used to define virtual joystick (used in touch mode)
  37019. */
  37020. export class VirtualJoystick {
  37021. /**
  37022. * Gets or sets a boolean indicating that left and right values must be inverted
  37023. */
  37024. reverseLeftRight: boolean;
  37025. /**
  37026. * Gets or sets a boolean indicating that up and down values must be inverted
  37027. */
  37028. reverseUpDown: boolean;
  37029. /**
  37030. * Gets the offset value for the position (ie. the change of the position value)
  37031. */
  37032. deltaPosition: Vector3;
  37033. /**
  37034. * Gets a boolean indicating if the virtual joystick was pressed
  37035. */
  37036. pressed: boolean;
  37037. /**
  37038. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37039. */
  37040. static Canvas: Nullable<HTMLCanvasElement>;
  37041. private static _globalJoystickIndex;
  37042. private static vjCanvasContext;
  37043. private static vjCanvasWidth;
  37044. private static vjCanvasHeight;
  37045. private static halfWidth;
  37046. private _action;
  37047. private _axisTargetedByLeftAndRight;
  37048. private _axisTargetedByUpAndDown;
  37049. private _joystickSensibility;
  37050. private _inversedSensibility;
  37051. private _joystickPointerID;
  37052. private _joystickColor;
  37053. private _joystickPointerPos;
  37054. private _joystickPreviousPointerPos;
  37055. private _joystickPointerStartPos;
  37056. private _deltaJoystickVector;
  37057. private _leftJoystick;
  37058. private _touches;
  37059. private _onPointerDownHandlerRef;
  37060. private _onPointerMoveHandlerRef;
  37061. private _onPointerUpHandlerRef;
  37062. private _onResize;
  37063. /**
  37064. * Creates a new virtual joystick
  37065. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37066. */
  37067. constructor(leftJoystick?: boolean);
  37068. /**
  37069. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37070. * @param newJoystickSensibility defines the new sensibility
  37071. */
  37072. setJoystickSensibility(newJoystickSensibility: number): void;
  37073. private _onPointerDown;
  37074. private _onPointerMove;
  37075. private _onPointerUp;
  37076. /**
  37077. * Change the color of the virtual joystick
  37078. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37079. */
  37080. setJoystickColor(newColor: string): void;
  37081. /**
  37082. * Defines a callback to call when the joystick is touched
  37083. * @param action defines the callback
  37084. */
  37085. setActionOnTouch(action: () => any): void;
  37086. /**
  37087. * Defines which axis you'd like to control for left & right
  37088. * @param axis defines the axis to use
  37089. */
  37090. setAxisForLeftRight(axis: JoystickAxis): void;
  37091. /**
  37092. * Defines which axis you'd like to control for up & down
  37093. * @param axis defines the axis to use
  37094. */
  37095. setAxisForUpDown(axis: JoystickAxis): void;
  37096. private _drawVirtualJoystick;
  37097. /**
  37098. * Release internal HTML canvas
  37099. */
  37100. releaseCanvas(): void;
  37101. }
  37102. }
  37103. declare module BABYLON {
  37104. interface FreeCameraInputsManager {
  37105. /**
  37106. * Add virtual joystick input support to the input manager.
  37107. * @returns the current input manager
  37108. */
  37109. addVirtualJoystick(): FreeCameraInputsManager;
  37110. }
  37111. /**
  37112. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37114. */
  37115. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37116. /**
  37117. * Defines the camera the input is attached to.
  37118. */
  37119. camera: FreeCamera;
  37120. private _leftjoystick;
  37121. private _rightjoystick;
  37122. /**
  37123. * Gets the left stick of the virtual joystick.
  37124. * @returns The virtual Joystick
  37125. */
  37126. getLeftJoystick(): VirtualJoystick;
  37127. /**
  37128. * Gets the right stick of the virtual joystick.
  37129. * @returns The virtual Joystick
  37130. */
  37131. getRightJoystick(): VirtualJoystick;
  37132. /**
  37133. * Update the current camera state depending on the inputs that have been used this frame.
  37134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37135. */
  37136. checkInputs(): void;
  37137. /**
  37138. * Attach the input controls to a specific dom element to get the input from.
  37139. * @param element Defines the element the controls should be listened from
  37140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37141. */
  37142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37143. /**
  37144. * Detach the current controls from the specified dom element.
  37145. * @param element Defines the element to stop listening the inputs from
  37146. */
  37147. detachControl(element: Nullable<HTMLElement>): void;
  37148. /**
  37149. * Gets the class name of the current intput.
  37150. * @returns the class name
  37151. */
  37152. getClassName(): string;
  37153. /**
  37154. * Get the friendly name associated with the input class.
  37155. * @returns the input friendly name
  37156. */
  37157. getSimpleName(): string;
  37158. }
  37159. }
  37160. declare module BABYLON {
  37161. /**
  37162. * This represents a FPS type of camera controlled by touch.
  37163. * This is like a universal camera minus the Gamepad controls.
  37164. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37165. */
  37166. export class TouchCamera extends FreeCamera {
  37167. /**
  37168. * Defines the touch sensibility for rotation.
  37169. * The higher the faster.
  37170. */
  37171. touchAngularSensibility: number;
  37172. /**
  37173. * Defines the touch sensibility for move.
  37174. * The higher the faster.
  37175. */
  37176. touchMoveSensibility: number;
  37177. /**
  37178. * Instantiates a new touch camera.
  37179. * This represents a FPS type of camera controlled by touch.
  37180. * This is like a universal camera minus the Gamepad controls.
  37181. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37182. * @param name Define the name of the camera in the scene
  37183. * @param position Define the start position of the camera in the scene
  37184. * @param scene Define the scene the camera belongs to
  37185. */
  37186. constructor(name: string, position: Vector3, scene: Scene);
  37187. /**
  37188. * Gets the current object class name.
  37189. * @return the class name
  37190. */
  37191. getClassName(): string;
  37192. /** @hidden */
  37193. _setupInputs(): void;
  37194. }
  37195. }
  37196. declare module BABYLON {
  37197. /**
  37198. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37199. * being tilted forward or back and left or right.
  37200. */
  37201. export class DeviceOrientationCamera extends FreeCamera {
  37202. private _initialQuaternion;
  37203. private _quaternionCache;
  37204. private _tmpDragQuaternion;
  37205. /**
  37206. * Creates a new device orientation camera
  37207. * @param name The name of the camera
  37208. * @param position The start position camera
  37209. * @param scene The scene the camera belongs to
  37210. */
  37211. constructor(name: string, position: Vector3, scene: Scene);
  37212. /**
  37213. * @hidden
  37214. * Disabled pointer input on first orientation sensor update (Default: true)
  37215. */
  37216. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37217. private _dragFactor;
  37218. /**
  37219. * Enabled turning on the y axis when the orientation sensor is active
  37220. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37221. */
  37222. enableHorizontalDragging(dragFactor?: number): void;
  37223. /**
  37224. * Gets the current instance class name ("DeviceOrientationCamera").
  37225. * This helps avoiding instanceof at run time.
  37226. * @returns the class name
  37227. */
  37228. getClassName(): string;
  37229. /**
  37230. * @hidden
  37231. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37232. */
  37233. _checkInputs(): void;
  37234. /**
  37235. * Reset the camera to its default orientation on the specified axis only.
  37236. * @param axis The axis to reset
  37237. */
  37238. resetToCurrentRotation(axis?: Axis): void;
  37239. }
  37240. }
  37241. declare module BABYLON {
  37242. /**
  37243. * 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,
  37244. * which still works and will still be found in many Playgrounds.
  37245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37246. */
  37247. export class UniversalCamera extends TouchCamera {
  37248. /**
  37249. * Defines the gamepad rotation sensiblity.
  37250. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37251. */
  37252. gamepadAngularSensibility: number;
  37253. /**
  37254. * Defines the gamepad move sensiblity.
  37255. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37256. */
  37257. gamepadMoveSensibility: number;
  37258. /**
  37259. * 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,
  37260. * which still works and will still be found in many Playgrounds.
  37261. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37262. * @param name Define the name of the camera in the scene
  37263. * @param position Define the start position of the camera in the scene
  37264. * @param scene Define the scene the camera belongs to
  37265. */
  37266. constructor(name: string, position: Vector3, scene: Scene);
  37267. /**
  37268. * Gets the current object class name.
  37269. * @return the class name
  37270. */
  37271. getClassName(): string;
  37272. }
  37273. }
  37274. declare module BABYLON {
  37275. /**
  37276. * This represents a FPS type of camera. This is only here for back compat purpose.
  37277. * Please use the UniversalCamera instead as both are identical.
  37278. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37279. */
  37280. export class GamepadCamera extends UniversalCamera {
  37281. /**
  37282. * Instantiates a new Gamepad Camera
  37283. * This represents a FPS type of camera. This is only here for back compat purpose.
  37284. * Please use the UniversalCamera instead as both are identical.
  37285. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37286. * @param name Define the name of the camera in the scene
  37287. * @param position Define the start position of the camera in the scene
  37288. * @param scene Define the scene the camera belongs to
  37289. */
  37290. constructor(name: string, position: Vector3, scene: Scene);
  37291. /**
  37292. * Gets the current object class name.
  37293. * @return the class name
  37294. */
  37295. getClassName(): string;
  37296. }
  37297. }
  37298. declare module BABYLON {
  37299. /** @hidden */
  37300. export var passPixelShader: {
  37301. name: string;
  37302. shader: string;
  37303. };
  37304. }
  37305. declare module BABYLON {
  37306. /** @hidden */
  37307. export var passCubePixelShader: {
  37308. name: string;
  37309. shader: string;
  37310. };
  37311. }
  37312. declare module BABYLON {
  37313. /**
  37314. * PassPostProcess which produces an output the same as it's input
  37315. */
  37316. export class PassPostProcess extends PostProcess {
  37317. /**
  37318. * Creates the PassPostProcess
  37319. * @param name The name of the effect.
  37320. * @param options The required width/height ratio to downsize to before computing the render pass.
  37321. * @param camera The camera to apply the render pass to.
  37322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37323. * @param engine The engine which the post process will be applied. (default: current engine)
  37324. * @param reusable If the post process can be reused on the same frame. (default: false)
  37325. * @param textureType The type of texture to be used when performing the post processing.
  37326. * @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)
  37327. */
  37328. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37329. }
  37330. /**
  37331. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37332. */
  37333. export class PassCubePostProcess extends PostProcess {
  37334. private _face;
  37335. /**
  37336. * Gets or sets the cube face to display.
  37337. * * 0 is +X
  37338. * * 1 is -X
  37339. * * 2 is +Y
  37340. * * 3 is -Y
  37341. * * 4 is +Z
  37342. * * 5 is -Z
  37343. */
  37344. face: number;
  37345. /**
  37346. * Creates the PassCubePostProcess
  37347. * @param name The name of the effect.
  37348. * @param options The required width/height ratio to downsize to before computing the render pass.
  37349. * @param camera The camera to apply the render pass to.
  37350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37351. * @param engine The engine which the post process will be applied. (default: current engine)
  37352. * @param reusable If the post process can be reused on the same frame. (default: false)
  37353. * @param textureType The type of texture to be used when performing the post processing.
  37354. * @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)
  37355. */
  37356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37357. }
  37358. }
  37359. declare module BABYLON {
  37360. /** @hidden */
  37361. export var anaglyphPixelShader: {
  37362. name: string;
  37363. shader: string;
  37364. };
  37365. }
  37366. declare module BABYLON {
  37367. /**
  37368. * Postprocess used to generate anaglyphic rendering
  37369. */
  37370. export class AnaglyphPostProcess extends PostProcess {
  37371. private _passedProcess;
  37372. /**
  37373. * Creates a new AnaglyphPostProcess
  37374. * @param name defines postprocess name
  37375. * @param options defines creation options or target ratio scale
  37376. * @param rigCameras defines cameras using this postprocess
  37377. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37378. * @param engine defines hosting engine
  37379. * @param reusable defines if the postprocess will be reused multiple times per frame
  37380. */
  37381. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37382. }
  37383. }
  37384. declare module BABYLON {
  37385. /**
  37386. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37387. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37388. */
  37389. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37390. /**
  37391. * Creates a new AnaglyphArcRotateCamera
  37392. * @param name defines camera name
  37393. * @param alpha defines alpha angle (in radians)
  37394. * @param beta defines beta angle (in radians)
  37395. * @param radius defines radius
  37396. * @param target defines camera target
  37397. * @param interaxialDistance defines distance between each color axis
  37398. * @param scene defines the hosting scene
  37399. */
  37400. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37401. /**
  37402. * Gets camera class name
  37403. * @returns AnaglyphArcRotateCamera
  37404. */
  37405. getClassName(): string;
  37406. }
  37407. }
  37408. declare module BABYLON {
  37409. /**
  37410. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37411. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37412. */
  37413. export class AnaglyphFreeCamera extends FreeCamera {
  37414. /**
  37415. * Creates a new AnaglyphFreeCamera
  37416. * @param name defines camera name
  37417. * @param position defines initial position
  37418. * @param interaxialDistance defines distance between each color axis
  37419. * @param scene defines the hosting scene
  37420. */
  37421. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37422. /**
  37423. * Gets camera class name
  37424. * @returns AnaglyphFreeCamera
  37425. */
  37426. getClassName(): string;
  37427. }
  37428. }
  37429. declare module BABYLON {
  37430. /**
  37431. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37432. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37433. */
  37434. export class AnaglyphGamepadCamera extends GamepadCamera {
  37435. /**
  37436. * Creates a new AnaglyphGamepadCamera
  37437. * @param name defines camera name
  37438. * @param position defines initial position
  37439. * @param interaxialDistance defines distance between each color axis
  37440. * @param scene defines the hosting scene
  37441. */
  37442. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37443. /**
  37444. * Gets camera class name
  37445. * @returns AnaglyphGamepadCamera
  37446. */
  37447. getClassName(): string;
  37448. }
  37449. }
  37450. declare module BABYLON {
  37451. /**
  37452. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37454. */
  37455. export class AnaglyphUniversalCamera extends UniversalCamera {
  37456. /**
  37457. * Creates a new AnaglyphUniversalCamera
  37458. * @param name defines camera name
  37459. * @param position defines initial position
  37460. * @param interaxialDistance defines distance between each color axis
  37461. * @param scene defines the hosting scene
  37462. */
  37463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37464. /**
  37465. * Gets camera class name
  37466. * @returns AnaglyphUniversalCamera
  37467. */
  37468. getClassName(): string;
  37469. }
  37470. }
  37471. declare module BABYLON {
  37472. /** @hidden */
  37473. export var stereoscopicInterlacePixelShader: {
  37474. name: string;
  37475. shader: string;
  37476. };
  37477. }
  37478. declare module BABYLON {
  37479. /**
  37480. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37481. */
  37482. export class StereoscopicInterlacePostProcess extends PostProcess {
  37483. private _stepSize;
  37484. private _passedProcess;
  37485. /**
  37486. * Initializes a StereoscopicInterlacePostProcess
  37487. * @param name The name of the effect.
  37488. * @param rigCameras The rig cameras to be appled to the post process
  37489. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37491. * @param engine The engine which the post process will be applied. (default: current engine)
  37492. * @param reusable If the post process can be reused on the same frame. (default: false)
  37493. */
  37494. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37495. }
  37496. }
  37497. declare module BABYLON {
  37498. /**
  37499. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37500. * @see http://doc.babylonjs.com/features/cameras
  37501. */
  37502. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37503. /**
  37504. * Creates a new StereoscopicArcRotateCamera
  37505. * @param name defines camera name
  37506. * @param alpha defines alpha angle (in radians)
  37507. * @param beta defines beta angle (in radians)
  37508. * @param radius defines radius
  37509. * @param target defines camera target
  37510. * @param interaxialDistance defines distance between each color axis
  37511. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37512. * @param scene defines the hosting scene
  37513. */
  37514. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37515. /**
  37516. * Gets camera class name
  37517. * @returns StereoscopicArcRotateCamera
  37518. */
  37519. getClassName(): string;
  37520. }
  37521. }
  37522. declare module BABYLON {
  37523. /**
  37524. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37525. * @see http://doc.babylonjs.com/features/cameras
  37526. */
  37527. export class StereoscopicFreeCamera extends FreeCamera {
  37528. /**
  37529. * Creates a new StereoscopicFreeCamera
  37530. * @param name defines camera name
  37531. * @param position defines initial position
  37532. * @param interaxialDistance defines distance between each color axis
  37533. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37534. * @param scene defines the hosting scene
  37535. */
  37536. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37537. /**
  37538. * Gets camera class name
  37539. * @returns StereoscopicFreeCamera
  37540. */
  37541. getClassName(): string;
  37542. }
  37543. }
  37544. declare module BABYLON {
  37545. /**
  37546. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37547. * @see http://doc.babylonjs.com/features/cameras
  37548. */
  37549. export class StereoscopicGamepadCamera extends GamepadCamera {
  37550. /**
  37551. * Creates a new StereoscopicGamepadCamera
  37552. * @param name defines camera name
  37553. * @param position defines initial position
  37554. * @param interaxialDistance defines distance between each color axis
  37555. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37556. * @param scene defines the hosting scene
  37557. */
  37558. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37559. /**
  37560. * Gets camera class name
  37561. * @returns StereoscopicGamepadCamera
  37562. */
  37563. getClassName(): string;
  37564. }
  37565. }
  37566. declare module BABYLON {
  37567. /**
  37568. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37569. * @see http://doc.babylonjs.com/features/cameras
  37570. */
  37571. export class StereoscopicUniversalCamera extends UniversalCamera {
  37572. /**
  37573. * Creates a new StereoscopicUniversalCamera
  37574. * @param name defines camera name
  37575. * @param position defines initial position
  37576. * @param interaxialDistance defines distance between each color axis
  37577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37578. * @param scene defines the hosting scene
  37579. */
  37580. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37581. /**
  37582. * Gets camera class name
  37583. * @returns StereoscopicUniversalCamera
  37584. */
  37585. getClassName(): string;
  37586. }
  37587. }
  37588. declare module BABYLON {
  37589. /**
  37590. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37591. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37592. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37593. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37594. */
  37595. export class VirtualJoysticksCamera extends FreeCamera {
  37596. /**
  37597. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37598. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37599. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37600. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37601. * @param name Define the name of the camera in the scene
  37602. * @param position Define the start position of the camera in the scene
  37603. * @param scene Define the scene the camera belongs to
  37604. */
  37605. constructor(name: string, position: Vector3, scene: Scene);
  37606. /**
  37607. * Gets the current object class name.
  37608. * @return the class name
  37609. */
  37610. getClassName(): string;
  37611. }
  37612. }
  37613. declare module BABYLON {
  37614. /**
  37615. * This represents all the required metrics to create a VR camera.
  37616. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37617. */
  37618. export class VRCameraMetrics {
  37619. /**
  37620. * Define the horizontal resolution off the screen.
  37621. */
  37622. hResolution: number;
  37623. /**
  37624. * Define the vertical resolution off the screen.
  37625. */
  37626. vResolution: number;
  37627. /**
  37628. * Define the horizontal screen size.
  37629. */
  37630. hScreenSize: number;
  37631. /**
  37632. * Define the vertical screen size.
  37633. */
  37634. vScreenSize: number;
  37635. /**
  37636. * Define the vertical screen center position.
  37637. */
  37638. vScreenCenter: number;
  37639. /**
  37640. * Define the distance of the eyes to the screen.
  37641. */
  37642. eyeToScreenDistance: number;
  37643. /**
  37644. * Define the distance between both lenses
  37645. */
  37646. lensSeparationDistance: number;
  37647. /**
  37648. * Define the distance between both viewer's eyes.
  37649. */
  37650. interpupillaryDistance: number;
  37651. /**
  37652. * Define the distortion factor of the VR postprocess.
  37653. * Please, touch with care.
  37654. */
  37655. distortionK: number[];
  37656. /**
  37657. * Define the chromatic aberration correction factors for the VR post process.
  37658. */
  37659. chromaAbCorrection: number[];
  37660. /**
  37661. * Define the scale factor of the post process.
  37662. * The smaller the better but the slower.
  37663. */
  37664. postProcessScaleFactor: number;
  37665. /**
  37666. * Define an offset for the lens center.
  37667. */
  37668. lensCenterOffset: number;
  37669. /**
  37670. * Define if the current vr camera should compensate the distortion of the lense or not.
  37671. */
  37672. compensateDistortion: boolean;
  37673. /**
  37674. * Defines if multiview should be enabled when rendering (Default: false)
  37675. */
  37676. multiviewEnabled: boolean;
  37677. /**
  37678. * Gets the rendering aspect ratio based on the provided resolutions.
  37679. */
  37680. readonly aspectRatio: number;
  37681. /**
  37682. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37683. */
  37684. readonly aspectRatioFov: number;
  37685. /**
  37686. * @hidden
  37687. */
  37688. readonly leftHMatrix: Matrix;
  37689. /**
  37690. * @hidden
  37691. */
  37692. readonly rightHMatrix: Matrix;
  37693. /**
  37694. * @hidden
  37695. */
  37696. readonly leftPreViewMatrix: Matrix;
  37697. /**
  37698. * @hidden
  37699. */
  37700. readonly rightPreViewMatrix: Matrix;
  37701. /**
  37702. * Get the default VRMetrics based on the most generic setup.
  37703. * @returns the default vr metrics
  37704. */
  37705. static GetDefault(): VRCameraMetrics;
  37706. }
  37707. }
  37708. declare module BABYLON {
  37709. /** @hidden */
  37710. export var vrDistortionCorrectionPixelShader: {
  37711. name: string;
  37712. shader: string;
  37713. };
  37714. }
  37715. declare module BABYLON {
  37716. /**
  37717. * VRDistortionCorrectionPostProcess used for mobile VR
  37718. */
  37719. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37720. private _isRightEye;
  37721. private _distortionFactors;
  37722. private _postProcessScaleFactor;
  37723. private _lensCenterOffset;
  37724. private _scaleIn;
  37725. private _scaleFactor;
  37726. private _lensCenter;
  37727. /**
  37728. * Initializes the VRDistortionCorrectionPostProcess
  37729. * @param name The name of the effect.
  37730. * @param camera The camera to apply the render pass to.
  37731. * @param isRightEye If this is for the right eye distortion
  37732. * @param vrMetrics All the required metrics for the VR camera
  37733. */
  37734. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37735. }
  37736. }
  37737. declare module BABYLON {
  37738. /**
  37739. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37740. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37741. */
  37742. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37743. /**
  37744. * Creates a new VRDeviceOrientationArcRotateCamera
  37745. * @param name defines camera name
  37746. * @param alpha defines the camera rotation along the logitudinal axis
  37747. * @param beta defines the camera rotation along the latitudinal axis
  37748. * @param radius defines the camera distance from its target
  37749. * @param target defines the camera target
  37750. * @param scene defines the scene the camera belongs to
  37751. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37752. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37753. */
  37754. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37755. /**
  37756. * Gets camera class name
  37757. * @returns VRDeviceOrientationArcRotateCamera
  37758. */
  37759. getClassName(): string;
  37760. }
  37761. }
  37762. declare module BABYLON {
  37763. /**
  37764. * Camera used to simulate VR rendering (based on FreeCamera)
  37765. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37766. */
  37767. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37768. /**
  37769. * Creates a new VRDeviceOrientationFreeCamera
  37770. * @param name defines camera name
  37771. * @param position defines the start position of the camera
  37772. * @param scene defines the scene the camera belongs to
  37773. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37774. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37775. */
  37776. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37777. /**
  37778. * Gets camera class name
  37779. * @returns VRDeviceOrientationFreeCamera
  37780. */
  37781. getClassName(): string;
  37782. }
  37783. }
  37784. declare module BABYLON {
  37785. /**
  37786. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37787. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37788. */
  37789. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37790. /**
  37791. * Creates a new VRDeviceOrientationGamepadCamera
  37792. * @param name defines camera name
  37793. * @param position defines the start position of the camera
  37794. * @param scene defines the scene the camera belongs to
  37795. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37796. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37797. */
  37798. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37799. /**
  37800. * Gets camera class name
  37801. * @returns VRDeviceOrientationGamepadCamera
  37802. */
  37803. getClassName(): string;
  37804. }
  37805. }
  37806. declare module BABYLON {
  37807. /**
  37808. * Defines supported buttons for XBox360 compatible gamepads
  37809. */
  37810. export enum Xbox360Button {
  37811. /** A */
  37812. A = 0,
  37813. /** B */
  37814. B = 1,
  37815. /** X */
  37816. X = 2,
  37817. /** Y */
  37818. Y = 3,
  37819. /** Start */
  37820. Start = 4,
  37821. /** Back */
  37822. Back = 5,
  37823. /** Left button */
  37824. LB = 6,
  37825. /** Right button */
  37826. RB = 7,
  37827. /** Left stick */
  37828. LeftStick = 8,
  37829. /** Right stick */
  37830. RightStick = 9
  37831. }
  37832. /** Defines values for XBox360 DPad */
  37833. export enum Xbox360Dpad {
  37834. /** Up */
  37835. Up = 0,
  37836. /** Down */
  37837. Down = 1,
  37838. /** Left */
  37839. Left = 2,
  37840. /** Right */
  37841. Right = 3
  37842. }
  37843. /**
  37844. * Defines a XBox360 gamepad
  37845. */
  37846. export class Xbox360Pad extends Gamepad {
  37847. private _leftTrigger;
  37848. private _rightTrigger;
  37849. private _onlefttriggerchanged;
  37850. private _onrighttriggerchanged;
  37851. private _onbuttondown;
  37852. private _onbuttonup;
  37853. private _ondpaddown;
  37854. private _ondpadup;
  37855. /** Observable raised when a button is pressed */
  37856. onButtonDownObservable: Observable<Xbox360Button>;
  37857. /** Observable raised when a button is released */
  37858. onButtonUpObservable: Observable<Xbox360Button>;
  37859. /** Observable raised when a pad is pressed */
  37860. onPadDownObservable: Observable<Xbox360Dpad>;
  37861. /** Observable raised when a pad is released */
  37862. onPadUpObservable: Observable<Xbox360Dpad>;
  37863. private _buttonA;
  37864. private _buttonB;
  37865. private _buttonX;
  37866. private _buttonY;
  37867. private _buttonBack;
  37868. private _buttonStart;
  37869. private _buttonLB;
  37870. private _buttonRB;
  37871. private _buttonLeftStick;
  37872. private _buttonRightStick;
  37873. private _dPadUp;
  37874. private _dPadDown;
  37875. private _dPadLeft;
  37876. private _dPadRight;
  37877. private _isXboxOnePad;
  37878. /**
  37879. * Creates a new XBox360 gamepad object
  37880. * @param id defines the id of this gamepad
  37881. * @param index defines its index
  37882. * @param gamepad defines the internal HTML gamepad object
  37883. * @param xboxOne defines if it is a XBox One gamepad
  37884. */
  37885. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37886. /**
  37887. * Defines the callback to call when left trigger is pressed
  37888. * @param callback defines the callback to use
  37889. */
  37890. onlefttriggerchanged(callback: (value: number) => void): void;
  37891. /**
  37892. * Defines the callback to call when right trigger is pressed
  37893. * @param callback defines the callback to use
  37894. */
  37895. onrighttriggerchanged(callback: (value: number) => void): void;
  37896. /**
  37897. * Gets the left trigger value
  37898. */
  37899. /**
  37900. * Sets the left trigger value
  37901. */
  37902. leftTrigger: number;
  37903. /**
  37904. * Gets the right trigger value
  37905. */
  37906. /**
  37907. * Sets the right trigger value
  37908. */
  37909. rightTrigger: number;
  37910. /**
  37911. * Defines the callback to call when a button is pressed
  37912. * @param callback defines the callback to use
  37913. */
  37914. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37915. /**
  37916. * Defines the callback to call when a button is released
  37917. * @param callback defines the callback to use
  37918. */
  37919. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37920. /**
  37921. * Defines the callback to call when a pad is pressed
  37922. * @param callback defines the callback to use
  37923. */
  37924. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37925. /**
  37926. * Defines the callback to call when a pad is released
  37927. * @param callback defines the callback to use
  37928. */
  37929. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37930. private _setButtonValue;
  37931. private _setDPadValue;
  37932. /**
  37933. * Gets the value of the `A` button
  37934. */
  37935. /**
  37936. * Sets the value of the `A` button
  37937. */
  37938. buttonA: number;
  37939. /**
  37940. * Gets the value of the `B` button
  37941. */
  37942. /**
  37943. * Sets the value of the `B` button
  37944. */
  37945. buttonB: number;
  37946. /**
  37947. * Gets the value of the `X` button
  37948. */
  37949. /**
  37950. * Sets the value of the `X` button
  37951. */
  37952. buttonX: number;
  37953. /**
  37954. * Gets the value of the `Y` button
  37955. */
  37956. /**
  37957. * Sets the value of the `Y` button
  37958. */
  37959. buttonY: number;
  37960. /**
  37961. * Gets the value of the `Start` button
  37962. */
  37963. /**
  37964. * Sets the value of the `Start` button
  37965. */
  37966. buttonStart: number;
  37967. /**
  37968. * Gets the value of the `Back` button
  37969. */
  37970. /**
  37971. * Sets the value of the `Back` button
  37972. */
  37973. buttonBack: number;
  37974. /**
  37975. * Gets the value of the `Left` button
  37976. */
  37977. /**
  37978. * Sets the value of the `Left` button
  37979. */
  37980. buttonLB: number;
  37981. /**
  37982. * Gets the value of the `Right` button
  37983. */
  37984. /**
  37985. * Sets the value of the `Right` button
  37986. */
  37987. buttonRB: number;
  37988. /**
  37989. * Gets the value of the Left joystick
  37990. */
  37991. /**
  37992. * Sets the value of the Left joystick
  37993. */
  37994. buttonLeftStick: number;
  37995. /**
  37996. * Gets the value of the Right joystick
  37997. */
  37998. /**
  37999. * Sets the value of the Right joystick
  38000. */
  38001. buttonRightStick: number;
  38002. /**
  38003. * Gets the value of D-pad up
  38004. */
  38005. /**
  38006. * Sets the value of D-pad up
  38007. */
  38008. dPadUp: number;
  38009. /**
  38010. * Gets the value of D-pad down
  38011. */
  38012. /**
  38013. * Sets the value of D-pad down
  38014. */
  38015. dPadDown: number;
  38016. /**
  38017. * Gets the value of D-pad left
  38018. */
  38019. /**
  38020. * Sets the value of D-pad left
  38021. */
  38022. dPadLeft: number;
  38023. /**
  38024. * Gets the value of D-pad right
  38025. */
  38026. /**
  38027. * Sets the value of D-pad right
  38028. */
  38029. dPadRight: number;
  38030. /**
  38031. * Force the gamepad to synchronize with device values
  38032. */
  38033. update(): void;
  38034. /**
  38035. * Disposes the gamepad
  38036. */
  38037. dispose(): void;
  38038. }
  38039. }
  38040. declare module BABYLON {
  38041. /**
  38042. * Base class of materials working in push mode in babylon JS
  38043. * @hidden
  38044. */
  38045. export class PushMaterial extends Material {
  38046. protected _activeEffect: Effect;
  38047. protected _normalMatrix: Matrix;
  38048. /**
  38049. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38050. * This means that the material can keep using a previous shader while a new one is being compiled.
  38051. * This is mostly used when shader parallel compilation is supported (true by default)
  38052. */
  38053. allowShaderHotSwapping: boolean;
  38054. constructor(name: string, scene: Scene);
  38055. getEffect(): Effect;
  38056. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38057. /**
  38058. * Binds the given world matrix to the active effect
  38059. *
  38060. * @param world the matrix to bind
  38061. */
  38062. bindOnlyWorldMatrix(world: Matrix): void;
  38063. /**
  38064. * Binds the given normal matrix to the active effect
  38065. *
  38066. * @param normalMatrix the matrix to bind
  38067. */
  38068. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38069. bind(world: Matrix, mesh?: Mesh): void;
  38070. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38071. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38072. }
  38073. }
  38074. declare module BABYLON {
  38075. /**
  38076. * This groups all the flags used to control the materials channel.
  38077. */
  38078. export class MaterialFlags {
  38079. private static _DiffuseTextureEnabled;
  38080. /**
  38081. * Are diffuse textures enabled in the application.
  38082. */
  38083. static DiffuseTextureEnabled: boolean;
  38084. private static _AmbientTextureEnabled;
  38085. /**
  38086. * Are ambient textures enabled in the application.
  38087. */
  38088. static AmbientTextureEnabled: boolean;
  38089. private static _OpacityTextureEnabled;
  38090. /**
  38091. * Are opacity textures enabled in the application.
  38092. */
  38093. static OpacityTextureEnabled: boolean;
  38094. private static _ReflectionTextureEnabled;
  38095. /**
  38096. * Are reflection textures enabled in the application.
  38097. */
  38098. static ReflectionTextureEnabled: boolean;
  38099. private static _EmissiveTextureEnabled;
  38100. /**
  38101. * Are emissive textures enabled in the application.
  38102. */
  38103. static EmissiveTextureEnabled: boolean;
  38104. private static _SpecularTextureEnabled;
  38105. /**
  38106. * Are specular textures enabled in the application.
  38107. */
  38108. static SpecularTextureEnabled: boolean;
  38109. private static _BumpTextureEnabled;
  38110. /**
  38111. * Are bump textures enabled in the application.
  38112. */
  38113. static BumpTextureEnabled: boolean;
  38114. private static _LightmapTextureEnabled;
  38115. /**
  38116. * Are lightmap textures enabled in the application.
  38117. */
  38118. static LightmapTextureEnabled: boolean;
  38119. private static _RefractionTextureEnabled;
  38120. /**
  38121. * Are refraction textures enabled in the application.
  38122. */
  38123. static RefractionTextureEnabled: boolean;
  38124. private static _ColorGradingTextureEnabled;
  38125. /**
  38126. * Are color grading textures enabled in the application.
  38127. */
  38128. static ColorGradingTextureEnabled: boolean;
  38129. private static _FresnelEnabled;
  38130. /**
  38131. * Are fresnels enabled in the application.
  38132. */
  38133. static FresnelEnabled: boolean;
  38134. private static _ClearCoatTextureEnabled;
  38135. /**
  38136. * Are clear coat textures enabled in the application.
  38137. */
  38138. static ClearCoatTextureEnabled: boolean;
  38139. private static _ClearCoatBumpTextureEnabled;
  38140. /**
  38141. * Are clear coat bump textures enabled in the application.
  38142. */
  38143. static ClearCoatBumpTextureEnabled: boolean;
  38144. private static _ClearCoatTintTextureEnabled;
  38145. /**
  38146. * Are clear coat tint textures enabled in the application.
  38147. */
  38148. static ClearCoatTintTextureEnabled: boolean;
  38149. private static _SheenTextureEnabled;
  38150. /**
  38151. * Are sheen textures enabled in the application.
  38152. */
  38153. static SheenTextureEnabled: boolean;
  38154. private static _AnisotropicTextureEnabled;
  38155. /**
  38156. * Are anisotropic textures enabled in the application.
  38157. */
  38158. static AnisotropicTextureEnabled: boolean;
  38159. private static _ThicknessTextureEnabled;
  38160. /**
  38161. * Are thickness textures enabled in the application.
  38162. */
  38163. static ThicknessTextureEnabled: boolean;
  38164. }
  38165. }
  38166. declare module BABYLON {
  38167. /** @hidden */
  38168. export var defaultFragmentDeclaration: {
  38169. name: string;
  38170. shader: string;
  38171. };
  38172. }
  38173. declare module BABYLON {
  38174. /** @hidden */
  38175. export var defaultUboDeclaration: {
  38176. name: string;
  38177. shader: string;
  38178. };
  38179. }
  38180. declare module BABYLON {
  38181. /** @hidden */
  38182. export var lightFragmentDeclaration: {
  38183. name: string;
  38184. shader: string;
  38185. };
  38186. }
  38187. declare module BABYLON {
  38188. /** @hidden */
  38189. export var lightUboDeclaration: {
  38190. name: string;
  38191. shader: string;
  38192. };
  38193. }
  38194. declare module BABYLON {
  38195. /** @hidden */
  38196. export var lightsFragmentFunctions: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module BABYLON {
  38202. /** @hidden */
  38203. export var shadowsFragmentFunctions: {
  38204. name: string;
  38205. shader: string;
  38206. };
  38207. }
  38208. declare module BABYLON {
  38209. /** @hidden */
  38210. export var fresnelFunction: {
  38211. name: string;
  38212. shader: string;
  38213. };
  38214. }
  38215. declare module BABYLON {
  38216. /** @hidden */
  38217. export var reflectionFunction: {
  38218. name: string;
  38219. shader: string;
  38220. };
  38221. }
  38222. declare module BABYLON {
  38223. /** @hidden */
  38224. export var bumpFragmentFunctions: {
  38225. name: string;
  38226. shader: string;
  38227. };
  38228. }
  38229. declare module BABYLON {
  38230. /** @hidden */
  38231. export var logDepthDeclaration: {
  38232. name: string;
  38233. shader: string;
  38234. };
  38235. }
  38236. declare module BABYLON {
  38237. /** @hidden */
  38238. export var bumpFragment: {
  38239. name: string;
  38240. shader: string;
  38241. };
  38242. }
  38243. declare module BABYLON {
  38244. /** @hidden */
  38245. export var depthPrePass: {
  38246. name: string;
  38247. shader: string;
  38248. };
  38249. }
  38250. declare module BABYLON {
  38251. /** @hidden */
  38252. export var lightFragment: {
  38253. name: string;
  38254. shader: string;
  38255. };
  38256. }
  38257. declare module BABYLON {
  38258. /** @hidden */
  38259. export var logDepthFragment: {
  38260. name: string;
  38261. shader: string;
  38262. };
  38263. }
  38264. declare module BABYLON {
  38265. /** @hidden */
  38266. export var defaultPixelShader: {
  38267. name: string;
  38268. shader: string;
  38269. };
  38270. }
  38271. declare module BABYLON {
  38272. /** @hidden */
  38273. export var defaultVertexDeclaration: {
  38274. name: string;
  38275. shader: string;
  38276. };
  38277. }
  38278. declare module BABYLON {
  38279. /** @hidden */
  38280. export var bumpVertexDeclaration: {
  38281. name: string;
  38282. shader: string;
  38283. };
  38284. }
  38285. declare module BABYLON {
  38286. /** @hidden */
  38287. export var bumpVertex: {
  38288. name: string;
  38289. shader: string;
  38290. };
  38291. }
  38292. declare module BABYLON {
  38293. /** @hidden */
  38294. export var fogVertex: {
  38295. name: string;
  38296. shader: string;
  38297. };
  38298. }
  38299. declare module BABYLON {
  38300. /** @hidden */
  38301. export var shadowsVertex: {
  38302. name: string;
  38303. shader: string;
  38304. };
  38305. }
  38306. declare module BABYLON {
  38307. /** @hidden */
  38308. export var pointCloudVertex: {
  38309. name: string;
  38310. shader: string;
  38311. };
  38312. }
  38313. declare module BABYLON {
  38314. /** @hidden */
  38315. export var logDepthVertex: {
  38316. name: string;
  38317. shader: string;
  38318. };
  38319. }
  38320. declare module BABYLON {
  38321. /** @hidden */
  38322. export var defaultVertexShader: {
  38323. name: string;
  38324. shader: string;
  38325. };
  38326. }
  38327. declare module BABYLON {
  38328. /** @hidden */
  38329. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38330. MAINUV1: boolean;
  38331. MAINUV2: boolean;
  38332. DIFFUSE: boolean;
  38333. DIFFUSEDIRECTUV: number;
  38334. AMBIENT: boolean;
  38335. AMBIENTDIRECTUV: number;
  38336. OPACITY: boolean;
  38337. OPACITYDIRECTUV: number;
  38338. OPACITYRGB: boolean;
  38339. REFLECTION: boolean;
  38340. EMISSIVE: boolean;
  38341. EMISSIVEDIRECTUV: number;
  38342. SPECULAR: boolean;
  38343. SPECULARDIRECTUV: number;
  38344. BUMP: boolean;
  38345. BUMPDIRECTUV: number;
  38346. PARALLAX: boolean;
  38347. PARALLAXOCCLUSION: boolean;
  38348. SPECULAROVERALPHA: boolean;
  38349. CLIPPLANE: boolean;
  38350. CLIPPLANE2: boolean;
  38351. CLIPPLANE3: boolean;
  38352. CLIPPLANE4: boolean;
  38353. ALPHATEST: boolean;
  38354. DEPTHPREPASS: boolean;
  38355. ALPHAFROMDIFFUSE: boolean;
  38356. POINTSIZE: boolean;
  38357. FOG: boolean;
  38358. SPECULARTERM: boolean;
  38359. DIFFUSEFRESNEL: boolean;
  38360. OPACITYFRESNEL: boolean;
  38361. REFLECTIONFRESNEL: boolean;
  38362. REFRACTIONFRESNEL: boolean;
  38363. EMISSIVEFRESNEL: boolean;
  38364. FRESNEL: boolean;
  38365. NORMAL: boolean;
  38366. UV1: boolean;
  38367. UV2: boolean;
  38368. VERTEXCOLOR: boolean;
  38369. VERTEXALPHA: boolean;
  38370. NUM_BONE_INFLUENCERS: number;
  38371. BonesPerMesh: number;
  38372. BONETEXTURE: boolean;
  38373. INSTANCES: boolean;
  38374. GLOSSINESS: boolean;
  38375. ROUGHNESS: boolean;
  38376. EMISSIVEASILLUMINATION: boolean;
  38377. LINKEMISSIVEWITHDIFFUSE: boolean;
  38378. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38379. LIGHTMAP: boolean;
  38380. LIGHTMAPDIRECTUV: number;
  38381. OBJECTSPACE_NORMALMAP: boolean;
  38382. USELIGHTMAPASSHADOWMAP: boolean;
  38383. REFLECTIONMAP_3D: boolean;
  38384. REFLECTIONMAP_SPHERICAL: boolean;
  38385. REFLECTIONMAP_PLANAR: boolean;
  38386. REFLECTIONMAP_CUBIC: boolean;
  38387. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38388. REFLECTIONMAP_PROJECTION: boolean;
  38389. REFLECTIONMAP_SKYBOX: boolean;
  38390. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38391. REFLECTIONMAP_EXPLICIT: boolean;
  38392. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38393. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38394. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38395. INVERTCUBICMAP: boolean;
  38396. LOGARITHMICDEPTH: boolean;
  38397. REFRACTION: boolean;
  38398. REFRACTIONMAP_3D: boolean;
  38399. REFLECTIONOVERALPHA: boolean;
  38400. TWOSIDEDLIGHTING: boolean;
  38401. SHADOWFLOAT: boolean;
  38402. MORPHTARGETS: boolean;
  38403. MORPHTARGETS_NORMAL: boolean;
  38404. MORPHTARGETS_TANGENT: boolean;
  38405. NUM_MORPH_INFLUENCERS: number;
  38406. NONUNIFORMSCALING: boolean;
  38407. PREMULTIPLYALPHA: boolean;
  38408. IMAGEPROCESSING: boolean;
  38409. VIGNETTE: boolean;
  38410. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38411. VIGNETTEBLENDMODEOPAQUE: boolean;
  38412. TONEMAPPING: boolean;
  38413. TONEMAPPING_ACES: boolean;
  38414. CONTRAST: boolean;
  38415. COLORCURVES: boolean;
  38416. COLORGRADING: boolean;
  38417. COLORGRADING3D: boolean;
  38418. SAMPLER3DGREENDEPTH: boolean;
  38419. SAMPLER3DBGRMAP: boolean;
  38420. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38421. MULTIVIEW: boolean;
  38422. /**
  38423. * If the reflection texture on this material is in linear color space
  38424. * @hidden
  38425. */
  38426. IS_REFLECTION_LINEAR: boolean;
  38427. /**
  38428. * If the refraction texture on this material is in linear color space
  38429. * @hidden
  38430. */
  38431. IS_REFRACTION_LINEAR: boolean;
  38432. EXPOSURE: boolean;
  38433. constructor();
  38434. setReflectionMode(modeToEnable: string): void;
  38435. }
  38436. /**
  38437. * This is the default material used in Babylon. It is the best trade off between quality
  38438. * and performances.
  38439. * @see http://doc.babylonjs.com/babylon101/materials
  38440. */
  38441. export class StandardMaterial extends PushMaterial {
  38442. private _diffuseTexture;
  38443. /**
  38444. * The basic texture of the material as viewed under a light.
  38445. */
  38446. diffuseTexture: Nullable<BaseTexture>;
  38447. private _ambientTexture;
  38448. /**
  38449. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38450. */
  38451. ambientTexture: Nullable<BaseTexture>;
  38452. private _opacityTexture;
  38453. /**
  38454. * Define the transparency of the material from a texture.
  38455. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38456. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38457. */
  38458. opacityTexture: Nullable<BaseTexture>;
  38459. private _reflectionTexture;
  38460. /**
  38461. * Define the texture used to display the reflection.
  38462. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38463. */
  38464. reflectionTexture: Nullable<BaseTexture>;
  38465. private _emissiveTexture;
  38466. /**
  38467. * Define texture of the material as if self lit.
  38468. * This will be mixed in the final result even in the absence of light.
  38469. */
  38470. emissiveTexture: Nullable<BaseTexture>;
  38471. private _specularTexture;
  38472. /**
  38473. * Define how the color and intensity of the highlight given by the light in the material.
  38474. */
  38475. specularTexture: Nullable<BaseTexture>;
  38476. private _bumpTexture;
  38477. /**
  38478. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38479. * 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.
  38480. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38481. */
  38482. bumpTexture: Nullable<BaseTexture>;
  38483. private _lightmapTexture;
  38484. /**
  38485. * Complex lighting can be computationally expensive to compute at runtime.
  38486. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38487. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38488. */
  38489. lightmapTexture: Nullable<BaseTexture>;
  38490. private _refractionTexture;
  38491. /**
  38492. * Define the texture used to display the refraction.
  38493. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38494. */
  38495. refractionTexture: Nullable<BaseTexture>;
  38496. /**
  38497. * The color of the material lit by the environmental background lighting.
  38498. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38499. */
  38500. ambientColor: Color3;
  38501. /**
  38502. * The basic color of the material as viewed under a light.
  38503. */
  38504. diffuseColor: Color3;
  38505. /**
  38506. * Define how the color and intensity of the highlight given by the light in the material.
  38507. */
  38508. specularColor: Color3;
  38509. /**
  38510. * Define the color of the material as if self lit.
  38511. * This will be mixed in the final result even in the absence of light.
  38512. */
  38513. emissiveColor: Color3;
  38514. /**
  38515. * Defines how sharp are the highlights in the material.
  38516. * The bigger the value the sharper giving a more glossy feeling to the result.
  38517. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38518. */
  38519. specularPower: number;
  38520. private _useAlphaFromDiffuseTexture;
  38521. /**
  38522. * Does the transparency come from the diffuse texture alpha channel.
  38523. */
  38524. useAlphaFromDiffuseTexture: boolean;
  38525. private _useEmissiveAsIllumination;
  38526. /**
  38527. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38528. */
  38529. useEmissiveAsIllumination: boolean;
  38530. private _linkEmissiveWithDiffuse;
  38531. /**
  38532. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38533. * the emissive level when the final color is close to one.
  38534. */
  38535. linkEmissiveWithDiffuse: boolean;
  38536. private _useSpecularOverAlpha;
  38537. /**
  38538. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38539. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38540. */
  38541. useSpecularOverAlpha: boolean;
  38542. private _useReflectionOverAlpha;
  38543. /**
  38544. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38545. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38546. */
  38547. useReflectionOverAlpha: boolean;
  38548. private _disableLighting;
  38549. /**
  38550. * Does lights from the scene impacts this material.
  38551. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38552. */
  38553. disableLighting: boolean;
  38554. private _useObjectSpaceNormalMap;
  38555. /**
  38556. * Allows using an object space normal map (instead of tangent space).
  38557. */
  38558. useObjectSpaceNormalMap: boolean;
  38559. private _useParallax;
  38560. /**
  38561. * Is parallax enabled or not.
  38562. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38563. */
  38564. useParallax: boolean;
  38565. private _useParallaxOcclusion;
  38566. /**
  38567. * Is parallax occlusion enabled or not.
  38568. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38569. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38570. */
  38571. useParallaxOcclusion: boolean;
  38572. /**
  38573. * 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.
  38574. */
  38575. parallaxScaleBias: number;
  38576. private _roughness;
  38577. /**
  38578. * Helps to define how blurry the reflections should appears in the material.
  38579. */
  38580. roughness: number;
  38581. /**
  38582. * In case of refraction, define the value of the indice of refraction.
  38583. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38584. */
  38585. indexOfRefraction: number;
  38586. /**
  38587. * Invert the refraction texture alongside the y axis.
  38588. * It can be useful with procedural textures or probe for instance.
  38589. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38590. */
  38591. invertRefractionY: boolean;
  38592. /**
  38593. * Defines the alpha limits in alpha test mode.
  38594. */
  38595. alphaCutOff: number;
  38596. private _useLightmapAsShadowmap;
  38597. /**
  38598. * In case of light mapping, define whether the map contains light or shadow informations.
  38599. */
  38600. useLightmapAsShadowmap: boolean;
  38601. private _diffuseFresnelParameters;
  38602. /**
  38603. * Define the diffuse fresnel parameters of the material.
  38604. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38605. */
  38606. diffuseFresnelParameters: FresnelParameters;
  38607. private _opacityFresnelParameters;
  38608. /**
  38609. * Define the opacity fresnel parameters of the material.
  38610. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38611. */
  38612. opacityFresnelParameters: FresnelParameters;
  38613. private _reflectionFresnelParameters;
  38614. /**
  38615. * Define the reflection fresnel parameters of the material.
  38616. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38617. */
  38618. reflectionFresnelParameters: FresnelParameters;
  38619. private _refractionFresnelParameters;
  38620. /**
  38621. * Define the refraction fresnel parameters of the material.
  38622. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38623. */
  38624. refractionFresnelParameters: FresnelParameters;
  38625. private _emissiveFresnelParameters;
  38626. /**
  38627. * Define the emissive fresnel parameters of the material.
  38628. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38629. */
  38630. emissiveFresnelParameters: FresnelParameters;
  38631. private _useReflectionFresnelFromSpecular;
  38632. /**
  38633. * If true automatically deducts the fresnels values from the material specularity.
  38634. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38635. */
  38636. useReflectionFresnelFromSpecular: boolean;
  38637. private _useGlossinessFromSpecularMapAlpha;
  38638. /**
  38639. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38640. */
  38641. useGlossinessFromSpecularMapAlpha: boolean;
  38642. private _maxSimultaneousLights;
  38643. /**
  38644. * Defines the maximum number of lights that can be used in the material
  38645. */
  38646. maxSimultaneousLights: number;
  38647. private _invertNormalMapX;
  38648. /**
  38649. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38650. */
  38651. invertNormalMapX: boolean;
  38652. private _invertNormalMapY;
  38653. /**
  38654. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38655. */
  38656. invertNormalMapY: boolean;
  38657. private _twoSidedLighting;
  38658. /**
  38659. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38660. */
  38661. twoSidedLighting: boolean;
  38662. /**
  38663. * Default configuration related to image processing available in the standard Material.
  38664. */
  38665. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38666. /**
  38667. * Gets the image processing configuration used either in this material.
  38668. */
  38669. /**
  38670. * Sets the Default image processing configuration used either in the this material.
  38671. *
  38672. * If sets to null, the scene one is in use.
  38673. */
  38674. imageProcessingConfiguration: ImageProcessingConfiguration;
  38675. /**
  38676. * Keep track of the image processing observer to allow dispose and replace.
  38677. */
  38678. private _imageProcessingObserver;
  38679. /**
  38680. * Attaches a new image processing configuration to the Standard Material.
  38681. * @param configuration
  38682. */
  38683. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38684. /**
  38685. * Gets wether the color curves effect is enabled.
  38686. */
  38687. /**
  38688. * Sets wether the color curves effect is enabled.
  38689. */
  38690. cameraColorCurvesEnabled: boolean;
  38691. /**
  38692. * Gets wether the color grading effect is enabled.
  38693. */
  38694. /**
  38695. * Gets wether the color grading effect is enabled.
  38696. */
  38697. cameraColorGradingEnabled: boolean;
  38698. /**
  38699. * Gets wether tonemapping is enabled or not.
  38700. */
  38701. /**
  38702. * Sets wether tonemapping is enabled or not
  38703. */
  38704. cameraToneMappingEnabled: boolean;
  38705. /**
  38706. * The camera exposure used on this material.
  38707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38708. * This corresponds to a photographic exposure.
  38709. */
  38710. /**
  38711. * The camera exposure used on this material.
  38712. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38713. * This corresponds to a photographic exposure.
  38714. */
  38715. cameraExposure: number;
  38716. /**
  38717. * Gets The camera contrast used on this material.
  38718. */
  38719. /**
  38720. * Sets The camera contrast used on this material.
  38721. */
  38722. cameraContrast: number;
  38723. /**
  38724. * Gets the Color Grading 2D Lookup Texture.
  38725. */
  38726. /**
  38727. * Sets the Color Grading 2D Lookup Texture.
  38728. */
  38729. cameraColorGradingTexture: Nullable<BaseTexture>;
  38730. /**
  38731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38733. * 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;
  38734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38735. */
  38736. /**
  38737. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38738. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38739. * 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;
  38740. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38741. */
  38742. cameraColorCurves: Nullable<ColorCurves>;
  38743. /**
  38744. * Custom callback helping to override the default shader used in the material.
  38745. */
  38746. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38747. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38748. protected _worldViewProjectionMatrix: Matrix;
  38749. protected _globalAmbientColor: Color3;
  38750. protected _useLogarithmicDepth: boolean;
  38751. /**
  38752. * Instantiates a new standard material.
  38753. * This is the default material used in Babylon. It is the best trade off between quality
  38754. * and performances.
  38755. * @see http://doc.babylonjs.com/babylon101/materials
  38756. * @param name Define the name of the material in the scene
  38757. * @param scene Define the scene the material belong to
  38758. */
  38759. constructor(name: string, scene: Scene);
  38760. /**
  38761. * Gets a boolean indicating that current material needs to register RTT
  38762. */
  38763. readonly hasRenderTargetTextures: boolean;
  38764. /**
  38765. * Gets the current class name of the material e.g. "StandardMaterial"
  38766. * Mainly use in serialization.
  38767. * @returns the class name
  38768. */
  38769. getClassName(): string;
  38770. /**
  38771. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38772. * You can try switching to logarithmic depth.
  38773. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38774. */
  38775. useLogarithmicDepth: boolean;
  38776. /**
  38777. * Specifies if the material will require alpha blending
  38778. * @returns a boolean specifying if alpha blending is needed
  38779. */
  38780. needAlphaBlending(): boolean;
  38781. /**
  38782. * Specifies if this material should be rendered in alpha test mode
  38783. * @returns a boolean specifying if an alpha test is needed.
  38784. */
  38785. needAlphaTesting(): boolean;
  38786. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38787. /**
  38788. * Get the texture used for alpha test purpose.
  38789. * @returns the diffuse texture in case of the standard material.
  38790. */
  38791. getAlphaTestTexture(): Nullable<BaseTexture>;
  38792. /**
  38793. * Get if the submesh is ready to be used and all its information available.
  38794. * Child classes can use it to update shaders
  38795. * @param mesh defines the mesh to check
  38796. * @param subMesh defines which submesh to check
  38797. * @param useInstances specifies that instances should be used
  38798. * @returns a boolean indicating that the submesh is ready or not
  38799. */
  38800. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38801. /**
  38802. * Builds the material UBO layouts.
  38803. * Used internally during the effect preparation.
  38804. */
  38805. buildUniformLayout(): void;
  38806. /**
  38807. * Unbinds the material from the mesh
  38808. */
  38809. unbind(): void;
  38810. /**
  38811. * Binds the submesh to this material by preparing the effect and shader to draw
  38812. * @param world defines the world transformation matrix
  38813. * @param mesh defines the mesh containing the submesh
  38814. * @param subMesh defines the submesh to bind the material to
  38815. */
  38816. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38817. /**
  38818. * Get the list of animatables in the material.
  38819. * @returns the list of animatables object used in the material
  38820. */
  38821. getAnimatables(): IAnimatable[];
  38822. /**
  38823. * Gets the active textures from the material
  38824. * @returns an array of textures
  38825. */
  38826. getActiveTextures(): BaseTexture[];
  38827. /**
  38828. * Specifies if the material uses a texture
  38829. * @param texture defines the texture to check against the material
  38830. * @returns a boolean specifying if the material uses the texture
  38831. */
  38832. hasTexture(texture: BaseTexture): boolean;
  38833. /**
  38834. * Disposes the material
  38835. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38836. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38837. */
  38838. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38839. /**
  38840. * Makes a duplicate of the material, and gives it a new name
  38841. * @param name defines the new name for the duplicated material
  38842. * @returns the cloned material
  38843. */
  38844. clone(name: string): StandardMaterial;
  38845. /**
  38846. * Serializes this material in a JSON representation
  38847. * @returns the serialized material object
  38848. */
  38849. serialize(): any;
  38850. /**
  38851. * Creates a standard material from parsed material data
  38852. * @param source defines the JSON representation of the material
  38853. * @param scene defines the hosting scene
  38854. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38855. * @returns a new standard material
  38856. */
  38857. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38858. /**
  38859. * Are diffuse textures enabled in the application.
  38860. */
  38861. static DiffuseTextureEnabled: boolean;
  38862. /**
  38863. * Are ambient textures enabled in the application.
  38864. */
  38865. static AmbientTextureEnabled: boolean;
  38866. /**
  38867. * Are opacity textures enabled in the application.
  38868. */
  38869. static OpacityTextureEnabled: boolean;
  38870. /**
  38871. * Are reflection textures enabled in the application.
  38872. */
  38873. static ReflectionTextureEnabled: boolean;
  38874. /**
  38875. * Are emissive textures enabled in the application.
  38876. */
  38877. static EmissiveTextureEnabled: boolean;
  38878. /**
  38879. * Are specular textures enabled in the application.
  38880. */
  38881. static SpecularTextureEnabled: boolean;
  38882. /**
  38883. * Are bump textures enabled in the application.
  38884. */
  38885. static BumpTextureEnabled: boolean;
  38886. /**
  38887. * Are lightmap textures enabled in the application.
  38888. */
  38889. static LightmapTextureEnabled: boolean;
  38890. /**
  38891. * Are refraction textures enabled in the application.
  38892. */
  38893. static RefractionTextureEnabled: boolean;
  38894. /**
  38895. * Are color grading textures enabled in the application.
  38896. */
  38897. static ColorGradingTextureEnabled: boolean;
  38898. /**
  38899. * Are fresnels enabled in the application.
  38900. */
  38901. static FresnelEnabled: boolean;
  38902. }
  38903. }
  38904. declare module BABYLON {
  38905. /**
  38906. * A class extending Texture allowing drawing on a texture
  38907. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38908. */
  38909. export class DynamicTexture extends Texture {
  38910. private _generateMipMaps;
  38911. private _canvas;
  38912. private _context;
  38913. private _engine;
  38914. /**
  38915. * Creates a DynamicTexture
  38916. * @param name defines the name of the texture
  38917. * @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
  38918. * @param scene defines the scene where you want the texture
  38919. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38920. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38921. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38922. */
  38923. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38924. /**
  38925. * Get the current class name of the texture useful for serialization or dynamic coding.
  38926. * @returns "DynamicTexture"
  38927. */
  38928. getClassName(): string;
  38929. /**
  38930. * Gets the current state of canRescale
  38931. */
  38932. readonly canRescale: boolean;
  38933. private _recreate;
  38934. /**
  38935. * Scales the texture
  38936. * @param ratio the scale factor to apply to both width and height
  38937. */
  38938. scale(ratio: number): void;
  38939. /**
  38940. * Resizes the texture
  38941. * @param width the new width
  38942. * @param height the new height
  38943. */
  38944. scaleTo(width: number, height: number): void;
  38945. /**
  38946. * Gets the context of the canvas used by the texture
  38947. * @returns the canvas context of the dynamic texture
  38948. */
  38949. getContext(): CanvasRenderingContext2D;
  38950. /**
  38951. * Clears the texture
  38952. */
  38953. clear(): void;
  38954. /**
  38955. * Updates the texture
  38956. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38957. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38958. */
  38959. update(invertY?: boolean, premulAlpha?: boolean): void;
  38960. /**
  38961. * Draws text onto the texture
  38962. * @param text defines the text to be drawn
  38963. * @param x defines the placement of the text from the left
  38964. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38965. * @param font defines the font to be used with font-style, font-size, font-name
  38966. * @param color defines the color used for the text
  38967. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38968. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38969. * @param update defines whether texture is immediately update (default is true)
  38970. */
  38971. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38972. /**
  38973. * Clones the texture
  38974. * @returns the clone of the texture.
  38975. */
  38976. clone(): DynamicTexture;
  38977. /**
  38978. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38979. * @returns a serialized dynamic texture object
  38980. */
  38981. serialize(): any;
  38982. /** @hidden */
  38983. _rebuild(): void;
  38984. }
  38985. }
  38986. declare module BABYLON {
  38987. /** @hidden */
  38988. export var imageProcessingPixelShader: {
  38989. name: string;
  38990. shader: string;
  38991. };
  38992. }
  38993. declare module BABYLON {
  38994. /**
  38995. * ImageProcessingPostProcess
  38996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38997. */
  38998. export class ImageProcessingPostProcess extends PostProcess {
  38999. /**
  39000. * Default configuration related to image processing available in the PBR Material.
  39001. */
  39002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39003. /**
  39004. * Gets the image processing configuration used either in this material.
  39005. */
  39006. /**
  39007. * Sets the Default image processing configuration used either in the this material.
  39008. *
  39009. * If sets to null, the scene one is in use.
  39010. */
  39011. imageProcessingConfiguration: ImageProcessingConfiguration;
  39012. /**
  39013. * Keep track of the image processing observer to allow dispose and replace.
  39014. */
  39015. private _imageProcessingObserver;
  39016. /**
  39017. * Attaches a new image processing configuration to the PBR Material.
  39018. * @param configuration
  39019. */
  39020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39021. /**
  39022. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39023. */
  39024. /**
  39025. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39026. */
  39027. colorCurves: Nullable<ColorCurves>;
  39028. /**
  39029. * Gets wether the color curves effect is enabled.
  39030. */
  39031. /**
  39032. * Sets wether the color curves effect is enabled.
  39033. */
  39034. colorCurvesEnabled: boolean;
  39035. /**
  39036. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39037. */
  39038. /**
  39039. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39040. */
  39041. colorGradingTexture: Nullable<BaseTexture>;
  39042. /**
  39043. * Gets wether the color grading effect is enabled.
  39044. */
  39045. /**
  39046. * Gets wether the color grading effect is enabled.
  39047. */
  39048. colorGradingEnabled: boolean;
  39049. /**
  39050. * Gets exposure used in the effect.
  39051. */
  39052. /**
  39053. * Sets exposure used in the effect.
  39054. */
  39055. exposure: number;
  39056. /**
  39057. * Gets wether tonemapping is enabled or not.
  39058. */
  39059. /**
  39060. * Sets wether tonemapping is enabled or not
  39061. */
  39062. toneMappingEnabled: boolean;
  39063. /**
  39064. * Gets the type of tone mapping effect.
  39065. */
  39066. /**
  39067. * Sets the type of tone mapping effect.
  39068. */
  39069. toneMappingType: number;
  39070. /**
  39071. * Gets contrast used in the effect.
  39072. */
  39073. /**
  39074. * Sets contrast used in the effect.
  39075. */
  39076. contrast: number;
  39077. /**
  39078. * Gets Vignette stretch size.
  39079. */
  39080. /**
  39081. * Sets Vignette stretch size.
  39082. */
  39083. vignetteStretch: number;
  39084. /**
  39085. * Gets Vignette centre X Offset.
  39086. */
  39087. /**
  39088. * Sets Vignette centre X Offset.
  39089. */
  39090. vignetteCentreX: number;
  39091. /**
  39092. * Gets Vignette centre Y Offset.
  39093. */
  39094. /**
  39095. * Sets Vignette centre Y Offset.
  39096. */
  39097. vignetteCentreY: number;
  39098. /**
  39099. * Gets Vignette weight or intensity of the vignette effect.
  39100. */
  39101. /**
  39102. * Sets Vignette weight or intensity of the vignette effect.
  39103. */
  39104. vignetteWeight: number;
  39105. /**
  39106. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39107. * if vignetteEnabled is set to true.
  39108. */
  39109. /**
  39110. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39111. * if vignetteEnabled is set to true.
  39112. */
  39113. vignetteColor: Color4;
  39114. /**
  39115. * Gets Camera field of view used by the Vignette effect.
  39116. */
  39117. /**
  39118. * Sets Camera field of view used by the Vignette effect.
  39119. */
  39120. vignetteCameraFov: number;
  39121. /**
  39122. * Gets the vignette blend mode allowing different kind of effect.
  39123. */
  39124. /**
  39125. * Sets the vignette blend mode allowing different kind of effect.
  39126. */
  39127. vignetteBlendMode: number;
  39128. /**
  39129. * Gets wether the vignette effect is enabled.
  39130. */
  39131. /**
  39132. * Sets wether the vignette effect is enabled.
  39133. */
  39134. vignetteEnabled: boolean;
  39135. private _fromLinearSpace;
  39136. /**
  39137. * Gets wether the input of the processing is in Gamma or Linear Space.
  39138. */
  39139. /**
  39140. * Sets wether the input of the processing is in Gamma or Linear Space.
  39141. */
  39142. fromLinearSpace: boolean;
  39143. /**
  39144. * Defines cache preventing GC.
  39145. */
  39146. private _defines;
  39147. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39148. /**
  39149. * "ImageProcessingPostProcess"
  39150. * @returns "ImageProcessingPostProcess"
  39151. */
  39152. getClassName(): string;
  39153. protected _updateParameters(): void;
  39154. dispose(camera?: Camera): void;
  39155. }
  39156. }
  39157. declare module BABYLON {
  39158. /**
  39159. * Class containing static functions to help procedurally build meshes
  39160. */
  39161. export class GroundBuilder {
  39162. /**
  39163. * Creates a ground mesh
  39164. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39165. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39167. * @param name defines the name of the mesh
  39168. * @param options defines the options used to create the mesh
  39169. * @param scene defines the hosting scene
  39170. * @returns the ground mesh
  39171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39172. */
  39173. static CreateGround(name: string, options: {
  39174. width?: number;
  39175. height?: number;
  39176. subdivisions?: number;
  39177. subdivisionsX?: number;
  39178. subdivisionsY?: number;
  39179. updatable?: boolean;
  39180. }, scene: any): Mesh;
  39181. /**
  39182. * Creates a tiled ground mesh
  39183. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39184. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39185. * * 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
  39186. * * 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
  39187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39188. * @param name defines the name of the mesh
  39189. * @param options defines the options used to create the mesh
  39190. * @param scene defines the hosting scene
  39191. * @returns the tiled ground mesh
  39192. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39193. */
  39194. static CreateTiledGround(name: string, options: {
  39195. xmin: number;
  39196. zmin: number;
  39197. xmax: number;
  39198. zmax: number;
  39199. subdivisions?: {
  39200. w: number;
  39201. h: number;
  39202. };
  39203. precision?: {
  39204. w: number;
  39205. h: number;
  39206. };
  39207. updatable?: boolean;
  39208. }, scene?: Nullable<Scene>): Mesh;
  39209. /**
  39210. * Creates a ground mesh from a height map
  39211. * * The parameter `url` sets the URL of the height map image resource.
  39212. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39213. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39214. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39215. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39216. * * 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.
  39217. * * 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).
  39218. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39220. * @param name defines the name of the mesh
  39221. * @param url defines the url to the height map
  39222. * @param options defines the options used to create the mesh
  39223. * @param scene defines the hosting scene
  39224. * @returns the ground mesh
  39225. * @see https://doc.babylonjs.com/babylon101/height_map
  39226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39227. */
  39228. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39229. width?: number;
  39230. height?: number;
  39231. subdivisions?: number;
  39232. minHeight?: number;
  39233. maxHeight?: number;
  39234. colorFilter?: Color3;
  39235. alphaFilter?: number;
  39236. updatable?: boolean;
  39237. onReady?: (mesh: GroundMesh) => void;
  39238. }, scene?: Nullable<Scene>): GroundMesh;
  39239. }
  39240. }
  39241. declare module BABYLON {
  39242. /**
  39243. * Class containing static functions to help procedurally build meshes
  39244. */
  39245. export class TorusBuilder {
  39246. /**
  39247. * Creates a torus mesh
  39248. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39249. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39250. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39252. * * 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
  39253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39254. * @param name defines the name of the mesh
  39255. * @param options defines the options used to create the mesh
  39256. * @param scene defines the hosting scene
  39257. * @returns the torus mesh
  39258. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39259. */
  39260. static CreateTorus(name: string, options: {
  39261. diameter?: number;
  39262. thickness?: number;
  39263. tessellation?: number;
  39264. updatable?: boolean;
  39265. sideOrientation?: number;
  39266. frontUVs?: Vector4;
  39267. backUVs?: Vector4;
  39268. }, scene: any): Mesh;
  39269. }
  39270. }
  39271. declare module BABYLON {
  39272. /**
  39273. * Class containing static functions to help procedurally build meshes
  39274. */
  39275. export class CylinderBuilder {
  39276. /**
  39277. * Creates a cylinder or a cone mesh
  39278. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39279. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39280. * * 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.
  39281. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39282. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39283. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39284. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39285. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39286. * * 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).
  39287. * * 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
  39288. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39289. * * 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
  39290. * * 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.
  39291. * * If `enclose` is false, a ring surface is one element.
  39292. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39293. * * 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
  39294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39295. * * 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
  39296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39297. * @param name defines the name of the mesh
  39298. * @param options defines the options used to create the mesh
  39299. * @param scene defines the hosting scene
  39300. * @returns the cylinder mesh
  39301. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39302. */
  39303. static CreateCylinder(name: string, options: {
  39304. height?: number;
  39305. diameterTop?: number;
  39306. diameterBottom?: number;
  39307. diameter?: number;
  39308. tessellation?: number;
  39309. subdivisions?: number;
  39310. arc?: number;
  39311. faceColors?: Color4[];
  39312. faceUV?: Vector4[];
  39313. updatable?: boolean;
  39314. hasRings?: boolean;
  39315. enclose?: boolean;
  39316. sideOrientation?: number;
  39317. frontUVs?: Vector4;
  39318. backUVs?: Vector4;
  39319. }, scene: any): Mesh;
  39320. }
  39321. }
  39322. declare module BABYLON {
  39323. /**
  39324. * Manager for handling gamepads
  39325. */
  39326. export class GamepadManager {
  39327. private _scene?;
  39328. private _babylonGamepads;
  39329. private _oneGamepadConnected;
  39330. /** @hidden */
  39331. _isMonitoring: boolean;
  39332. private _gamepadEventSupported;
  39333. private _gamepadSupport;
  39334. /**
  39335. * observable to be triggered when the gamepad controller has been connected
  39336. */
  39337. onGamepadConnectedObservable: Observable<Gamepad>;
  39338. /**
  39339. * observable to be triggered when the gamepad controller has been disconnected
  39340. */
  39341. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39342. private _onGamepadConnectedEvent;
  39343. private _onGamepadDisconnectedEvent;
  39344. /**
  39345. * Initializes the gamepad manager
  39346. * @param _scene BabylonJS scene
  39347. */
  39348. constructor(_scene?: Scene | undefined);
  39349. /**
  39350. * The gamepads in the game pad manager
  39351. */
  39352. readonly gamepads: Gamepad[];
  39353. /**
  39354. * Get the gamepad controllers based on type
  39355. * @param type The type of gamepad controller
  39356. * @returns Nullable gamepad
  39357. */
  39358. getGamepadByType(type?: number): Nullable<Gamepad>;
  39359. /**
  39360. * Disposes the gamepad manager
  39361. */
  39362. dispose(): void;
  39363. private _addNewGamepad;
  39364. private _startMonitoringGamepads;
  39365. private _stopMonitoringGamepads;
  39366. /** @hidden */
  39367. _checkGamepadsStatus(): void;
  39368. private _updateGamepadObjects;
  39369. }
  39370. }
  39371. declare module BABYLON {
  39372. interface Scene {
  39373. /** @hidden */
  39374. _gamepadManager: Nullable<GamepadManager>;
  39375. /**
  39376. * Gets the gamepad manager associated with the scene
  39377. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39378. */
  39379. gamepadManager: GamepadManager;
  39380. }
  39381. /**
  39382. * Interface representing a free camera inputs manager
  39383. */
  39384. interface FreeCameraInputsManager {
  39385. /**
  39386. * Adds gamepad input support to the FreeCameraInputsManager.
  39387. * @returns the FreeCameraInputsManager
  39388. */
  39389. addGamepad(): FreeCameraInputsManager;
  39390. }
  39391. /**
  39392. * Interface representing an arc rotate camera inputs manager
  39393. */
  39394. interface ArcRotateCameraInputsManager {
  39395. /**
  39396. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39397. * @returns the camera inputs manager
  39398. */
  39399. addGamepad(): ArcRotateCameraInputsManager;
  39400. }
  39401. /**
  39402. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39403. */
  39404. export class GamepadSystemSceneComponent implements ISceneComponent {
  39405. /**
  39406. * The component name helpfull to identify the component in the list of scene components.
  39407. */
  39408. readonly name: string;
  39409. /**
  39410. * The scene the component belongs to.
  39411. */
  39412. scene: Scene;
  39413. /**
  39414. * Creates a new instance of the component for the given scene
  39415. * @param scene Defines the scene to register the component in
  39416. */
  39417. constructor(scene: Scene);
  39418. /**
  39419. * Registers the component in a given scene
  39420. */
  39421. register(): void;
  39422. /**
  39423. * Rebuilds the elements related to this component in case of
  39424. * context lost for instance.
  39425. */
  39426. rebuild(): void;
  39427. /**
  39428. * Disposes the component and the associated ressources
  39429. */
  39430. dispose(): void;
  39431. private _beforeCameraUpdate;
  39432. }
  39433. }
  39434. declare module BABYLON {
  39435. /**
  39436. * Options to modify the vr teleportation behavior.
  39437. */
  39438. export interface VRTeleportationOptions {
  39439. /**
  39440. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39441. */
  39442. floorMeshName?: string;
  39443. /**
  39444. * A list of meshes to be used as the teleportation floor. (default: empty)
  39445. */
  39446. floorMeshes?: Mesh[];
  39447. }
  39448. /**
  39449. * Options to modify the vr experience helper's behavior.
  39450. */
  39451. export interface VRExperienceHelperOptions extends WebVROptions {
  39452. /**
  39453. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39454. */
  39455. createDeviceOrientationCamera?: boolean;
  39456. /**
  39457. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39458. */
  39459. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39460. /**
  39461. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39462. */
  39463. laserToggle?: boolean;
  39464. /**
  39465. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39466. */
  39467. floorMeshes?: Mesh[];
  39468. /**
  39469. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39470. */
  39471. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39472. }
  39473. /**
  39474. * Event containing information after VR has been entered
  39475. */
  39476. export class OnAfterEnteringVRObservableEvent {
  39477. /**
  39478. * If entering vr was successful
  39479. */
  39480. success: boolean;
  39481. }
  39482. /**
  39483. * Helps to quickly add VR support to an existing scene.
  39484. * See http://doc.babylonjs.com/how_to/webvr_helper
  39485. */
  39486. export class VRExperienceHelper {
  39487. /** Options to modify the vr experience helper's behavior. */
  39488. webVROptions: VRExperienceHelperOptions;
  39489. private _scene;
  39490. private _position;
  39491. private _btnVR;
  39492. private _btnVRDisplayed;
  39493. private _webVRsupported;
  39494. private _webVRready;
  39495. private _webVRrequesting;
  39496. private _webVRpresenting;
  39497. private _hasEnteredVR;
  39498. private _fullscreenVRpresenting;
  39499. private _canvas;
  39500. private _webVRCamera;
  39501. private _vrDeviceOrientationCamera;
  39502. private _deviceOrientationCamera;
  39503. private _existingCamera;
  39504. private _onKeyDown;
  39505. private _onVrDisplayPresentChange;
  39506. private _onVRDisplayChanged;
  39507. private _onVRRequestPresentStart;
  39508. private _onVRRequestPresentComplete;
  39509. /**
  39510. * Observable raised right before entering VR.
  39511. */
  39512. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39513. /**
  39514. * Observable raised when entering VR has completed.
  39515. */
  39516. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39517. /**
  39518. * Observable raised when exiting VR.
  39519. */
  39520. onExitingVRObservable: Observable<VRExperienceHelper>;
  39521. /**
  39522. * Observable raised when controller mesh is loaded.
  39523. */
  39524. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39525. /** Return this.onEnteringVRObservable
  39526. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39527. */
  39528. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39529. /** Return this.onExitingVRObservable
  39530. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39531. */
  39532. readonly onExitingVR: Observable<VRExperienceHelper>;
  39533. /** Return this.onControllerMeshLoadedObservable
  39534. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39535. */
  39536. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39537. private _rayLength;
  39538. private _useCustomVRButton;
  39539. private _teleportationRequested;
  39540. private _teleportActive;
  39541. private _floorMeshName;
  39542. private _floorMeshesCollection;
  39543. private _rotationAllowed;
  39544. private _teleportBackwardsVector;
  39545. private _teleportationTarget;
  39546. private _isDefaultTeleportationTarget;
  39547. private _postProcessMove;
  39548. private _teleportationFillColor;
  39549. private _teleportationBorderColor;
  39550. private _rotationAngle;
  39551. private _haloCenter;
  39552. private _cameraGazer;
  39553. private _padSensibilityUp;
  39554. private _padSensibilityDown;
  39555. private _leftController;
  39556. private _rightController;
  39557. /**
  39558. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39559. */
  39560. onNewMeshSelected: Observable<AbstractMesh>;
  39561. /**
  39562. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39563. */
  39564. onNewMeshPicked: Observable<PickingInfo>;
  39565. private _circleEase;
  39566. /**
  39567. * Observable raised before camera teleportation
  39568. */
  39569. onBeforeCameraTeleport: Observable<Vector3>;
  39570. /**
  39571. * Observable raised after camera teleportation
  39572. */
  39573. onAfterCameraTeleport: Observable<Vector3>;
  39574. /**
  39575. * Observable raised when current selected mesh gets unselected
  39576. */
  39577. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39578. private _raySelectionPredicate;
  39579. /**
  39580. * To be optionaly changed by user to define custom ray selection
  39581. */
  39582. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39583. /**
  39584. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39585. */
  39586. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39587. /**
  39588. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39589. */
  39590. teleportationEnabled: boolean;
  39591. private _defaultHeight;
  39592. private _teleportationInitialized;
  39593. private _interactionsEnabled;
  39594. private _interactionsRequested;
  39595. private _displayGaze;
  39596. private _displayLaserPointer;
  39597. /**
  39598. * The mesh used to display where the user is going to teleport.
  39599. */
  39600. /**
  39601. * Sets the mesh to be used to display where the user is going to teleport.
  39602. */
  39603. teleportationTarget: Mesh;
  39604. /**
  39605. * 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
  39606. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39607. * See http://doc.babylonjs.com/resources/baking_transformations
  39608. */
  39609. gazeTrackerMesh: Mesh;
  39610. /**
  39611. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39612. */
  39613. updateGazeTrackerScale: boolean;
  39614. /**
  39615. * If the gaze trackers color should be updated when selecting meshes
  39616. */
  39617. updateGazeTrackerColor: boolean;
  39618. /**
  39619. * The gaze tracking mesh corresponding to the left controller
  39620. */
  39621. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39622. /**
  39623. * The gaze tracking mesh corresponding to the right controller
  39624. */
  39625. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39626. /**
  39627. * If the ray of the gaze should be displayed.
  39628. */
  39629. /**
  39630. * Sets if the ray of the gaze should be displayed.
  39631. */
  39632. displayGaze: boolean;
  39633. /**
  39634. * If the ray of the LaserPointer should be displayed.
  39635. */
  39636. /**
  39637. * Sets if the ray of the LaserPointer should be displayed.
  39638. */
  39639. displayLaserPointer: boolean;
  39640. /**
  39641. * The deviceOrientationCamera used as the camera when not in VR.
  39642. */
  39643. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39644. /**
  39645. * Based on the current WebVR support, returns the current VR camera used.
  39646. */
  39647. readonly currentVRCamera: Nullable<Camera>;
  39648. /**
  39649. * The webVRCamera which is used when in VR.
  39650. */
  39651. readonly webVRCamera: WebVRFreeCamera;
  39652. /**
  39653. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39654. */
  39655. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39656. private readonly _teleportationRequestInitiated;
  39657. /**
  39658. * Defines wether or not Pointer lock should be requested when switching to
  39659. * full screen.
  39660. */
  39661. requestPointerLockOnFullScreen: boolean;
  39662. /**
  39663. * Instantiates a VRExperienceHelper.
  39664. * Helps to quickly add VR support to an existing scene.
  39665. * @param scene The scene the VRExperienceHelper belongs to.
  39666. * @param webVROptions Options to modify the vr experience helper's behavior.
  39667. */
  39668. constructor(scene: Scene,
  39669. /** Options to modify the vr experience helper's behavior. */
  39670. webVROptions?: VRExperienceHelperOptions);
  39671. private _onDefaultMeshLoaded;
  39672. private _onResize;
  39673. private _onFullscreenChange;
  39674. /**
  39675. * Gets a value indicating if we are currently in VR mode.
  39676. */
  39677. readonly isInVRMode: boolean;
  39678. private onVrDisplayPresentChange;
  39679. private onVRDisplayChanged;
  39680. private moveButtonToBottomRight;
  39681. private displayVRButton;
  39682. private updateButtonVisibility;
  39683. private _cachedAngularSensibility;
  39684. /**
  39685. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39686. * Otherwise, will use the fullscreen API.
  39687. */
  39688. enterVR(): void;
  39689. /**
  39690. * Attempt to exit VR, or fullscreen.
  39691. */
  39692. exitVR(): void;
  39693. /**
  39694. * The position of the vr experience helper.
  39695. */
  39696. /**
  39697. * Sets the position of the vr experience helper.
  39698. */
  39699. position: Vector3;
  39700. /**
  39701. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39702. */
  39703. enableInteractions(): void;
  39704. private readonly _noControllerIsActive;
  39705. private beforeRender;
  39706. private _isTeleportationFloor;
  39707. /**
  39708. * Adds a floor mesh to be used for teleportation.
  39709. * @param floorMesh the mesh to be used for teleportation.
  39710. */
  39711. addFloorMesh(floorMesh: Mesh): void;
  39712. /**
  39713. * Removes a floor mesh from being used for teleportation.
  39714. * @param floorMesh the mesh to be removed.
  39715. */
  39716. removeFloorMesh(floorMesh: Mesh): void;
  39717. /**
  39718. * Enables interactions and teleportation using the VR controllers and gaze.
  39719. * @param vrTeleportationOptions options to modify teleportation behavior.
  39720. */
  39721. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39722. private _onNewGamepadConnected;
  39723. private _tryEnableInteractionOnController;
  39724. private _onNewGamepadDisconnected;
  39725. private _enableInteractionOnController;
  39726. private _checkTeleportWithRay;
  39727. private _checkRotate;
  39728. private _checkTeleportBackwards;
  39729. private _enableTeleportationOnController;
  39730. private _createTeleportationCircles;
  39731. private _displayTeleportationTarget;
  39732. private _hideTeleportationTarget;
  39733. private _rotateCamera;
  39734. private _moveTeleportationSelectorTo;
  39735. private _workingVector;
  39736. private _workingQuaternion;
  39737. private _workingMatrix;
  39738. /**
  39739. * Teleports the users feet to the desired location
  39740. * @param location The location where the user's feet should be placed
  39741. */
  39742. teleportCamera(location: Vector3): void;
  39743. private _convertNormalToDirectionOfRay;
  39744. private _castRayAndSelectObject;
  39745. private _notifySelectedMeshUnselected;
  39746. /**
  39747. * Sets the color of the laser ray from the vr controllers.
  39748. * @param color new color for the ray.
  39749. */
  39750. changeLaserColor(color: Color3): void;
  39751. /**
  39752. * Sets the color of the ray from the vr headsets gaze.
  39753. * @param color new color for the ray.
  39754. */
  39755. changeGazeColor(color: Color3): void;
  39756. /**
  39757. * Exits VR and disposes of the vr experience helper
  39758. */
  39759. dispose(): void;
  39760. /**
  39761. * Gets the name of the VRExperienceHelper class
  39762. * @returns "VRExperienceHelper"
  39763. */
  39764. getClassName(): string;
  39765. }
  39766. }
  39767. declare module BABYLON {
  39768. /**
  39769. * Manages an XRSession
  39770. * @see https://doc.babylonjs.com/how_to/webxr
  39771. */
  39772. export class WebXRSessionManager implements IDisposable {
  39773. private scene;
  39774. /**
  39775. * Fires every time a new xrFrame arrives which can be used to update the camera
  39776. */
  39777. onXRFrameObservable: Observable<any>;
  39778. /**
  39779. * Fires when the xr session is ended either by the device or manually done
  39780. */
  39781. onXRSessionEnded: Observable<any>;
  39782. /** @hidden */
  39783. _xrSession: XRSession;
  39784. /** @hidden */
  39785. _frameOfReference: XRFrameOfReference;
  39786. /** @hidden */
  39787. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39788. /** @hidden */
  39789. _currentXRFrame: Nullable<XRFrame>;
  39790. private _xrNavigator;
  39791. private _xrDevice;
  39792. private _tmpMatrix;
  39793. /**
  39794. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39795. * @param scene The scene which the session should be created for
  39796. */
  39797. constructor(scene: Scene);
  39798. /**
  39799. * Initializes the manager
  39800. * After initialization enterXR can be called to start an XR session
  39801. * @returns Promise which resolves after it is initialized
  39802. */
  39803. initializeAsync(): Promise<void>;
  39804. /**
  39805. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39806. * @param sessionCreationOptions xr options to create the session with
  39807. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39808. * @returns Promise which resolves after it enters XR
  39809. */
  39810. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39811. /**
  39812. * Stops the xrSession and restores the renderloop
  39813. * @returns Promise which resolves after it exits XR
  39814. */
  39815. exitXRAsync(): Promise<void>;
  39816. /**
  39817. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39818. * @param ray ray to cast into the environment
  39819. * @returns Promise which resolves with a collision point in the environment if it exists
  39820. */
  39821. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39822. /**
  39823. * Checks if a session would be supported for the creation options specified
  39824. * @param options creation options to check if they are supported
  39825. * @returns true if supported
  39826. */
  39827. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39828. /**
  39829. * @hidden
  39830. * Converts the render layer of xrSession to a render target
  39831. * @param session session to create render target for
  39832. * @param scene scene the new render target should be created for
  39833. */
  39834. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39835. /**
  39836. * Disposes of the session manager
  39837. */
  39838. dispose(): void;
  39839. }
  39840. }
  39841. declare module BABYLON {
  39842. /**
  39843. * WebXR Camera which holds the views for the xrSession
  39844. * @see https://doc.babylonjs.com/how_to/webxr
  39845. */
  39846. export class WebXRCamera extends FreeCamera {
  39847. private static _TmpMatrix;
  39848. /**
  39849. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39850. * @param name the name of the camera
  39851. * @param scene the scene to add the camera to
  39852. */
  39853. constructor(name: string, scene: Scene);
  39854. private _updateNumberOfRigCameras;
  39855. /** @hidden */
  39856. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39857. /**
  39858. * Updates the cameras position from the current pose information of the XR session
  39859. * @param xrSessionManager the session containing pose information
  39860. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39861. */
  39862. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39863. }
  39864. }
  39865. declare module BABYLON {
  39866. /**
  39867. * States of the webXR experience
  39868. */
  39869. export enum WebXRState {
  39870. /**
  39871. * Transitioning to being in XR mode
  39872. */
  39873. ENTERING_XR = 0,
  39874. /**
  39875. * Transitioning to non XR mode
  39876. */
  39877. EXITING_XR = 1,
  39878. /**
  39879. * In XR mode and presenting
  39880. */
  39881. IN_XR = 2,
  39882. /**
  39883. * Not entered XR mode
  39884. */
  39885. NOT_IN_XR = 3
  39886. }
  39887. /**
  39888. * Helper class used to enable XR
  39889. * @see https://doc.babylonjs.com/how_to/webxr
  39890. */
  39891. export class WebXRExperienceHelper implements IDisposable {
  39892. private scene;
  39893. /**
  39894. * 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
  39895. */
  39896. container: AbstractMesh;
  39897. /**
  39898. * Camera used to render xr content
  39899. */
  39900. camera: WebXRCamera;
  39901. /**
  39902. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39903. */
  39904. state: WebXRState;
  39905. private _setState;
  39906. private static _TmpVector;
  39907. /**
  39908. * Fires when the state of the experience helper has changed
  39909. */
  39910. onStateChangedObservable: Observable<WebXRState>;
  39911. /** @hidden */
  39912. _sessionManager: WebXRSessionManager;
  39913. private _nonVRCamera;
  39914. private _originalSceneAutoClear;
  39915. private _supported;
  39916. /**
  39917. * Creates the experience helper
  39918. * @param scene the scene to attach the experience helper to
  39919. * @returns a promise for the experience helper
  39920. */
  39921. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39922. /**
  39923. * Creates a WebXRExperienceHelper
  39924. * @param scene The scene the helper should be created in
  39925. */
  39926. private constructor();
  39927. /**
  39928. * Exits XR mode and returns the scene to its original state
  39929. * @returns promise that resolves after xr mode has exited
  39930. */
  39931. exitXRAsync(): Promise<void>;
  39932. /**
  39933. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39934. * @param sessionCreationOptions options for the XR session
  39935. * @param frameOfReference frame of reference of the XR session
  39936. * @returns promise that resolves after xr mode has entered
  39937. */
  39938. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39939. /**
  39940. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39941. * @param ray ray to cast into the environment
  39942. * @returns Promise which resolves with a collision point in the environment if it exists
  39943. */
  39944. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39945. /**
  39946. * Updates the global position of the camera by moving the camera's container
  39947. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39948. * @param position The desired global position of the camera
  39949. */
  39950. setPositionOfCameraUsingContainer(position: Vector3): void;
  39951. /**
  39952. * Rotates the xr camera by rotating the camera's container around the camera's position
  39953. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39954. * @param rotation the desired quaternion rotation to apply to the camera
  39955. */
  39956. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39957. /**
  39958. * Checks if the creation options are supported by the xr session
  39959. * @param options creation options
  39960. * @returns true if supported
  39961. */
  39962. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39963. /**
  39964. * Disposes of the experience helper
  39965. */
  39966. dispose(): void;
  39967. }
  39968. }
  39969. declare module BABYLON {
  39970. /**
  39971. * Button which can be used to enter a different mode of XR
  39972. */
  39973. export class WebXREnterExitUIButton {
  39974. /** button element */
  39975. element: HTMLElement;
  39976. /** XR initialization options for the button */
  39977. initializationOptions: XRSessionCreationOptions;
  39978. /**
  39979. * Creates a WebXREnterExitUIButton
  39980. * @param element button element
  39981. * @param initializationOptions XR initialization options for the button
  39982. */
  39983. constructor(
  39984. /** button element */
  39985. element: HTMLElement,
  39986. /** XR initialization options for the button */
  39987. initializationOptions: XRSessionCreationOptions);
  39988. /**
  39989. * Overwritable function which can be used to update the button's visuals when the state changes
  39990. * @param activeButton the current active button in the UI
  39991. */
  39992. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39993. }
  39994. /**
  39995. * Options to create the webXR UI
  39996. */
  39997. export class WebXREnterExitUIOptions {
  39998. /**
  39999. * Context to enter xr with
  40000. */
  40001. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40002. /**
  40003. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40004. */
  40005. customButtons?: Array<WebXREnterExitUIButton>;
  40006. }
  40007. /**
  40008. * UI to allow the user to enter/exit XR mode
  40009. */
  40010. export class WebXREnterExitUI implements IDisposable {
  40011. private scene;
  40012. private _overlay;
  40013. private _buttons;
  40014. private _activeButton;
  40015. /**
  40016. * Fired every time the active button is changed.
  40017. *
  40018. * When xr is entered via a button that launches xr that button will be the callback parameter
  40019. *
  40020. * When exiting xr the callback parameter will be null)
  40021. */
  40022. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40023. /**
  40024. * Creates UI to allow the user to enter/exit XR mode
  40025. * @param scene the scene to add the ui to
  40026. * @param helper the xr experience helper to enter/exit xr with
  40027. * @param options options to configure the UI
  40028. * @returns the created ui
  40029. */
  40030. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40031. private constructor();
  40032. private _updateButtons;
  40033. /**
  40034. * Disposes of the object
  40035. */
  40036. dispose(): void;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Represents an XR input
  40042. */
  40043. export class WebXRController {
  40044. /**
  40045. * 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
  40046. */
  40047. grip?: AbstractMesh;
  40048. /**
  40049. * Pointer which can be used to select objects or attach a visible laser to
  40050. */
  40051. pointer: AbstractMesh;
  40052. /**
  40053. * Creates the controller
  40054. * @see https://doc.babylonjs.com/how_to/webxr
  40055. * @param scene the scene which the controller should be associated to
  40056. */
  40057. constructor(scene: Scene);
  40058. /**
  40059. * Disposes of the object
  40060. */
  40061. dispose(): void;
  40062. }
  40063. /**
  40064. * XR input used to track XR inputs such as controllers/rays
  40065. */
  40066. export class WebXRInput implements IDisposable {
  40067. private helper;
  40068. /**
  40069. * XR controllers being tracked
  40070. */
  40071. controllers: Array<WebXRController>;
  40072. private _tmpMatrix;
  40073. private _frameObserver;
  40074. /**
  40075. * Initializes the WebXRInput
  40076. * @param helper experience helper which the input should be created for
  40077. */
  40078. constructor(helper: WebXRExperienceHelper);
  40079. /**
  40080. * Disposes of the object
  40081. */
  40082. dispose(): void;
  40083. }
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40088. */
  40089. export class WebXRManagedOutputCanvas implements IDisposable {
  40090. private _canvas;
  40091. /**
  40092. * xrpresent context of the canvas which can be used to display/mirror xr content
  40093. */
  40094. canvasContext: Nullable<WebGLRenderingContext>;
  40095. /**
  40096. * Initializes the canvas to be added/removed upon entering/exiting xr
  40097. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40098. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40099. */
  40100. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40101. /**
  40102. * Disposes of the object
  40103. */
  40104. dispose(): void;
  40105. private _setManagedOutputCanvas;
  40106. private _addCanvas;
  40107. private _removeCanvas;
  40108. }
  40109. }
  40110. declare module BABYLON {
  40111. /**
  40112. * Contains an array of blocks representing the octree
  40113. */
  40114. export interface IOctreeContainer<T> {
  40115. /**
  40116. * Blocks within the octree
  40117. */
  40118. blocks: Array<OctreeBlock<T>>;
  40119. }
  40120. /**
  40121. * Class used to store a cell in an octree
  40122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40123. */
  40124. export class OctreeBlock<T> {
  40125. /**
  40126. * Gets the content of the current block
  40127. */
  40128. entries: T[];
  40129. /**
  40130. * Gets the list of block children
  40131. */
  40132. blocks: Array<OctreeBlock<T>>;
  40133. private _depth;
  40134. private _maxDepth;
  40135. private _capacity;
  40136. private _minPoint;
  40137. private _maxPoint;
  40138. private _boundingVectors;
  40139. private _creationFunc;
  40140. /**
  40141. * Creates a new block
  40142. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40143. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40144. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40145. * @param depth defines the current depth of this block in the octree
  40146. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40147. * @param creationFunc defines a callback to call when an element is added to the block
  40148. */
  40149. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40150. /**
  40151. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40152. */
  40153. readonly capacity: number;
  40154. /**
  40155. * Gets the minimum vector (in world space) of the block's bounding box
  40156. */
  40157. readonly minPoint: Vector3;
  40158. /**
  40159. * Gets the maximum vector (in world space) of the block's bounding box
  40160. */
  40161. readonly maxPoint: Vector3;
  40162. /**
  40163. * Add a new element to this block
  40164. * @param entry defines the element to add
  40165. */
  40166. addEntry(entry: T): void;
  40167. /**
  40168. * Remove an element from this block
  40169. * @param entry defines the element to remove
  40170. */
  40171. removeEntry(entry: T): void;
  40172. /**
  40173. * Add an array of elements to this block
  40174. * @param entries defines the array of elements to add
  40175. */
  40176. addEntries(entries: T[]): void;
  40177. /**
  40178. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40179. * @param frustumPlanes defines the frustum planes to test
  40180. * @param selection defines the array to store current content if selection is positive
  40181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40182. */
  40183. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40184. /**
  40185. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40186. * @param sphereCenter defines the bounding sphere center
  40187. * @param sphereRadius defines the bounding sphere radius
  40188. * @param selection defines the array to store current content if selection is positive
  40189. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40190. */
  40191. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40192. /**
  40193. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40194. * @param ray defines the ray to test with
  40195. * @param selection defines the array to store current content if selection is positive
  40196. */
  40197. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40198. /**
  40199. * Subdivide the content into child blocks (this block will then be empty)
  40200. */
  40201. createInnerBlocks(): void;
  40202. /**
  40203. * @hidden
  40204. */
  40205. 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;
  40206. }
  40207. }
  40208. declare module BABYLON {
  40209. /**
  40210. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40212. */
  40213. export class Octree<T> {
  40214. /** 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.) */
  40215. maxDepth: number;
  40216. /**
  40217. * Blocks within the octree containing objects
  40218. */
  40219. blocks: Array<OctreeBlock<T>>;
  40220. /**
  40221. * Content stored in the octree
  40222. */
  40223. dynamicContent: T[];
  40224. private _maxBlockCapacity;
  40225. private _selectionContent;
  40226. private _creationFunc;
  40227. /**
  40228. * Creates a octree
  40229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40230. * @param creationFunc function to be used to instatiate the octree
  40231. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40232. * @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.)
  40233. */
  40234. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40235. /** 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.) */
  40236. maxDepth?: number);
  40237. /**
  40238. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40239. * @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);
  40240. * @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);
  40241. * @param entries meshes to be added to the octree blocks
  40242. */
  40243. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40244. /**
  40245. * Adds a mesh to the octree
  40246. * @param entry Mesh to add to the octree
  40247. */
  40248. addMesh(entry: T): void;
  40249. /**
  40250. * Remove an element from the octree
  40251. * @param entry defines the element to remove
  40252. */
  40253. removeMesh(entry: T): void;
  40254. /**
  40255. * Selects an array of meshes within the frustum
  40256. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40257. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40258. * @returns array of meshes within the frustum
  40259. */
  40260. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40261. /**
  40262. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40263. * @param sphereCenter defines the bounding sphere center
  40264. * @param sphereRadius defines the bounding sphere radius
  40265. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40266. * @returns an array of objects that intersect the sphere
  40267. */
  40268. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40269. /**
  40270. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40271. * @param ray defines the ray to test with
  40272. * @returns array of intersected objects
  40273. */
  40274. intersectsRay(ray: Ray): SmartArray<T>;
  40275. /**
  40276. * Adds a mesh into the octree block if it intersects the block
  40277. */
  40278. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40279. /**
  40280. * Adds a submesh into the octree block if it intersects the block
  40281. */
  40282. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40283. }
  40284. }
  40285. declare module BABYLON {
  40286. interface Scene {
  40287. /**
  40288. * @hidden
  40289. * Backing Filed
  40290. */
  40291. _selectionOctree: Octree<AbstractMesh>;
  40292. /**
  40293. * Gets the octree used to boost mesh selection (picking)
  40294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40295. */
  40296. selectionOctree: Octree<AbstractMesh>;
  40297. /**
  40298. * Creates or updates the octree used to boost selection (picking)
  40299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40300. * @param maxCapacity defines the maximum capacity per leaf
  40301. * @param maxDepth defines the maximum depth of the octree
  40302. * @returns an octree of AbstractMesh
  40303. */
  40304. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40305. }
  40306. interface AbstractMesh {
  40307. /**
  40308. * @hidden
  40309. * Backing Field
  40310. */
  40311. _submeshesOctree: Octree<SubMesh>;
  40312. /**
  40313. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40314. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40315. * @param maxCapacity defines the maximum size of each block (64 by default)
  40316. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40317. * @returns the new octree
  40318. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40320. */
  40321. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40322. }
  40323. /**
  40324. * Defines the octree scene component responsible to manage any octrees
  40325. * in a given scene.
  40326. */
  40327. export class OctreeSceneComponent {
  40328. /**
  40329. * The component name helpfull to identify the component in the list of scene components.
  40330. */
  40331. readonly name: string;
  40332. /**
  40333. * The scene the component belongs to.
  40334. */
  40335. scene: Scene;
  40336. /**
  40337. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40338. */
  40339. readonly checksIsEnabled: boolean;
  40340. /**
  40341. * Creates a new instance of the component for the given scene
  40342. * @param scene Defines the scene to register the component in
  40343. */
  40344. constructor(scene: Scene);
  40345. /**
  40346. * Registers the component in a given scene
  40347. */
  40348. register(): void;
  40349. /**
  40350. * Return the list of active meshes
  40351. * @returns the list of active meshes
  40352. */
  40353. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40354. /**
  40355. * Return the list of active sub meshes
  40356. * @param mesh The mesh to get the candidates sub meshes from
  40357. * @returns the list of active sub meshes
  40358. */
  40359. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40360. private _tempRay;
  40361. /**
  40362. * Return the list of sub meshes intersecting with a given local ray
  40363. * @param mesh defines the mesh to find the submesh for
  40364. * @param localRay defines the ray in local space
  40365. * @returns the list of intersecting sub meshes
  40366. */
  40367. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40368. /**
  40369. * Return the list of sub meshes colliding with a collider
  40370. * @param mesh defines the mesh to find the submesh for
  40371. * @param collider defines the collider to evaluate the collision against
  40372. * @returns the list of colliding sub meshes
  40373. */
  40374. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40375. /**
  40376. * Rebuilds the elements related to this component in case of
  40377. * context lost for instance.
  40378. */
  40379. rebuild(): void;
  40380. /**
  40381. * Disposes the component and the associated ressources.
  40382. */
  40383. dispose(): void;
  40384. }
  40385. }
  40386. declare module BABYLON {
  40387. /**
  40388. * Renders a layer on top of an existing scene
  40389. */
  40390. export class UtilityLayerRenderer implements IDisposable {
  40391. /** the original scene that will be rendered on top of */
  40392. originalScene: Scene;
  40393. private _pointerCaptures;
  40394. private _lastPointerEvents;
  40395. private static _DefaultUtilityLayer;
  40396. private static _DefaultKeepDepthUtilityLayer;
  40397. private _sharedGizmoLight;
  40398. /**
  40399. * @hidden
  40400. * Light which used by gizmos to get light shading
  40401. */
  40402. _getSharedGizmoLight(): HemisphericLight;
  40403. /**
  40404. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40405. */
  40406. pickUtilitySceneFirst: boolean;
  40407. /**
  40408. * 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)
  40409. */
  40410. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40411. /**
  40412. * 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)
  40413. */
  40414. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40415. /**
  40416. * The scene that is rendered on top of the original scene
  40417. */
  40418. utilityLayerScene: Scene;
  40419. /**
  40420. * If the utility layer should automatically be rendered on top of existing scene
  40421. */
  40422. shouldRender: boolean;
  40423. /**
  40424. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40425. */
  40426. onlyCheckPointerDownEvents: boolean;
  40427. /**
  40428. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40429. */
  40430. processAllEvents: boolean;
  40431. /**
  40432. * Observable raised when the pointer move from the utility layer scene to the main scene
  40433. */
  40434. onPointerOutObservable: Observable<number>;
  40435. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40436. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40437. private _afterRenderObserver;
  40438. private _sceneDisposeObserver;
  40439. private _originalPointerObserver;
  40440. /**
  40441. * Instantiates a UtilityLayerRenderer
  40442. * @param originalScene the original scene that will be rendered on top of
  40443. * @param handleEvents boolean indicating if the utility layer should handle events
  40444. */
  40445. constructor(
  40446. /** the original scene that will be rendered on top of */
  40447. originalScene: Scene, handleEvents?: boolean);
  40448. private _notifyObservers;
  40449. /**
  40450. * Renders the utility layers scene on top of the original scene
  40451. */
  40452. render(): void;
  40453. /**
  40454. * Disposes of the renderer
  40455. */
  40456. dispose(): void;
  40457. private _updateCamera;
  40458. }
  40459. }
  40460. declare module BABYLON {
  40461. /**
  40462. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40463. */
  40464. export class Gizmo implements IDisposable {
  40465. /** The utility layer the gizmo will be added to */
  40466. gizmoLayer: UtilityLayerRenderer;
  40467. /**
  40468. * The root mesh of the gizmo
  40469. */
  40470. _rootMesh: Mesh;
  40471. private _attachedMesh;
  40472. /**
  40473. * Ratio for the scale of the gizmo (Default: 1)
  40474. */
  40475. scaleRatio: number;
  40476. private _tmpMatrix;
  40477. /**
  40478. * If a custom mesh has been set (Default: false)
  40479. */
  40480. protected _customMeshSet: boolean;
  40481. /**
  40482. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40483. * * When set, interactions will be enabled
  40484. */
  40485. attachedMesh: Nullable<AbstractMesh>;
  40486. /**
  40487. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40488. * @param mesh The mesh to replace the default mesh of the gizmo
  40489. */
  40490. setCustomMesh(mesh: Mesh): void;
  40491. /**
  40492. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40493. */
  40494. updateGizmoRotationToMatchAttachedMesh: boolean;
  40495. /**
  40496. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40497. */
  40498. updateGizmoPositionToMatchAttachedMesh: boolean;
  40499. /**
  40500. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40501. */
  40502. protected _updateScale: boolean;
  40503. protected _interactionsEnabled: boolean;
  40504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40505. private _beforeRenderObserver;
  40506. /**
  40507. * Creates a gizmo
  40508. * @param gizmoLayer The utility layer the gizmo will be added to
  40509. */
  40510. constructor(
  40511. /** The utility layer the gizmo will be added to */
  40512. gizmoLayer?: UtilityLayerRenderer);
  40513. private _tempVector;
  40514. /**
  40515. * @hidden
  40516. * Updates the gizmo to match the attached mesh's position/rotation
  40517. */
  40518. protected _update(): void;
  40519. /**
  40520. * Disposes of the gizmo
  40521. */
  40522. dispose(): void;
  40523. }
  40524. }
  40525. declare module BABYLON {
  40526. /**
  40527. * Single axis drag gizmo
  40528. */
  40529. export class AxisDragGizmo extends Gizmo {
  40530. /**
  40531. * Drag behavior responsible for the gizmos dragging interactions
  40532. */
  40533. dragBehavior: PointerDragBehavior;
  40534. private _pointerObserver;
  40535. /**
  40536. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40537. */
  40538. snapDistance: number;
  40539. /**
  40540. * Event that fires each time the gizmo snaps to a new location.
  40541. * * snapDistance is the the change in distance
  40542. */
  40543. onSnapObservable: Observable<{
  40544. snapDistance: number;
  40545. }>;
  40546. /** @hidden */
  40547. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40548. /** @hidden */
  40549. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40550. /**
  40551. * Creates an AxisDragGizmo
  40552. * @param gizmoLayer The utility layer the gizmo will be added to
  40553. * @param dragAxis The axis which the gizmo will be able to drag on
  40554. * @param color The color of the gizmo
  40555. */
  40556. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40557. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40558. /**
  40559. * Disposes of the gizmo
  40560. */
  40561. dispose(): void;
  40562. }
  40563. }
  40564. declare module BABYLON.Debug {
  40565. /**
  40566. * The Axes viewer will show 3 axes in a specific point in space
  40567. */
  40568. export class AxesViewer {
  40569. private _xAxis;
  40570. private _yAxis;
  40571. private _zAxis;
  40572. private _scaleLinesFactor;
  40573. private _instanced;
  40574. /**
  40575. * Gets the hosting scene
  40576. */
  40577. scene: Scene;
  40578. /**
  40579. * Gets or sets a number used to scale line length
  40580. */
  40581. scaleLines: number;
  40582. /** Gets the node hierarchy used to render x-axis */
  40583. readonly xAxis: TransformNode;
  40584. /** Gets the node hierarchy used to render y-axis */
  40585. readonly yAxis: TransformNode;
  40586. /** Gets the node hierarchy used to render z-axis */
  40587. readonly zAxis: TransformNode;
  40588. /**
  40589. * Creates a new AxesViewer
  40590. * @param scene defines the hosting scene
  40591. * @param scaleLines defines a number used to scale line length (1 by default)
  40592. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40593. * @param xAxis defines the node hierarchy used to render the x-axis
  40594. * @param yAxis defines the node hierarchy used to render the y-axis
  40595. * @param zAxis defines the node hierarchy used to render the z-axis
  40596. */
  40597. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40598. /**
  40599. * Force the viewer to update
  40600. * @param position defines the position of the viewer
  40601. * @param xaxis defines the x axis of the viewer
  40602. * @param yaxis defines the y axis of the viewer
  40603. * @param zaxis defines the z axis of the viewer
  40604. */
  40605. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40606. /**
  40607. * Creates an instance of this axes viewer.
  40608. * @returns a new axes viewer with instanced meshes
  40609. */
  40610. createInstance(): AxesViewer;
  40611. /** Releases resources */
  40612. dispose(): void;
  40613. private static _SetRenderingGroupId;
  40614. }
  40615. }
  40616. declare module BABYLON.Debug {
  40617. /**
  40618. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40619. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40620. */
  40621. export class BoneAxesViewer extends AxesViewer {
  40622. /**
  40623. * Gets or sets the target mesh where to display the axes viewer
  40624. */
  40625. mesh: Nullable<Mesh>;
  40626. /**
  40627. * Gets or sets the target bone where to display the axes viewer
  40628. */
  40629. bone: Nullable<Bone>;
  40630. /** Gets current position */
  40631. pos: Vector3;
  40632. /** Gets direction of X axis */
  40633. xaxis: Vector3;
  40634. /** Gets direction of Y axis */
  40635. yaxis: Vector3;
  40636. /** Gets direction of Z axis */
  40637. zaxis: Vector3;
  40638. /**
  40639. * Creates a new BoneAxesViewer
  40640. * @param scene defines the hosting scene
  40641. * @param bone defines the target bone
  40642. * @param mesh defines the target mesh
  40643. * @param scaleLines defines a scaling factor for line length (1 by default)
  40644. */
  40645. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40646. /**
  40647. * Force the viewer to update
  40648. */
  40649. update(): void;
  40650. /** Releases resources */
  40651. dispose(): void;
  40652. }
  40653. }
  40654. declare module BABYLON {
  40655. /**
  40656. * Interface used to define scene explorer extensibility option
  40657. */
  40658. export interface IExplorerExtensibilityOption {
  40659. /**
  40660. * Define the option label
  40661. */
  40662. label: string;
  40663. /**
  40664. * Defines the action to execute on click
  40665. */
  40666. action: (entity: any) => void;
  40667. }
  40668. /**
  40669. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40670. */
  40671. export interface IExplorerExtensibilityGroup {
  40672. /**
  40673. * Defines a predicate to test if a given type mut be extended
  40674. */
  40675. predicate: (entity: any) => boolean;
  40676. /**
  40677. * Gets the list of options added to a type
  40678. */
  40679. entries: IExplorerExtensibilityOption[];
  40680. }
  40681. /**
  40682. * Interface used to define the options to use to create the Inspector
  40683. */
  40684. export interface IInspectorOptions {
  40685. /**
  40686. * Display in overlay mode (default: false)
  40687. */
  40688. overlay?: boolean;
  40689. /**
  40690. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40691. */
  40692. globalRoot?: HTMLElement;
  40693. /**
  40694. * Display the Scene explorer
  40695. */
  40696. showExplorer?: boolean;
  40697. /**
  40698. * Display the property inspector
  40699. */
  40700. showInspector?: boolean;
  40701. /**
  40702. * Display in embed mode (both panes on the right)
  40703. */
  40704. embedMode?: boolean;
  40705. /**
  40706. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40707. */
  40708. handleResize?: boolean;
  40709. /**
  40710. * Allow the panes to popup (default: true)
  40711. */
  40712. enablePopup?: boolean;
  40713. /**
  40714. * Allow the panes to be closed by users (default: true)
  40715. */
  40716. enableClose?: boolean;
  40717. /**
  40718. * Optional list of extensibility entries
  40719. */
  40720. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40721. /**
  40722. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40723. */
  40724. inspectorURL?: string;
  40725. }
  40726. interface Scene {
  40727. /**
  40728. * @hidden
  40729. * Backing field
  40730. */
  40731. _debugLayer: DebugLayer;
  40732. /**
  40733. * Gets the debug layer (aka Inspector) associated with the scene
  40734. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40735. */
  40736. debugLayer: DebugLayer;
  40737. }
  40738. /**
  40739. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40740. * what is happening in your scene
  40741. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40742. */
  40743. export class DebugLayer {
  40744. /**
  40745. * Define the url to get the inspector script from.
  40746. * By default it uses the babylonjs CDN.
  40747. * @ignoreNaming
  40748. */
  40749. static InspectorURL: string;
  40750. private _scene;
  40751. private BJSINSPECTOR;
  40752. /**
  40753. * Observable triggered when a property is changed through the inspector.
  40754. */
  40755. onPropertyChangedObservable: Observable<{
  40756. object: any;
  40757. property: string;
  40758. value: any;
  40759. initialValue: any;
  40760. }>;
  40761. /**
  40762. * Instantiates a new debug layer.
  40763. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40764. * what is happening in your scene
  40765. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40766. * @param scene Defines the scene to inspect
  40767. */
  40768. constructor(scene: Scene);
  40769. /** Creates the inspector window. */
  40770. private _createInspector;
  40771. /**
  40772. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40773. * @param entity defines the entity to select
  40774. * @param lineContainerTitle defines the specific block to highlight
  40775. */
  40776. select(entity: any, lineContainerTitle?: string): void;
  40777. /** Get the inspector from bundle or global */
  40778. private _getGlobalInspector;
  40779. /**
  40780. * Get if the inspector is visible or not.
  40781. * @returns true if visible otherwise, false
  40782. */
  40783. isVisible(): boolean;
  40784. /**
  40785. * Hide the inspector and close its window.
  40786. */
  40787. hide(): void;
  40788. /**
  40789. * Launch the debugLayer.
  40790. * @param config Define the configuration of the inspector
  40791. * @return a promise fulfilled when the debug layer is visible
  40792. */
  40793. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40794. }
  40795. }
  40796. declare module BABYLON {
  40797. /**
  40798. * Class containing static functions to help procedurally build meshes
  40799. */
  40800. export class BoxBuilder {
  40801. /**
  40802. * Creates a box mesh
  40803. * * The parameter `size` sets the size (float) of each box side (default 1)
  40804. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40805. * * 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)
  40806. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40808. * * 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
  40809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40810. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40811. * @param name defines the name of the mesh
  40812. * @param options defines the options used to create the mesh
  40813. * @param scene defines the hosting scene
  40814. * @returns the box mesh
  40815. */
  40816. static CreateBox(name: string, options: {
  40817. size?: number;
  40818. width?: number;
  40819. height?: number;
  40820. depth?: number;
  40821. faceUV?: Vector4[];
  40822. faceColors?: Color4[];
  40823. sideOrientation?: number;
  40824. frontUVs?: Vector4;
  40825. backUVs?: Vector4;
  40826. wrap?: boolean;
  40827. topBaseAt?: number;
  40828. bottomBaseAt?: number;
  40829. updatable?: boolean;
  40830. }, scene?: Nullable<Scene>): Mesh;
  40831. }
  40832. }
  40833. declare module BABYLON {
  40834. /**
  40835. * Class containing static functions to help procedurally build meshes
  40836. */
  40837. export class SphereBuilder {
  40838. /**
  40839. * Creates a sphere mesh
  40840. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40841. * * 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`)
  40842. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40843. * * 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
  40844. * * 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)
  40845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40846. * * 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
  40847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40848. * @param name defines the name of the mesh
  40849. * @param options defines the options used to create the mesh
  40850. * @param scene defines the hosting scene
  40851. * @returns the sphere mesh
  40852. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40853. */
  40854. static CreateSphere(name: string, options: {
  40855. segments?: number;
  40856. diameter?: number;
  40857. diameterX?: number;
  40858. diameterY?: number;
  40859. diameterZ?: number;
  40860. arc?: number;
  40861. slice?: number;
  40862. sideOrientation?: number;
  40863. frontUVs?: Vector4;
  40864. backUVs?: Vector4;
  40865. updatable?: boolean;
  40866. }, scene: any): Mesh;
  40867. }
  40868. }
  40869. declare module BABYLON.Debug {
  40870. /**
  40871. * Used to show the physics impostor around the specific mesh
  40872. */
  40873. export class PhysicsViewer {
  40874. /** @hidden */
  40875. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40876. /** @hidden */
  40877. protected _meshes: Array<Nullable<AbstractMesh>>;
  40878. /** @hidden */
  40879. protected _scene: Nullable<Scene>;
  40880. /** @hidden */
  40881. protected _numMeshes: number;
  40882. /** @hidden */
  40883. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40884. private _renderFunction;
  40885. private _utilityLayer;
  40886. private _debugBoxMesh;
  40887. private _debugSphereMesh;
  40888. private _debugCylinderMesh;
  40889. private _debugMaterial;
  40890. private _debugMeshMeshes;
  40891. /**
  40892. * Creates a new PhysicsViewer
  40893. * @param scene defines the hosting scene
  40894. */
  40895. constructor(scene: Scene);
  40896. /** @hidden */
  40897. protected _updateDebugMeshes(): void;
  40898. /**
  40899. * Renders a specified physic impostor
  40900. * @param impostor defines the impostor to render
  40901. * @param targetMesh defines the mesh represented by the impostor
  40902. * @returns the new debug mesh used to render the impostor
  40903. */
  40904. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40905. /**
  40906. * Hides a specified physic impostor
  40907. * @param impostor defines the impostor to hide
  40908. */
  40909. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40910. private _getDebugMaterial;
  40911. private _getDebugBoxMesh;
  40912. private _getDebugSphereMesh;
  40913. private _getDebugCylinderMesh;
  40914. private _getDebugMeshMesh;
  40915. private _getDebugMesh;
  40916. /** Releases all resources */
  40917. dispose(): void;
  40918. }
  40919. }
  40920. declare module BABYLON {
  40921. /**
  40922. * Class containing static functions to help procedurally build meshes
  40923. */
  40924. export class LinesBuilder {
  40925. /**
  40926. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40927. * * 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
  40928. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40929. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40930. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40931. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40932. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40933. * * 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
  40934. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40937. * @param name defines the name of the new line system
  40938. * @param options defines the options used to create the line system
  40939. * @param scene defines the hosting scene
  40940. * @returns a new line system mesh
  40941. */
  40942. static CreateLineSystem(name: string, options: {
  40943. lines: Vector3[][];
  40944. updatable?: boolean;
  40945. instance?: Nullable<LinesMesh>;
  40946. colors?: Nullable<Color4[][]>;
  40947. useVertexAlpha?: boolean;
  40948. }, scene: Nullable<Scene>): LinesMesh;
  40949. /**
  40950. * Creates a line mesh
  40951. * 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
  40952. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40953. * * The parameter `points` is an array successive Vector3
  40954. * * 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
  40955. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40956. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40957. * * When updating an instance, remember that only point positions can change, not the number of points
  40958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40960. * @param name defines the name of the new line system
  40961. * @param options defines the options used to create the line system
  40962. * @param scene defines the hosting scene
  40963. * @returns a new line mesh
  40964. */
  40965. static CreateLines(name: string, options: {
  40966. points: Vector3[];
  40967. updatable?: boolean;
  40968. instance?: Nullable<LinesMesh>;
  40969. colors?: Color4[];
  40970. useVertexAlpha?: boolean;
  40971. }, scene?: Nullable<Scene>): LinesMesh;
  40972. /**
  40973. * Creates a dashed line mesh
  40974. * * 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
  40975. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40976. * * The parameter `points` is an array successive Vector3
  40977. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40978. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40979. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40980. * * 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
  40981. * * When updating an instance, remember that only point positions can change, not the number of points
  40982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40983. * @param name defines the name of the mesh
  40984. * @param options defines the options used to create the mesh
  40985. * @param scene defines the hosting scene
  40986. * @returns the dashed line mesh
  40987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40988. */
  40989. static CreateDashedLines(name: string, options: {
  40990. points: Vector3[];
  40991. dashSize?: number;
  40992. gapSize?: number;
  40993. dashNb?: number;
  40994. updatable?: boolean;
  40995. instance?: LinesMesh;
  40996. }, scene?: Nullable<Scene>): LinesMesh;
  40997. }
  40998. }
  40999. declare module BABYLON {
  41000. /**
  41001. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41002. * in order to better appreciate the issue one might have.
  41003. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41004. */
  41005. export class RayHelper {
  41006. /**
  41007. * Defines the ray we are currently tryin to visualize.
  41008. */
  41009. ray: Nullable<Ray>;
  41010. private _renderPoints;
  41011. private _renderLine;
  41012. private _renderFunction;
  41013. private _scene;
  41014. private _updateToMeshFunction;
  41015. private _attachedToMesh;
  41016. private _meshSpaceDirection;
  41017. private _meshSpaceOrigin;
  41018. /**
  41019. * Helper function to create a colored helper in a scene in one line.
  41020. * @param ray Defines the ray we are currently tryin to visualize
  41021. * @param scene Defines the scene the ray is used in
  41022. * @param color Defines the color we want to see the ray in
  41023. * @returns The newly created ray helper.
  41024. */
  41025. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41026. /**
  41027. * Instantiate a new ray helper.
  41028. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41029. * in order to better appreciate the issue one might have.
  41030. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41031. * @param ray Defines the ray we are currently tryin to visualize
  41032. */
  41033. constructor(ray: Ray);
  41034. /**
  41035. * Shows the ray we are willing to debug.
  41036. * @param scene Defines the scene the ray needs to be rendered in
  41037. * @param color Defines the color the ray needs to be rendered in
  41038. */
  41039. show(scene: Scene, color?: Color3): void;
  41040. /**
  41041. * Hides the ray we are debugging.
  41042. */
  41043. hide(): void;
  41044. private _render;
  41045. /**
  41046. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41047. * @param mesh Defines the mesh we want the helper attached to
  41048. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41049. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41050. * @param length Defines the length of the ray
  41051. */
  41052. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41053. /**
  41054. * Detach the ray helper from the mesh it has previously been attached to.
  41055. */
  41056. detachFromMesh(): void;
  41057. private _updateToMesh;
  41058. /**
  41059. * Dispose the helper and release its associated resources.
  41060. */
  41061. dispose(): void;
  41062. }
  41063. }
  41064. declare module BABYLON.Debug {
  41065. /**
  41066. * Class used to render a debug view of a given skeleton
  41067. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41068. */
  41069. export class SkeletonViewer {
  41070. /** defines the skeleton to render */
  41071. skeleton: Skeleton;
  41072. /** defines the mesh attached to the skeleton */
  41073. mesh: AbstractMesh;
  41074. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41075. autoUpdateBonesMatrices: boolean;
  41076. /** defines the rendering group id to use with the viewer */
  41077. renderingGroupId: number;
  41078. /** Gets or sets the color used to render the skeleton */
  41079. color: Color3;
  41080. private _scene;
  41081. private _debugLines;
  41082. private _debugMesh;
  41083. private _isEnabled;
  41084. private _renderFunction;
  41085. private _utilityLayer;
  41086. /**
  41087. * Returns the mesh used to render the bones
  41088. */
  41089. readonly debugMesh: Nullable<LinesMesh>;
  41090. /**
  41091. * Creates a new SkeletonViewer
  41092. * @param skeleton defines the skeleton to render
  41093. * @param mesh defines the mesh attached to the skeleton
  41094. * @param scene defines the hosting scene
  41095. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41096. * @param renderingGroupId defines the rendering group id to use with the viewer
  41097. */
  41098. constructor(
  41099. /** defines the skeleton to render */
  41100. skeleton: Skeleton,
  41101. /** defines the mesh attached to the skeleton */
  41102. mesh: AbstractMesh, scene: Scene,
  41103. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41104. autoUpdateBonesMatrices?: boolean,
  41105. /** defines the rendering group id to use with the viewer */
  41106. renderingGroupId?: number);
  41107. /** Gets or sets a boolean indicating if the viewer is enabled */
  41108. isEnabled: boolean;
  41109. private _getBonePosition;
  41110. private _getLinesForBonesWithLength;
  41111. private _getLinesForBonesNoLength;
  41112. /** Update the viewer to sync with current skeleton state */
  41113. update(): void;
  41114. /** Release associated resources */
  41115. dispose(): void;
  41116. }
  41117. }
  41118. declare module BABYLON {
  41119. /**
  41120. * Options to create the null engine
  41121. */
  41122. export class NullEngineOptions {
  41123. /**
  41124. * Render width (Default: 512)
  41125. */
  41126. renderWidth: number;
  41127. /**
  41128. * Render height (Default: 256)
  41129. */
  41130. renderHeight: number;
  41131. /**
  41132. * Texture size (Default: 512)
  41133. */
  41134. textureSize: number;
  41135. /**
  41136. * If delta time between frames should be constant
  41137. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41138. */
  41139. deterministicLockstep: boolean;
  41140. /**
  41141. * Maximum about of steps between frames (Default: 4)
  41142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41143. */
  41144. lockstepMaxSteps: number;
  41145. }
  41146. /**
  41147. * The null engine class provides support for headless version of babylon.js.
  41148. * This can be used in server side scenario or for testing purposes
  41149. */
  41150. export class NullEngine extends Engine {
  41151. private _options;
  41152. /**
  41153. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41154. */
  41155. isDeterministicLockStep(): boolean;
  41156. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41157. getLockstepMaxSteps(): number;
  41158. /**
  41159. * Sets hardware scaling, used to save performance if needed
  41160. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41161. */
  41162. getHardwareScalingLevel(): number;
  41163. constructor(options?: NullEngineOptions);
  41164. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41165. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41166. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41167. getRenderWidth(useScreen?: boolean): number;
  41168. getRenderHeight(useScreen?: boolean): number;
  41169. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41170. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41171. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41172. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41173. bindSamplers(effect: Effect): void;
  41174. enableEffect(effect: Effect): void;
  41175. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41176. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41177. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41178. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41179. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41180. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41181. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41182. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41183. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41184. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41185. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41186. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41187. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41188. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41189. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41190. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41191. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41192. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41193. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41194. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41195. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41196. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41197. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41198. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41199. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41200. bindBuffers(vertexBuffers: {
  41201. [key: string]: VertexBuffer;
  41202. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41203. wipeCaches(bruteForce?: boolean): void;
  41204. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41205. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41206. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41207. /** @hidden */
  41208. _createTexture(): WebGLTexture;
  41209. /** @hidden */
  41210. _releaseTexture(texture: InternalTexture): void;
  41211. 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;
  41212. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41213. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41214. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41215. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41216. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41217. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41218. areAllEffectsReady(): boolean;
  41219. /**
  41220. * @hidden
  41221. * Get the current error code of the webGL context
  41222. * @returns the error code
  41223. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41224. */
  41225. getError(): number;
  41226. /** @hidden */
  41227. _getUnpackAlignement(): number;
  41228. /** @hidden */
  41229. _unpackFlipY(value: boolean): void;
  41230. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41231. /**
  41232. * Updates a dynamic vertex buffer.
  41233. * @param vertexBuffer the vertex buffer to update
  41234. * @param data the data used to update the vertex buffer
  41235. * @param byteOffset the byte offset of the data (optional)
  41236. * @param byteLength the byte length of the data (optional)
  41237. */
  41238. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41239. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41240. /** @hidden */
  41241. _bindTexture(channel: number, texture: InternalTexture): void;
  41242. /** @hidden */
  41243. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41244. releaseEffects(): void;
  41245. displayLoadingUI(): void;
  41246. hideLoadingUI(): void;
  41247. /** @hidden */
  41248. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41249. /** @hidden */
  41250. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41251. /** @hidden */
  41252. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41253. /** @hidden */
  41254. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41255. }
  41256. }
  41257. declare module BABYLON {
  41258. /** @hidden */
  41259. export class _OcclusionDataStorage {
  41260. /** @hidden */
  41261. occlusionInternalRetryCounter: number;
  41262. /** @hidden */
  41263. isOcclusionQueryInProgress: boolean;
  41264. /** @hidden */
  41265. isOccluded: boolean;
  41266. /** @hidden */
  41267. occlusionRetryCount: number;
  41268. /** @hidden */
  41269. occlusionType: number;
  41270. /** @hidden */
  41271. occlusionQueryAlgorithmType: number;
  41272. }
  41273. interface Engine {
  41274. /**
  41275. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41276. * @return the new query
  41277. */
  41278. createQuery(): WebGLQuery;
  41279. /**
  41280. * Delete and release a webGL query
  41281. * @param query defines the query to delete
  41282. * @return the current engine
  41283. */
  41284. deleteQuery(query: WebGLQuery): Engine;
  41285. /**
  41286. * Check if a given query has resolved and got its value
  41287. * @param query defines the query to check
  41288. * @returns true if the query got its value
  41289. */
  41290. isQueryResultAvailable(query: WebGLQuery): boolean;
  41291. /**
  41292. * Gets the value of a given query
  41293. * @param query defines the query to check
  41294. * @returns the value of the query
  41295. */
  41296. getQueryResult(query: WebGLQuery): number;
  41297. /**
  41298. * Initiates an occlusion query
  41299. * @param algorithmType defines the algorithm to use
  41300. * @param query defines the query to use
  41301. * @returns the current engine
  41302. * @see http://doc.babylonjs.com/features/occlusionquery
  41303. */
  41304. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41305. /**
  41306. * Ends an occlusion query
  41307. * @see http://doc.babylonjs.com/features/occlusionquery
  41308. * @param algorithmType defines the algorithm to use
  41309. * @returns the current engine
  41310. */
  41311. endOcclusionQuery(algorithmType: number): Engine;
  41312. /**
  41313. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41314. * Please note that only one query can be issued at a time
  41315. * @returns a time token used to track the time span
  41316. */
  41317. startTimeQuery(): Nullable<_TimeToken>;
  41318. /**
  41319. * Ends a time query
  41320. * @param token defines the token used to measure the time span
  41321. * @returns the time spent (in ns)
  41322. */
  41323. endTimeQuery(token: _TimeToken): int;
  41324. /** @hidden */
  41325. _currentNonTimestampToken: Nullable<_TimeToken>;
  41326. /** @hidden */
  41327. _createTimeQuery(): WebGLQuery;
  41328. /** @hidden */
  41329. _deleteTimeQuery(query: WebGLQuery): void;
  41330. /** @hidden */
  41331. _getGlAlgorithmType(algorithmType: number): number;
  41332. /** @hidden */
  41333. _getTimeQueryResult(query: WebGLQuery): any;
  41334. /** @hidden */
  41335. _getTimeQueryAvailability(query: WebGLQuery): any;
  41336. }
  41337. interface AbstractMesh {
  41338. /**
  41339. * Backing filed
  41340. * @hidden
  41341. */
  41342. __occlusionDataStorage: _OcclusionDataStorage;
  41343. /**
  41344. * Access property
  41345. * @hidden
  41346. */
  41347. _occlusionDataStorage: _OcclusionDataStorage;
  41348. /**
  41349. * 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.
  41350. * The default value is -1 which means don't break the query and wait till the result
  41351. * @see http://doc.babylonjs.com/features/occlusionquery
  41352. */
  41353. occlusionRetryCount: number;
  41354. /**
  41355. * 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:
  41356. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41357. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41358. * * 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.
  41359. * @see http://doc.babylonjs.com/features/occlusionquery
  41360. */
  41361. occlusionType: number;
  41362. /**
  41363. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41364. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41365. * * 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.
  41366. * @see http://doc.babylonjs.com/features/occlusionquery
  41367. */
  41368. occlusionQueryAlgorithmType: number;
  41369. /**
  41370. * 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
  41371. * @see http://doc.babylonjs.com/features/occlusionquery
  41372. */
  41373. isOccluded: boolean;
  41374. /**
  41375. * Flag to check the progress status of the query
  41376. * @see http://doc.babylonjs.com/features/occlusionquery
  41377. */
  41378. isOcclusionQueryInProgress: boolean;
  41379. }
  41380. }
  41381. declare module BABYLON {
  41382. /** @hidden */
  41383. export var _forceTransformFeedbackToBundle: boolean;
  41384. interface Engine {
  41385. /**
  41386. * Creates a webGL transform feedback object
  41387. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41388. * @returns the webGL transform feedback object
  41389. */
  41390. createTransformFeedback(): WebGLTransformFeedback;
  41391. /**
  41392. * Delete a webGL transform feedback object
  41393. * @param value defines the webGL transform feedback object to delete
  41394. */
  41395. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41396. /**
  41397. * Bind a webGL transform feedback object to the webgl context
  41398. * @param value defines the webGL transform feedback object to bind
  41399. */
  41400. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41401. /**
  41402. * Begins a transform feedback operation
  41403. * @param usePoints defines if points or triangles must be used
  41404. */
  41405. beginTransformFeedback(usePoints: boolean): void;
  41406. /**
  41407. * Ends a transform feedback operation
  41408. */
  41409. endTransformFeedback(): void;
  41410. /**
  41411. * Specify the varyings to use with transform feedback
  41412. * @param program defines the associated webGL program
  41413. * @param value defines the list of strings representing the varying names
  41414. */
  41415. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41416. /**
  41417. * Bind a webGL buffer for a transform feedback operation
  41418. * @param value defines the webGL buffer to bind
  41419. */
  41420. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41421. }
  41422. }
  41423. declare module BABYLON {
  41424. /**
  41425. * Gather the list of clipboard event types as constants.
  41426. */
  41427. export class ClipboardEventTypes {
  41428. /**
  41429. * The clipboard event is fired when a copy command is active (pressed).
  41430. */
  41431. static readonly COPY: number;
  41432. /**
  41433. * The clipboard event is fired when a cut command is active (pressed).
  41434. */
  41435. static readonly CUT: number;
  41436. /**
  41437. * The clipboard event is fired when a paste command is active (pressed).
  41438. */
  41439. static readonly PASTE: number;
  41440. }
  41441. /**
  41442. * This class is used to store clipboard related info for the onClipboardObservable event.
  41443. */
  41444. export class ClipboardInfo {
  41445. /**
  41446. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41447. */
  41448. type: number;
  41449. /**
  41450. * Defines the related dom event
  41451. */
  41452. event: ClipboardEvent;
  41453. /**
  41454. *Creates an instance of ClipboardInfo.
  41455. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41456. * @param event Defines the related dom event
  41457. */
  41458. constructor(
  41459. /**
  41460. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41461. */
  41462. type: number,
  41463. /**
  41464. * Defines the related dom event
  41465. */
  41466. event: ClipboardEvent);
  41467. /**
  41468. * Get the clipboard event's type from the keycode.
  41469. * @param keyCode Defines the keyCode for the current keyboard event.
  41470. * @return {number}
  41471. */
  41472. static GetTypeFromCharacter(keyCode: number): number;
  41473. }
  41474. }
  41475. declare module BABYLON {
  41476. /**
  41477. * Class used to represent data loading progression
  41478. */
  41479. export class SceneLoaderProgressEvent {
  41480. /** defines if data length to load can be evaluated */
  41481. readonly lengthComputable: boolean;
  41482. /** defines the loaded data length */
  41483. readonly loaded: number;
  41484. /** defines the data length to load */
  41485. readonly total: number;
  41486. /**
  41487. * Create a new progress event
  41488. * @param lengthComputable defines if data length to load can be evaluated
  41489. * @param loaded defines the loaded data length
  41490. * @param total defines the data length to load
  41491. */
  41492. constructor(
  41493. /** defines if data length to load can be evaluated */
  41494. lengthComputable: boolean,
  41495. /** defines the loaded data length */
  41496. loaded: number,
  41497. /** defines the data length to load */
  41498. total: number);
  41499. /**
  41500. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41501. * @param event defines the source event
  41502. * @returns a new SceneLoaderProgressEvent
  41503. */
  41504. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41505. }
  41506. /**
  41507. * Interface used by SceneLoader plugins to define supported file extensions
  41508. */
  41509. export interface ISceneLoaderPluginExtensions {
  41510. /**
  41511. * Defines the list of supported extensions
  41512. */
  41513. [extension: string]: {
  41514. isBinary: boolean;
  41515. };
  41516. }
  41517. /**
  41518. * Interface used by SceneLoader plugin factory
  41519. */
  41520. export interface ISceneLoaderPluginFactory {
  41521. /**
  41522. * Defines the name of the factory
  41523. */
  41524. name: string;
  41525. /**
  41526. * Function called to create a new plugin
  41527. * @return the new plugin
  41528. */
  41529. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41530. /**
  41531. * Boolean indicating if the plugin can direct load specific data
  41532. */
  41533. canDirectLoad?: (data: string) => boolean;
  41534. }
  41535. /**
  41536. * Interface used to define a SceneLoader plugin
  41537. */
  41538. export interface ISceneLoaderPlugin {
  41539. /**
  41540. * The friendly name of this plugin.
  41541. */
  41542. name: string;
  41543. /**
  41544. * The file extensions supported by this plugin.
  41545. */
  41546. extensions: string | ISceneLoaderPluginExtensions;
  41547. /**
  41548. * Import meshes into a scene.
  41549. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41550. * @param scene The scene to import into
  41551. * @param data The data to import
  41552. * @param rootUrl The root url for scene and resources
  41553. * @param meshes The meshes array to import into
  41554. * @param particleSystems The particle systems array to import into
  41555. * @param skeletons The skeletons array to import into
  41556. * @param onError The callback when import fails
  41557. * @returns True if successful or false otherwise
  41558. */
  41559. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41560. /**
  41561. * Load into a scene.
  41562. * @param scene The scene to load into
  41563. * @param data The data to import
  41564. * @param rootUrl The root url for scene and resources
  41565. * @param onError The callback when import fails
  41566. * @returns true if successful or false otherwise
  41567. */
  41568. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41569. /**
  41570. * The callback that returns true if the data can be directly loaded.
  41571. */
  41572. canDirectLoad?: (data: string) => boolean;
  41573. /**
  41574. * The callback that allows custom handling of the root url based on the response url.
  41575. */
  41576. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41577. /**
  41578. * Load into an asset container.
  41579. * @param scene The scene to load into
  41580. * @param data The data to import
  41581. * @param rootUrl The root url for scene and resources
  41582. * @param onError The callback when import fails
  41583. * @returns The loaded asset container
  41584. */
  41585. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41586. }
  41587. /**
  41588. * Interface used to define an async SceneLoader plugin
  41589. */
  41590. export interface ISceneLoaderPluginAsync {
  41591. /**
  41592. * The friendly name of this plugin.
  41593. */
  41594. name: string;
  41595. /**
  41596. * The file extensions supported by this plugin.
  41597. */
  41598. extensions: string | ISceneLoaderPluginExtensions;
  41599. /**
  41600. * Import meshes into a scene.
  41601. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41602. * @param scene The scene to import into
  41603. * @param data The data to import
  41604. * @param rootUrl The root url for scene and resources
  41605. * @param onProgress The callback when the load progresses
  41606. * @param fileName Defines the name of the file to load
  41607. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41608. */
  41609. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41610. meshes: AbstractMesh[];
  41611. particleSystems: IParticleSystem[];
  41612. skeletons: Skeleton[];
  41613. animationGroups: AnimationGroup[];
  41614. }>;
  41615. /**
  41616. * Load into a scene.
  41617. * @param scene The scene to load into
  41618. * @param data The data to import
  41619. * @param rootUrl The root url for scene and resources
  41620. * @param onProgress The callback when the load progresses
  41621. * @param fileName Defines the name of the file to load
  41622. * @returns Nothing
  41623. */
  41624. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41625. /**
  41626. * The callback that returns true if the data can be directly loaded.
  41627. */
  41628. canDirectLoad?: (data: string) => boolean;
  41629. /**
  41630. * The callback that allows custom handling of the root url based on the response url.
  41631. */
  41632. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41633. /**
  41634. * Load into an asset container.
  41635. * @param scene The scene to load into
  41636. * @param data The data to import
  41637. * @param rootUrl The root url for scene and resources
  41638. * @param onProgress The callback when the load progresses
  41639. * @param fileName Defines the name of the file to load
  41640. * @returns The loaded asset container
  41641. */
  41642. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41643. }
  41644. /**
  41645. * Class used to load scene from various file formats using registered plugins
  41646. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41647. */
  41648. export class SceneLoader {
  41649. /**
  41650. * No logging while loading
  41651. */
  41652. static readonly NO_LOGGING: number;
  41653. /**
  41654. * Minimal logging while loading
  41655. */
  41656. static readonly MINIMAL_LOGGING: number;
  41657. /**
  41658. * Summary logging while loading
  41659. */
  41660. static readonly SUMMARY_LOGGING: number;
  41661. /**
  41662. * Detailled logging while loading
  41663. */
  41664. static readonly DETAILED_LOGGING: number;
  41665. /**
  41666. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41667. */
  41668. static ForceFullSceneLoadingForIncremental: boolean;
  41669. /**
  41670. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41671. */
  41672. static ShowLoadingScreen: boolean;
  41673. /**
  41674. * Defines the current logging level (while loading the scene)
  41675. * @ignorenaming
  41676. */
  41677. static loggingLevel: number;
  41678. /**
  41679. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41680. */
  41681. static CleanBoneMatrixWeights: boolean;
  41682. /**
  41683. * Event raised when a plugin is used to load a scene
  41684. */
  41685. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41686. private static _registeredPlugins;
  41687. private static _getDefaultPlugin;
  41688. private static _getPluginForExtension;
  41689. private static _getPluginForDirectLoad;
  41690. private static _getPluginForFilename;
  41691. private static _getDirectLoad;
  41692. private static _loadData;
  41693. private static _getFileInfo;
  41694. /**
  41695. * Gets a plugin that can load the given extension
  41696. * @param extension defines the extension to load
  41697. * @returns a plugin or null if none works
  41698. */
  41699. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41700. /**
  41701. * Gets a boolean indicating that the given extension can be loaded
  41702. * @param extension defines the extension to load
  41703. * @returns true if the extension is supported
  41704. */
  41705. static IsPluginForExtensionAvailable(extension: string): boolean;
  41706. /**
  41707. * Adds a new plugin to the list of registered plugins
  41708. * @param plugin defines the plugin to add
  41709. */
  41710. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41711. /**
  41712. * Import meshes into a scene
  41713. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41714. * @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)
  41715. * @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)
  41716. * @param scene the instance of BABYLON.Scene to append to
  41717. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41718. * @param onProgress a callback with a progress event for each file being loaded
  41719. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41720. * @param pluginExtension the extension used to determine the plugin
  41721. * @returns The loaded plugin
  41722. */
  41723. 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>;
  41724. /**
  41725. * Import meshes into a scene
  41726. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41727. * @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)
  41728. * @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)
  41729. * @param scene the instance of BABYLON.Scene to append to
  41730. * @param onProgress a callback with a progress event for each file being loaded
  41731. * @param pluginExtension the extension used to determine the plugin
  41732. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41733. */
  41734. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41735. meshes: AbstractMesh[];
  41736. particleSystems: IParticleSystem[];
  41737. skeletons: Skeleton[];
  41738. animationGroups: AnimationGroup[];
  41739. }>;
  41740. /**
  41741. * Load a scene
  41742. * @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)
  41743. * @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)
  41744. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41745. * @param onSuccess a callback with the scene when import succeeds
  41746. * @param onProgress a callback with a progress event for each file being loaded
  41747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41748. * @param pluginExtension the extension used to determine the plugin
  41749. * @returns The loaded plugin
  41750. */
  41751. 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>;
  41752. /**
  41753. * Load a scene
  41754. * @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)
  41755. * @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)
  41756. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41757. * @param onProgress a callback with a progress event for each file being loaded
  41758. * @param pluginExtension the extension used to determine the plugin
  41759. * @returns The loaded scene
  41760. */
  41761. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41762. /**
  41763. * Append a scene
  41764. * @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)
  41765. * @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)
  41766. * @param scene is the instance of BABYLON.Scene to append to
  41767. * @param onSuccess a callback with the scene when import succeeds
  41768. * @param onProgress a callback with a progress event for each file being loaded
  41769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41770. * @param pluginExtension the extension used to determine the plugin
  41771. * @returns The loaded plugin
  41772. */
  41773. 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>;
  41774. /**
  41775. * Append a scene
  41776. * @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)
  41777. * @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)
  41778. * @param scene is the instance of BABYLON.Scene to append to
  41779. * @param onProgress a callback with a progress event for each file being loaded
  41780. * @param pluginExtension the extension used to determine the plugin
  41781. * @returns The given scene
  41782. */
  41783. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41784. /**
  41785. * Load a scene into an asset container
  41786. * @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)
  41787. * @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)
  41788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41789. * @param onSuccess a callback with the scene when import succeeds
  41790. * @param onProgress a callback with a progress event for each file being loaded
  41791. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41792. * @param pluginExtension the extension used to determine the plugin
  41793. * @returns The loaded plugin
  41794. */
  41795. 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>;
  41796. /**
  41797. * Load a scene into an asset container
  41798. * @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)
  41799. * @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)
  41800. * @param scene is the instance of Scene to append to
  41801. * @param onProgress a callback with a progress event for each file being loaded
  41802. * @param pluginExtension the extension used to determine the plugin
  41803. * @returns The loaded asset container
  41804. */
  41805. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41806. }
  41807. }
  41808. declare module BABYLON {
  41809. /**
  41810. * Google Daydream controller
  41811. */
  41812. export class DaydreamController extends WebVRController {
  41813. /**
  41814. * Base Url for the controller model.
  41815. */
  41816. static MODEL_BASE_URL: string;
  41817. /**
  41818. * File name for the controller model.
  41819. */
  41820. static MODEL_FILENAME: string;
  41821. /**
  41822. * Gamepad Id prefix used to identify Daydream Controller.
  41823. */
  41824. static readonly GAMEPAD_ID_PREFIX: string;
  41825. /**
  41826. * Creates a new DaydreamController from a gamepad
  41827. * @param vrGamepad the gamepad that the controller should be created from
  41828. */
  41829. constructor(vrGamepad: any);
  41830. /**
  41831. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41832. * @param scene scene in which to add meshes
  41833. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41834. */
  41835. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41836. /**
  41837. * Called once for each button that changed state since the last frame
  41838. * @param buttonIdx Which button index changed
  41839. * @param state New state of the button
  41840. * @param changes Which properties on the state changed since last frame
  41841. */
  41842. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41843. }
  41844. }
  41845. declare module BABYLON {
  41846. /**
  41847. * Gear VR Controller
  41848. */
  41849. export class GearVRController extends WebVRController {
  41850. /**
  41851. * Base Url for the controller model.
  41852. */
  41853. static MODEL_BASE_URL: string;
  41854. /**
  41855. * File name for the controller model.
  41856. */
  41857. static MODEL_FILENAME: string;
  41858. /**
  41859. * Gamepad Id prefix used to identify this controller.
  41860. */
  41861. static readonly GAMEPAD_ID_PREFIX: string;
  41862. private readonly _buttonIndexToObservableNameMap;
  41863. /**
  41864. * Creates a new GearVRController from a gamepad
  41865. * @param vrGamepad the gamepad that the controller should be created from
  41866. */
  41867. constructor(vrGamepad: any);
  41868. /**
  41869. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41870. * @param scene scene in which to add meshes
  41871. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41872. */
  41873. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41874. /**
  41875. * Called once for each button that changed state since the last frame
  41876. * @param buttonIdx Which button index changed
  41877. * @param state New state of the button
  41878. * @param changes Which properties on the state changed since last frame
  41879. */
  41880. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41881. }
  41882. }
  41883. declare module BABYLON {
  41884. /**
  41885. * Generic Controller
  41886. */
  41887. export class GenericController extends WebVRController {
  41888. /**
  41889. * Base Url for the controller model.
  41890. */
  41891. static readonly MODEL_BASE_URL: string;
  41892. /**
  41893. * File name for the controller model.
  41894. */
  41895. static readonly MODEL_FILENAME: string;
  41896. /**
  41897. * Creates a new GenericController from a gamepad
  41898. * @param vrGamepad the gamepad that the controller should be created from
  41899. */
  41900. constructor(vrGamepad: any);
  41901. /**
  41902. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41903. * @param scene scene in which to add meshes
  41904. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41905. */
  41906. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41907. /**
  41908. * Called once for each button that changed state since the last frame
  41909. * @param buttonIdx Which button index changed
  41910. * @param state New state of the button
  41911. * @param changes Which properties on the state changed since last frame
  41912. */
  41913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41914. }
  41915. }
  41916. declare module BABYLON {
  41917. /**
  41918. * Oculus Touch Controller
  41919. */
  41920. export class OculusTouchController extends WebVRController {
  41921. /**
  41922. * Base Url for the controller model.
  41923. */
  41924. static MODEL_BASE_URL: string;
  41925. /**
  41926. * File name for the left controller model.
  41927. */
  41928. static MODEL_LEFT_FILENAME: string;
  41929. /**
  41930. * File name for the right controller model.
  41931. */
  41932. static MODEL_RIGHT_FILENAME: string;
  41933. /**
  41934. * Fired when the secondary trigger on this controller is modified
  41935. */
  41936. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41937. /**
  41938. * Fired when the thumb rest on this controller is modified
  41939. */
  41940. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41941. /**
  41942. * Creates a new OculusTouchController from a gamepad
  41943. * @param vrGamepad the gamepad that the controller should be created from
  41944. */
  41945. constructor(vrGamepad: any);
  41946. /**
  41947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41948. * @param scene scene in which to add meshes
  41949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41950. */
  41951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41952. /**
  41953. * Fired when the A button on this controller is modified
  41954. */
  41955. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41956. /**
  41957. * Fired when the B button on this controller is modified
  41958. */
  41959. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41960. /**
  41961. * Fired when the X button on this controller is modified
  41962. */
  41963. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41964. /**
  41965. * Fired when the Y button on this controller is modified
  41966. */
  41967. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41968. /**
  41969. * Called once for each button that changed state since the last frame
  41970. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41971. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41972. * 2) secondary trigger (same)
  41973. * 3) A (right) X (left), touch, pressed = value
  41974. * 4) B / Y
  41975. * 5) thumb rest
  41976. * @param buttonIdx Which button index changed
  41977. * @param state New state of the button
  41978. * @param changes Which properties on the state changed since last frame
  41979. */
  41980. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41981. }
  41982. }
  41983. declare module BABYLON {
  41984. /**
  41985. * Vive Controller
  41986. */
  41987. export class ViveController extends WebVRController {
  41988. /**
  41989. * Base Url for the controller model.
  41990. */
  41991. static MODEL_BASE_URL: string;
  41992. /**
  41993. * File name for the controller model.
  41994. */
  41995. static MODEL_FILENAME: string;
  41996. /**
  41997. * Creates a new ViveController from a gamepad
  41998. * @param vrGamepad the gamepad that the controller should be created from
  41999. */
  42000. constructor(vrGamepad: any);
  42001. /**
  42002. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42003. * @param scene scene in which to add meshes
  42004. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42005. */
  42006. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42007. /**
  42008. * Fired when the left button on this controller is modified
  42009. */
  42010. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42011. /**
  42012. * Fired when the right button on this controller is modified
  42013. */
  42014. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42015. /**
  42016. * Fired when the menu button on this controller is modified
  42017. */
  42018. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42019. /**
  42020. * Called once for each button that changed state since the last frame
  42021. * Vive mapping:
  42022. * 0: touchpad
  42023. * 1: trigger
  42024. * 2: left AND right buttons
  42025. * 3: menu button
  42026. * @param buttonIdx Which button index changed
  42027. * @param state New state of the button
  42028. * @param changes Which properties on the state changed since last frame
  42029. */
  42030. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42031. }
  42032. }
  42033. declare module BABYLON {
  42034. /**
  42035. * Defines the WindowsMotionController object that the state of the windows motion controller
  42036. */
  42037. export class WindowsMotionController extends WebVRController {
  42038. /**
  42039. * The base url used to load the left and right controller models
  42040. */
  42041. static MODEL_BASE_URL: string;
  42042. /**
  42043. * The name of the left controller model file
  42044. */
  42045. static MODEL_LEFT_FILENAME: string;
  42046. /**
  42047. * The name of the right controller model file
  42048. */
  42049. static MODEL_RIGHT_FILENAME: string;
  42050. /**
  42051. * The controller name prefix for this controller type
  42052. */
  42053. static readonly GAMEPAD_ID_PREFIX: string;
  42054. /**
  42055. * The controller id pattern for this controller type
  42056. */
  42057. private static readonly GAMEPAD_ID_PATTERN;
  42058. private _loadedMeshInfo;
  42059. private readonly _mapping;
  42060. /**
  42061. * Fired when the trackpad on this controller is clicked
  42062. */
  42063. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42064. /**
  42065. * Fired when the trackpad on this controller is modified
  42066. */
  42067. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42068. /**
  42069. * The current x and y values of this controller's trackpad
  42070. */
  42071. trackpad: StickValues;
  42072. /**
  42073. * Creates a new WindowsMotionController from a gamepad
  42074. * @param vrGamepad the gamepad that the controller should be created from
  42075. */
  42076. constructor(vrGamepad: any);
  42077. /**
  42078. * Fired when the trigger on this controller is modified
  42079. */
  42080. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42081. /**
  42082. * Fired when the menu button on this controller is modified
  42083. */
  42084. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42085. /**
  42086. * Fired when the grip button on this controller is modified
  42087. */
  42088. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42089. /**
  42090. * Fired when the thumbstick button on this controller is modified
  42091. */
  42092. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42093. /**
  42094. * Fired when the touchpad button on this controller is modified
  42095. */
  42096. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42097. /**
  42098. * Fired when the touchpad values on this controller are modified
  42099. */
  42100. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42101. private _updateTrackpad;
  42102. /**
  42103. * Called once per frame by the engine.
  42104. */
  42105. update(): void;
  42106. /**
  42107. * Called once for each button that changed state since the last frame
  42108. * @param buttonIdx Which button index changed
  42109. * @param state New state of the button
  42110. * @param changes Which properties on the state changed since last frame
  42111. */
  42112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42113. /**
  42114. * Moves the buttons on the controller mesh based on their current state
  42115. * @param buttonName the name of the button to move
  42116. * @param buttonValue the value of the button which determines the buttons new position
  42117. */
  42118. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42119. /**
  42120. * Moves the axis on the controller mesh based on its current state
  42121. * @param axis the index of the axis
  42122. * @param axisValue the value of the axis which determines the meshes new position
  42123. * @hidden
  42124. */
  42125. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42126. /**
  42127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42128. * @param scene scene in which to add meshes
  42129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42130. */
  42131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42132. /**
  42133. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42134. * can be transformed by button presses and axes values, based on this._mapping.
  42135. *
  42136. * @param scene scene in which the meshes exist
  42137. * @param meshes list of meshes that make up the controller model to process
  42138. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42139. */
  42140. private processModel;
  42141. private createMeshInfo;
  42142. /**
  42143. * Gets the ray of the controller in the direction the controller is pointing
  42144. * @param length the length the resulting ray should be
  42145. * @returns a ray in the direction the controller is pointing
  42146. */
  42147. getForwardRay(length?: number): Ray;
  42148. /**
  42149. * Disposes of the controller
  42150. */
  42151. dispose(): void;
  42152. }
  42153. }
  42154. declare module BABYLON {
  42155. /**
  42156. * Single axis scale gizmo
  42157. */
  42158. export class AxisScaleGizmo extends Gizmo {
  42159. private _coloredMaterial;
  42160. /**
  42161. * Drag behavior responsible for the gizmos dragging interactions
  42162. */
  42163. dragBehavior: PointerDragBehavior;
  42164. private _pointerObserver;
  42165. /**
  42166. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42167. */
  42168. snapDistance: number;
  42169. /**
  42170. * Event that fires each time the gizmo snaps to a new location.
  42171. * * snapDistance is the the change in distance
  42172. */
  42173. onSnapObservable: Observable<{
  42174. snapDistance: number;
  42175. }>;
  42176. /**
  42177. * If the scaling operation should be done on all axis (default: false)
  42178. */
  42179. uniformScaling: boolean;
  42180. /**
  42181. * Creates an AxisScaleGizmo
  42182. * @param gizmoLayer The utility layer the gizmo will be added to
  42183. * @param dragAxis The axis which the gizmo will be able to scale on
  42184. * @param color The color of the gizmo
  42185. */
  42186. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42187. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42188. /**
  42189. * Disposes of the gizmo
  42190. */
  42191. dispose(): void;
  42192. /**
  42193. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42194. * @param mesh The mesh to replace the default mesh of the gizmo
  42195. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42196. */
  42197. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Bounding box gizmo
  42203. */
  42204. export class BoundingBoxGizmo extends Gizmo {
  42205. private _lineBoundingBox;
  42206. private _rotateSpheresParent;
  42207. private _scaleBoxesParent;
  42208. private _boundingDimensions;
  42209. private _renderObserver;
  42210. private _pointerObserver;
  42211. private _scaleDragSpeed;
  42212. private _tmpQuaternion;
  42213. private _tmpVector;
  42214. private _tmpRotationMatrix;
  42215. /**
  42216. * 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)
  42217. */
  42218. ignoreChildren: boolean;
  42219. /**
  42220. * 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)
  42221. */
  42222. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42223. /**
  42224. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42225. */
  42226. rotationSphereSize: number;
  42227. /**
  42228. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42229. */
  42230. scaleBoxSize: number;
  42231. /**
  42232. * 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)
  42233. */
  42234. fixedDragMeshScreenSize: boolean;
  42235. /**
  42236. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42237. */
  42238. fixedDragMeshScreenSizeDistanceFactor: number;
  42239. /**
  42240. * Fired when a rotation sphere or scale box is dragged
  42241. */
  42242. onDragStartObservable: Observable<{}>;
  42243. /**
  42244. * Fired when a scale box is dragged
  42245. */
  42246. onScaleBoxDragObservable: Observable<{}>;
  42247. /**
  42248. * Fired when a scale box drag is ended
  42249. */
  42250. onScaleBoxDragEndObservable: Observable<{}>;
  42251. /**
  42252. * Fired when a rotation sphere is dragged
  42253. */
  42254. onRotationSphereDragObservable: Observable<{}>;
  42255. /**
  42256. * Fired when a rotation sphere drag is ended
  42257. */
  42258. onRotationSphereDragEndObservable: Observable<{}>;
  42259. /**
  42260. * 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)
  42261. */
  42262. scalePivot: Nullable<Vector3>;
  42263. /**
  42264. * Mesh used as a pivot to rotate the attached mesh
  42265. */
  42266. private _anchorMesh;
  42267. private _existingMeshScale;
  42268. private _dragMesh;
  42269. private pointerDragBehavior;
  42270. private coloredMaterial;
  42271. private hoverColoredMaterial;
  42272. /**
  42273. * Sets the color of the bounding box gizmo
  42274. * @param color the color to set
  42275. */
  42276. setColor(color: Color3): void;
  42277. /**
  42278. * Creates an BoundingBoxGizmo
  42279. * @param gizmoLayer The utility layer the gizmo will be added to
  42280. * @param color The color of the gizmo
  42281. */
  42282. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42283. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42284. private _selectNode;
  42285. /**
  42286. * Updates the bounding box information for the Gizmo
  42287. */
  42288. updateBoundingBox(): void;
  42289. private _updateRotationSpheres;
  42290. private _updateScaleBoxes;
  42291. /**
  42292. * Enables rotation on the specified axis and disables rotation on the others
  42293. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42294. */
  42295. setEnabledRotationAxis(axis: string): void;
  42296. /**
  42297. * Enables/disables scaling
  42298. * @param enable if scaling should be enabled
  42299. */
  42300. setEnabledScaling(enable: boolean): void;
  42301. private _updateDummy;
  42302. /**
  42303. * Enables a pointer drag behavior on the bounding box of the gizmo
  42304. */
  42305. enableDragBehavior(): void;
  42306. /**
  42307. * Disposes of the gizmo
  42308. */
  42309. dispose(): void;
  42310. /**
  42311. * 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)
  42312. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42313. * @returns the bounding box mesh with the passed in mesh as a child
  42314. */
  42315. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42316. /**
  42317. * CustomMeshes are not supported by this gizmo
  42318. * @param mesh The mesh to replace the default mesh of the gizmo
  42319. */
  42320. setCustomMesh(mesh: Mesh): void;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * Single plane rotation gizmo
  42326. */
  42327. export class PlaneRotationGizmo extends Gizmo {
  42328. /**
  42329. * Drag behavior responsible for the gizmos dragging interactions
  42330. */
  42331. dragBehavior: PointerDragBehavior;
  42332. private _pointerObserver;
  42333. /**
  42334. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42335. */
  42336. snapDistance: number;
  42337. /**
  42338. * Event that fires each time the gizmo snaps to a new location.
  42339. * * snapDistance is the the change in distance
  42340. */
  42341. onSnapObservable: Observable<{
  42342. snapDistance: number;
  42343. }>;
  42344. /**
  42345. * Creates a PlaneRotationGizmo
  42346. * @param gizmoLayer The utility layer the gizmo will be added to
  42347. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42348. * @param color The color of the gizmo
  42349. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42350. */
  42351. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42352. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42353. /**
  42354. * Disposes of the gizmo
  42355. */
  42356. dispose(): void;
  42357. }
  42358. }
  42359. declare module BABYLON {
  42360. /**
  42361. * Gizmo that enables rotating a mesh along 3 axis
  42362. */
  42363. export class RotationGizmo extends Gizmo {
  42364. /**
  42365. * Internal gizmo used for interactions on the x axis
  42366. */
  42367. xGizmo: PlaneRotationGizmo;
  42368. /**
  42369. * Internal gizmo used for interactions on the y axis
  42370. */
  42371. yGizmo: PlaneRotationGizmo;
  42372. /**
  42373. * Internal gizmo used for interactions on the z axis
  42374. */
  42375. zGizmo: PlaneRotationGizmo;
  42376. /** Fires an event when any of it's sub gizmos are dragged */
  42377. onDragStartObservable: Observable<{}>;
  42378. /** Fires an event when any of it's sub gizmos are released from dragging */
  42379. onDragEndObservable: Observable<{}>;
  42380. attachedMesh: Nullable<AbstractMesh>;
  42381. /**
  42382. * Creates a RotationGizmo
  42383. * @param gizmoLayer The utility layer the gizmo will be added to
  42384. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42385. */
  42386. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42387. updateGizmoRotationToMatchAttachedMesh: boolean;
  42388. /**
  42389. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42390. */
  42391. snapDistance: number;
  42392. /**
  42393. * Ratio for the scale of the gizmo (Default: 1)
  42394. */
  42395. scaleRatio: number;
  42396. /**
  42397. * Disposes of the gizmo
  42398. */
  42399. dispose(): void;
  42400. /**
  42401. * CustomMeshes are not supported by this gizmo
  42402. * @param mesh The mesh to replace the default mesh of the gizmo
  42403. */
  42404. setCustomMesh(mesh: Mesh): void;
  42405. }
  42406. }
  42407. declare module BABYLON {
  42408. /**
  42409. * Gizmo that enables dragging a mesh along 3 axis
  42410. */
  42411. export class PositionGizmo extends Gizmo {
  42412. /**
  42413. * Internal gizmo used for interactions on the x axis
  42414. */
  42415. xGizmo: AxisDragGizmo;
  42416. /**
  42417. * Internal gizmo used for interactions on the y axis
  42418. */
  42419. yGizmo: AxisDragGizmo;
  42420. /**
  42421. * Internal gizmo used for interactions on the z axis
  42422. */
  42423. zGizmo: AxisDragGizmo;
  42424. /** Fires an event when any of it's sub gizmos are dragged */
  42425. onDragStartObservable: Observable<{}>;
  42426. /** Fires an event when any of it's sub gizmos are released from dragging */
  42427. onDragEndObservable: Observable<{}>;
  42428. attachedMesh: Nullable<AbstractMesh>;
  42429. /**
  42430. * Creates a PositionGizmo
  42431. * @param gizmoLayer The utility layer the gizmo will be added to
  42432. */
  42433. constructor(gizmoLayer?: UtilityLayerRenderer);
  42434. updateGizmoRotationToMatchAttachedMesh: boolean;
  42435. /**
  42436. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42437. */
  42438. snapDistance: number;
  42439. /**
  42440. * Ratio for the scale of the gizmo (Default: 1)
  42441. */
  42442. scaleRatio: number;
  42443. /**
  42444. * Disposes of the gizmo
  42445. */
  42446. dispose(): void;
  42447. /**
  42448. * CustomMeshes are not supported by this gizmo
  42449. * @param mesh The mesh to replace the default mesh of the gizmo
  42450. */
  42451. setCustomMesh(mesh: Mesh): void;
  42452. }
  42453. }
  42454. declare module BABYLON {
  42455. /**
  42456. * Class containing static functions to help procedurally build meshes
  42457. */
  42458. export class PolyhedronBuilder {
  42459. /**
  42460. * Creates a polyhedron mesh
  42461. * * 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
  42462. * * The parameter `size` (positive float, default 1) sets the polygon size
  42463. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42464. * * 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`
  42465. * * 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
  42466. * * 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)`)
  42467. * * 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
  42468. * * 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
  42469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42470. * * 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
  42471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42472. * @param name defines the name of the mesh
  42473. * @param options defines the options used to create the mesh
  42474. * @param scene defines the hosting scene
  42475. * @returns the polyhedron mesh
  42476. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42477. */
  42478. static CreatePolyhedron(name: string, options: {
  42479. type?: number;
  42480. size?: number;
  42481. sizeX?: number;
  42482. sizeY?: number;
  42483. sizeZ?: number;
  42484. custom?: any;
  42485. faceUV?: Vector4[];
  42486. faceColors?: Color4[];
  42487. flat?: boolean;
  42488. updatable?: boolean;
  42489. sideOrientation?: number;
  42490. frontUVs?: Vector4;
  42491. backUVs?: Vector4;
  42492. }, scene?: Nullable<Scene>): Mesh;
  42493. }
  42494. }
  42495. declare module BABYLON {
  42496. /**
  42497. * Gizmo that enables scaling a mesh along 3 axis
  42498. */
  42499. export class ScaleGizmo extends Gizmo {
  42500. /**
  42501. * Internal gizmo used for interactions on the x axis
  42502. */
  42503. xGizmo: AxisScaleGizmo;
  42504. /**
  42505. * Internal gizmo used for interactions on the y axis
  42506. */
  42507. yGizmo: AxisScaleGizmo;
  42508. /**
  42509. * Internal gizmo used for interactions on the z axis
  42510. */
  42511. zGizmo: AxisScaleGizmo;
  42512. /**
  42513. * Internal gizmo used to scale all axis equally
  42514. */
  42515. uniformScaleGizmo: AxisScaleGizmo;
  42516. /** Fires an event when any of it's sub gizmos are dragged */
  42517. onDragStartObservable: Observable<{}>;
  42518. /** Fires an event when any of it's sub gizmos are released from dragging */
  42519. onDragEndObservable: Observable<{}>;
  42520. attachedMesh: Nullable<AbstractMesh>;
  42521. /**
  42522. * Creates a ScaleGizmo
  42523. * @param gizmoLayer The utility layer the gizmo will be added to
  42524. */
  42525. constructor(gizmoLayer?: UtilityLayerRenderer);
  42526. updateGizmoRotationToMatchAttachedMesh: boolean;
  42527. /**
  42528. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42529. */
  42530. snapDistance: number;
  42531. /**
  42532. * Ratio for the scale of the gizmo (Default: 1)
  42533. */
  42534. scaleRatio: number;
  42535. /**
  42536. * Disposes of the gizmo
  42537. */
  42538. dispose(): void;
  42539. }
  42540. }
  42541. declare module BABYLON {
  42542. /**
  42543. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42544. */
  42545. export class GizmoManager implements IDisposable {
  42546. private scene;
  42547. /**
  42548. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42549. */
  42550. gizmos: {
  42551. positionGizmo: Nullable<PositionGizmo>;
  42552. rotationGizmo: Nullable<RotationGizmo>;
  42553. scaleGizmo: Nullable<ScaleGizmo>;
  42554. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42555. };
  42556. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42557. clearGizmoOnEmptyPointerEvent: boolean;
  42558. /** Fires an event when the manager is attached to a mesh */
  42559. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42560. private _gizmosEnabled;
  42561. private _pointerObserver;
  42562. private _attachedMesh;
  42563. private _boundingBoxColor;
  42564. private _defaultUtilityLayer;
  42565. private _defaultKeepDepthUtilityLayer;
  42566. /**
  42567. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42568. */
  42569. boundingBoxDragBehavior: SixDofDragBehavior;
  42570. /**
  42571. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42572. */
  42573. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42574. /**
  42575. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42576. */
  42577. usePointerToAttachGizmos: boolean;
  42578. /**
  42579. * Instatiates a gizmo manager
  42580. * @param scene the scene to overlay the gizmos on top of
  42581. */
  42582. constructor(scene: Scene);
  42583. /**
  42584. * Attaches a set of gizmos to the specified mesh
  42585. * @param mesh The mesh the gizmo's should be attached to
  42586. */
  42587. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42588. /**
  42589. * If the position gizmo is enabled
  42590. */
  42591. positionGizmoEnabled: boolean;
  42592. /**
  42593. * If the rotation gizmo is enabled
  42594. */
  42595. rotationGizmoEnabled: boolean;
  42596. /**
  42597. * If the scale gizmo is enabled
  42598. */
  42599. scaleGizmoEnabled: boolean;
  42600. /**
  42601. * If the boundingBox gizmo is enabled
  42602. */
  42603. boundingBoxGizmoEnabled: boolean;
  42604. /**
  42605. * Disposes of the gizmo manager
  42606. */
  42607. dispose(): void;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /**
  42612. * A directional light is defined by a direction (what a surprise!).
  42613. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42614. * 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.
  42615. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42616. */
  42617. export class DirectionalLight extends ShadowLight {
  42618. private _shadowFrustumSize;
  42619. /**
  42620. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42621. */
  42622. /**
  42623. * Specifies a fix frustum size for the shadow generation.
  42624. */
  42625. shadowFrustumSize: number;
  42626. private _shadowOrthoScale;
  42627. /**
  42628. * Gets the shadow projection scale against the optimal computed one.
  42629. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42630. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42631. */
  42632. /**
  42633. * Sets the shadow projection scale against the optimal computed one.
  42634. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42635. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42636. */
  42637. shadowOrthoScale: number;
  42638. /**
  42639. * Automatically compute the projection matrix to best fit (including all the casters)
  42640. * on each frame.
  42641. */
  42642. autoUpdateExtends: boolean;
  42643. private _orthoLeft;
  42644. private _orthoRight;
  42645. private _orthoTop;
  42646. private _orthoBottom;
  42647. /**
  42648. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42649. * The directional light is emitted from everywhere in the given direction.
  42650. * It can cast shadows.
  42651. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42652. * @param name The friendly name of the light
  42653. * @param direction The direction of the light
  42654. * @param scene The scene the light belongs to
  42655. */
  42656. constructor(name: string, direction: Vector3, scene: Scene);
  42657. /**
  42658. * Returns the string "DirectionalLight".
  42659. * @return The class name
  42660. */
  42661. getClassName(): string;
  42662. /**
  42663. * Returns the integer 1.
  42664. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42665. */
  42666. getTypeID(): number;
  42667. /**
  42668. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42669. * Returns the DirectionalLight Shadow projection matrix.
  42670. */
  42671. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42672. /**
  42673. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42674. * Returns the DirectionalLight Shadow projection matrix.
  42675. */
  42676. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42677. /**
  42678. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42679. * Returns the DirectionalLight Shadow projection matrix.
  42680. */
  42681. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42682. protected _buildUniformLayout(): void;
  42683. /**
  42684. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42685. * @param effect The effect to update
  42686. * @param lightIndex The index of the light in the effect to update
  42687. * @returns The directional light
  42688. */
  42689. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42690. /**
  42691. * Gets the minZ used for shadow according to both the scene and the light.
  42692. *
  42693. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42694. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42695. * @param activeCamera The camera we are returning the min for
  42696. * @returns the depth min z
  42697. */
  42698. getDepthMinZ(activeCamera: Camera): number;
  42699. /**
  42700. * Gets the maxZ used for shadow according to both the scene and the light.
  42701. *
  42702. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42703. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42704. * @param activeCamera The camera we are returning the max for
  42705. * @returns the depth max z
  42706. */
  42707. getDepthMaxZ(activeCamera: Camera): number;
  42708. /**
  42709. * Prepares the list of defines specific to the light type.
  42710. * @param defines the list of defines
  42711. * @param lightIndex defines the index of the light for the effect
  42712. */
  42713. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42714. }
  42715. }
  42716. declare module BABYLON {
  42717. /**
  42718. * Class containing static functions to help procedurally build meshes
  42719. */
  42720. export class HemisphereBuilder {
  42721. /**
  42722. * Creates a hemisphere mesh
  42723. * @param name defines the name of the mesh
  42724. * @param options defines the options used to create the mesh
  42725. * @param scene defines the hosting scene
  42726. * @returns the hemisphere mesh
  42727. */
  42728. static CreateHemisphere(name: string, options: {
  42729. segments?: number;
  42730. diameter?: number;
  42731. sideOrientation?: number;
  42732. }, scene: any): Mesh;
  42733. }
  42734. }
  42735. declare module BABYLON {
  42736. /**
  42737. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42738. * These values define a cone of light starting from the position, emitting toward the direction.
  42739. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42740. * and the exponent defines the speed of the decay of the light with distance (reach).
  42741. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42742. */
  42743. export class SpotLight extends ShadowLight {
  42744. private _angle;
  42745. private _innerAngle;
  42746. private _cosHalfAngle;
  42747. private _lightAngleScale;
  42748. private _lightAngleOffset;
  42749. /**
  42750. * Gets the cone angle of the spot light in Radians.
  42751. */
  42752. /**
  42753. * Sets the cone angle of the spot light in Radians.
  42754. */
  42755. angle: number;
  42756. /**
  42757. * Only used in gltf falloff mode, this defines the angle where
  42758. * the directional falloff will start before cutting at angle which could be seen
  42759. * as outer angle.
  42760. */
  42761. /**
  42762. * Only used in gltf falloff mode, this defines the angle where
  42763. * the directional falloff will start before cutting at angle which could be seen
  42764. * as outer angle.
  42765. */
  42766. innerAngle: number;
  42767. private _shadowAngleScale;
  42768. /**
  42769. * Allows scaling the angle of the light for shadow generation only.
  42770. */
  42771. /**
  42772. * Allows scaling the angle of the light for shadow generation only.
  42773. */
  42774. shadowAngleScale: number;
  42775. /**
  42776. * The light decay speed with the distance from the emission spot.
  42777. */
  42778. exponent: number;
  42779. private _projectionTextureMatrix;
  42780. /**
  42781. * Allows reading the projecton texture
  42782. */
  42783. readonly projectionTextureMatrix: Matrix;
  42784. protected _projectionTextureLightNear: number;
  42785. /**
  42786. * Gets the near clip of the Spotlight for texture projection.
  42787. */
  42788. /**
  42789. * Sets the near clip of the Spotlight for texture projection.
  42790. */
  42791. projectionTextureLightNear: number;
  42792. protected _projectionTextureLightFar: number;
  42793. /**
  42794. * Gets the far clip of the Spotlight for texture projection.
  42795. */
  42796. /**
  42797. * Sets the far clip of the Spotlight for texture projection.
  42798. */
  42799. projectionTextureLightFar: number;
  42800. protected _projectionTextureUpDirection: Vector3;
  42801. /**
  42802. * Gets the Up vector of the Spotlight for texture projection.
  42803. */
  42804. /**
  42805. * Sets the Up vector of the Spotlight for texture projection.
  42806. */
  42807. projectionTextureUpDirection: Vector3;
  42808. private _projectionTexture;
  42809. /**
  42810. * Gets the projection texture of the light.
  42811. */
  42812. /**
  42813. * Sets the projection texture of the light.
  42814. */
  42815. projectionTexture: Nullable<BaseTexture>;
  42816. private _projectionTextureViewLightDirty;
  42817. private _projectionTextureProjectionLightDirty;
  42818. private _projectionTextureDirty;
  42819. private _projectionTextureViewTargetVector;
  42820. private _projectionTextureViewLightMatrix;
  42821. private _projectionTextureProjectionLightMatrix;
  42822. private _projectionTextureScalingMatrix;
  42823. /**
  42824. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42825. * It can cast shadows.
  42826. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42827. * @param name The light friendly name
  42828. * @param position The position of the spot light in the scene
  42829. * @param direction The direction of the light in the scene
  42830. * @param angle The cone angle of the light in Radians
  42831. * @param exponent The light decay speed with the distance from the emission spot
  42832. * @param scene The scene the lights belongs to
  42833. */
  42834. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42835. /**
  42836. * Returns the string "SpotLight".
  42837. * @returns the class name
  42838. */
  42839. getClassName(): string;
  42840. /**
  42841. * Returns the integer 2.
  42842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42843. */
  42844. getTypeID(): number;
  42845. /**
  42846. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42847. */
  42848. protected _setDirection(value: Vector3): void;
  42849. /**
  42850. * Overrides the position setter to recompute the projection texture view light Matrix.
  42851. */
  42852. protected _setPosition(value: Vector3): void;
  42853. /**
  42854. * 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.
  42855. * Returns the SpotLight.
  42856. */
  42857. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42858. protected _computeProjectionTextureViewLightMatrix(): void;
  42859. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42860. /**
  42861. * Main function for light texture projection matrix computing.
  42862. */
  42863. protected _computeProjectionTextureMatrix(): void;
  42864. protected _buildUniformLayout(): void;
  42865. private _computeAngleValues;
  42866. /**
  42867. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42868. * @param effect The effect to update
  42869. * @param lightIndex The index of the light in the effect to update
  42870. * @returns The spot light
  42871. */
  42872. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42873. /**
  42874. * Disposes the light and the associated resources.
  42875. */
  42876. dispose(): void;
  42877. /**
  42878. * Prepares the list of defines specific to the light type.
  42879. * @param defines the list of defines
  42880. * @param lightIndex defines the index of the light for the effect
  42881. */
  42882. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42883. }
  42884. }
  42885. declare module BABYLON {
  42886. /**
  42887. * Gizmo that enables viewing a light
  42888. */
  42889. export class LightGizmo extends Gizmo {
  42890. private _lightMesh;
  42891. private _material;
  42892. /**
  42893. * Creates a LightGizmo
  42894. * @param gizmoLayer The utility layer the gizmo will be added to
  42895. */
  42896. constructor(gizmoLayer?: UtilityLayerRenderer);
  42897. private _light;
  42898. /**
  42899. * The light that the gizmo is attached to
  42900. */
  42901. light: Nullable<Light>;
  42902. /**
  42903. * @hidden
  42904. * Updates the gizmo to match the attached mesh's position/rotation
  42905. */
  42906. protected _update(): void;
  42907. private static _Scale;
  42908. /**
  42909. * Creates the lines for a light mesh
  42910. */
  42911. private static _createLightLines;
  42912. private static _CreateHemisphericLightMesh;
  42913. private static _CreatePointLightMesh;
  42914. private static _CreateSpotLightMesh;
  42915. private static _CreateDirectionalLightMesh;
  42916. }
  42917. }
  42918. declare module BABYLON {
  42919. /** @hidden */
  42920. export var backgroundFragmentDeclaration: {
  42921. name: string;
  42922. shader: string;
  42923. };
  42924. }
  42925. declare module BABYLON {
  42926. /** @hidden */
  42927. export var backgroundUboDeclaration: {
  42928. name: string;
  42929. shader: string;
  42930. };
  42931. }
  42932. declare module BABYLON {
  42933. /** @hidden */
  42934. export var backgroundPixelShader: {
  42935. name: string;
  42936. shader: string;
  42937. };
  42938. }
  42939. declare module BABYLON {
  42940. /** @hidden */
  42941. export var backgroundVertexDeclaration: {
  42942. name: string;
  42943. shader: string;
  42944. };
  42945. }
  42946. declare module BABYLON {
  42947. /** @hidden */
  42948. export var backgroundVertexShader: {
  42949. name: string;
  42950. shader: string;
  42951. };
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Background material used to create an efficient environement around your scene.
  42956. */
  42957. export class BackgroundMaterial extends PushMaterial {
  42958. /**
  42959. * Standard reflectance value at parallel view angle.
  42960. */
  42961. static StandardReflectance0: number;
  42962. /**
  42963. * Standard reflectance value at grazing angle.
  42964. */
  42965. static StandardReflectance90: number;
  42966. protected _primaryColor: Color3;
  42967. /**
  42968. * Key light Color (multiply against the environement texture)
  42969. */
  42970. primaryColor: Color3;
  42971. protected __perceptualColor: Nullable<Color3>;
  42972. /**
  42973. * Experimental Internal Use Only.
  42974. *
  42975. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42976. * This acts as a helper to set the primary color to a more "human friendly" value.
  42977. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42978. * output color as close as possible from the chosen value.
  42979. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42980. * part of lighting setup.)
  42981. */
  42982. _perceptualColor: Nullable<Color3>;
  42983. protected _primaryColorShadowLevel: float;
  42984. /**
  42985. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42986. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42987. */
  42988. primaryColorShadowLevel: float;
  42989. protected _primaryColorHighlightLevel: float;
  42990. /**
  42991. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42992. * The primary color is used at the level chosen to define what the white area would look.
  42993. */
  42994. primaryColorHighlightLevel: float;
  42995. protected _reflectionTexture: Nullable<BaseTexture>;
  42996. /**
  42997. * Reflection Texture used in the material.
  42998. * Should be author in a specific way for the best result (refer to the documentation).
  42999. */
  43000. reflectionTexture: Nullable<BaseTexture>;
  43001. protected _reflectionBlur: float;
  43002. /**
  43003. * Reflection Texture level of blur.
  43004. *
  43005. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43006. * texture twice.
  43007. */
  43008. reflectionBlur: float;
  43009. protected _diffuseTexture: Nullable<BaseTexture>;
  43010. /**
  43011. * Diffuse Texture used in the material.
  43012. * Should be author in a specific way for the best result (refer to the documentation).
  43013. */
  43014. diffuseTexture: Nullable<BaseTexture>;
  43015. protected _shadowLights: Nullable<IShadowLight[]>;
  43016. /**
  43017. * Specify the list of lights casting shadow on the material.
  43018. * All scene shadow lights will be included if null.
  43019. */
  43020. shadowLights: Nullable<IShadowLight[]>;
  43021. protected _shadowLevel: float;
  43022. /**
  43023. * Helps adjusting the shadow to a softer level if required.
  43024. * 0 means black shadows and 1 means no shadows.
  43025. */
  43026. shadowLevel: float;
  43027. protected _sceneCenter: Vector3;
  43028. /**
  43029. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43030. * It is usually zero but might be interesting to modify according to your setup.
  43031. */
  43032. sceneCenter: Vector3;
  43033. protected _opacityFresnel: boolean;
  43034. /**
  43035. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43036. * This helps ensuring a nice transition when the camera goes under the ground.
  43037. */
  43038. opacityFresnel: boolean;
  43039. protected _reflectionFresnel: boolean;
  43040. /**
  43041. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43042. * This helps adding a mirror texture on the ground.
  43043. */
  43044. reflectionFresnel: boolean;
  43045. protected _reflectionFalloffDistance: number;
  43046. /**
  43047. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43048. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43049. */
  43050. reflectionFalloffDistance: number;
  43051. protected _reflectionAmount: number;
  43052. /**
  43053. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43054. */
  43055. reflectionAmount: number;
  43056. protected _reflectionReflectance0: number;
  43057. /**
  43058. * This specifies the weight of the reflection at grazing angle.
  43059. */
  43060. reflectionReflectance0: number;
  43061. protected _reflectionReflectance90: number;
  43062. /**
  43063. * This specifies the weight of the reflection at a perpendicular point of view.
  43064. */
  43065. reflectionReflectance90: number;
  43066. /**
  43067. * Sets the reflection reflectance fresnel values according to the default standard
  43068. * empirically know to work well :-)
  43069. */
  43070. reflectionStandardFresnelWeight: number;
  43071. protected _useRGBColor: boolean;
  43072. /**
  43073. * Helps to directly use the maps channels instead of their level.
  43074. */
  43075. useRGBColor: boolean;
  43076. protected _enableNoise: boolean;
  43077. /**
  43078. * This helps reducing the banding effect that could occur on the background.
  43079. */
  43080. enableNoise: boolean;
  43081. /**
  43082. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43083. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43084. * Recommended to be keep at 1.0 except for special cases.
  43085. */
  43086. fovMultiplier: number;
  43087. private _fovMultiplier;
  43088. /**
  43089. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43090. */
  43091. useEquirectangularFOV: boolean;
  43092. private _maxSimultaneousLights;
  43093. /**
  43094. * Number of Simultaneous lights allowed on the material.
  43095. */
  43096. maxSimultaneousLights: int;
  43097. /**
  43098. * Default configuration related to image processing available in the Background Material.
  43099. */
  43100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43101. /**
  43102. * Keep track of the image processing observer to allow dispose and replace.
  43103. */
  43104. private _imageProcessingObserver;
  43105. /**
  43106. * Attaches a new image processing configuration to the PBR Material.
  43107. * @param configuration (if null the scene configuration will be use)
  43108. */
  43109. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43110. /**
  43111. * Gets the image processing configuration used either in this material.
  43112. */
  43113. /**
  43114. * Sets the Default image processing configuration used either in the this material.
  43115. *
  43116. * If sets to null, the scene one is in use.
  43117. */
  43118. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43119. /**
  43120. * Gets wether the color curves effect is enabled.
  43121. */
  43122. /**
  43123. * Sets wether the color curves effect is enabled.
  43124. */
  43125. cameraColorCurvesEnabled: boolean;
  43126. /**
  43127. * Gets wether the color grading effect is enabled.
  43128. */
  43129. /**
  43130. * Gets wether the color grading effect is enabled.
  43131. */
  43132. cameraColorGradingEnabled: boolean;
  43133. /**
  43134. * Gets wether tonemapping is enabled or not.
  43135. */
  43136. /**
  43137. * Sets wether tonemapping is enabled or not
  43138. */
  43139. cameraToneMappingEnabled: boolean;
  43140. /**
  43141. * The camera exposure used on this material.
  43142. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43143. * This corresponds to a photographic exposure.
  43144. */
  43145. /**
  43146. * The camera exposure used on this material.
  43147. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43148. * This corresponds to a photographic exposure.
  43149. */
  43150. cameraExposure: float;
  43151. /**
  43152. * Gets The camera contrast used on this material.
  43153. */
  43154. /**
  43155. * Sets The camera contrast used on this material.
  43156. */
  43157. cameraContrast: float;
  43158. /**
  43159. * Gets the Color Grading 2D Lookup Texture.
  43160. */
  43161. /**
  43162. * Sets the Color Grading 2D Lookup Texture.
  43163. */
  43164. cameraColorGradingTexture: Nullable<BaseTexture>;
  43165. /**
  43166. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43167. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43168. * 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;
  43169. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43170. */
  43171. /**
  43172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43174. * 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;
  43175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43176. */
  43177. cameraColorCurves: Nullable<ColorCurves>;
  43178. /**
  43179. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43180. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43181. */
  43182. switchToBGR: boolean;
  43183. private _renderTargets;
  43184. private _reflectionControls;
  43185. private _white;
  43186. private _primaryShadowColor;
  43187. private _primaryHighlightColor;
  43188. /**
  43189. * Instantiates a Background Material in the given scene
  43190. * @param name The friendly name of the material
  43191. * @param scene The scene to add the material to
  43192. */
  43193. constructor(name: string, scene: Scene);
  43194. /**
  43195. * Gets a boolean indicating that current material needs to register RTT
  43196. */
  43197. readonly hasRenderTargetTextures: boolean;
  43198. /**
  43199. * The entire material has been created in order to prevent overdraw.
  43200. * @returns false
  43201. */
  43202. needAlphaTesting(): boolean;
  43203. /**
  43204. * The entire material has been created in order to prevent overdraw.
  43205. * @returns true if blending is enable
  43206. */
  43207. needAlphaBlending(): boolean;
  43208. /**
  43209. * Checks wether the material is ready to be rendered for a given mesh.
  43210. * @param mesh The mesh to render
  43211. * @param subMesh The submesh to check against
  43212. * @param useInstances Specify wether or not the material is used with instances
  43213. * @returns true if all the dependencies are ready (Textures, Effects...)
  43214. */
  43215. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43216. /**
  43217. * Compute the primary color according to the chosen perceptual color.
  43218. */
  43219. private _computePrimaryColorFromPerceptualColor;
  43220. /**
  43221. * Compute the highlights and shadow colors according to their chosen levels.
  43222. */
  43223. private _computePrimaryColors;
  43224. /**
  43225. * Build the uniform buffer used in the material.
  43226. */
  43227. buildUniformLayout(): void;
  43228. /**
  43229. * Unbind the material.
  43230. */
  43231. unbind(): void;
  43232. /**
  43233. * Bind only the world matrix to the material.
  43234. * @param world The world matrix to bind.
  43235. */
  43236. bindOnlyWorldMatrix(world: Matrix): void;
  43237. /**
  43238. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43239. * @param world The world matrix to bind.
  43240. * @param subMesh The submesh to bind for.
  43241. */
  43242. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43243. /**
  43244. * Dispose the material.
  43245. * @param forceDisposeEffect Force disposal of the associated effect.
  43246. * @param forceDisposeTextures Force disposal of the associated textures.
  43247. */
  43248. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43249. /**
  43250. * Clones the material.
  43251. * @param name The cloned name.
  43252. * @returns The cloned material.
  43253. */
  43254. clone(name: string): BackgroundMaterial;
  43255. /**
  43256. * Serializes the current material to its JSON representation.
  43257. * @returns The JSON representation.
  43258. */
  43259. serialize(): any;
  43260. /**
  43261. * Gets the class name of the material
  43262. * @returns "BackgroundMaterial"
  43263. */
  43264. getClassName(): string;
  43265. /**
  43266. * Parse a JSON input to create back a background material.
  43267. * @param source The JSON data to parse
  43268. * @param scene The scene to create the parsed material in
  43269. * @param rootUrl The root url of the assets the material depends upon
  43270. * @returns the instantiated BackgroundMaterial.
  43271. */
  43272. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43273. }
  43274. }
  43275. declare module BABYLON {
  43276. /**
  43277. * Represents the different options available during the creation of
  43278. * a Environment helper.
  43279. *
  43280. * This can control the default ground, skybox and image processing setup of your scene.
  43281. */
  43282. export interface IEnvironmentHelperOptions {
  43283. /**
  43284. * Specifies wether or not to create a ground.
  43285. * True by default.
  43286. */
  43287. createGround: boolean;
  43288. /**
  43289. * Specifies the ground size.
  43290. * 15 by default.
  43291. */
  43292. groundSize: number;
  43293. /**
  43294. * The texture used on the ground for the main color.
  43295. * Comes from the BabylonJS CDN by default.
  43296. *
  43297. * Remarks: Can be either a texture or a url.
  43298. */
  43299. groundTexture: string | BaseTexture;
  43300. /**
  43301. * The color mixed in the ground texture by default.
  43302. * BabylonJS clearColor by default.
  43303. */
  43304. groundColor: Color3;
  43305. /**
  43306. * Specifies the ground opacity.
  43307. * 1 by default.
  43308. */
  43309. groundOpacity: number;
  43310. /**
  43311. * Enables the ground to receive shadows.
  43312. * True by default.
  43313. */
  43314. enableGroundShadow: boolean;
  43315. /**
  43316. * Helps preventing the shadow to be fully black on the ground.
  43317. * 0.5 by default.
  43318. */
  43319. groundShadowLevel: number;
  43320. /**
  43321. * Creates a mirror texture attach to the ground.
  43322. * false by default.
  43323. */
  43324. enableGroundMirror: boolean;
  43325. /**
  43326. * Specifies the ground mirror size ratio.
  43327. * 0.3 by default as the default kernel is 64.
  43328. */
  43329. groundMirrorSizeRatio: number;
  43330. /**
  43331. * Specifies the ground mirror blur kernel size.
  43332. * 64 by default.
  43333. */
  43334. groundMirrorBlurKernel: number;
  43335. /**
  43336. * Specifies the ground mirror visibility amount.
  43337. * 1 by default
  43338. */
  43339. groundMirrorAmount: number;
  43340. /**
  43341. * Specifies the ground mirror reflectance weight.
  43342. * This uses the standard weight of the background material to setup the fresnel effect
  43343. * of the mirror.
  43344. * 1 by default.
  43345. */
  43346. groundMirrorFresnelWeight: number;
  43347. /**
  43348. * Specifies the ground mirror Falloff distance.
  43349. * This can helps reducing the size of the reflection.
  43350. * 0 by Default.
  43351. */
  43352. groundMirrorFallOffDistance: number;
  43353. /**
  43354. * Specifies the ground mirror texture type.
  43355. * Unsigned Int by Default.
  43356. */
  43357. groundMirrorTextureType: number;
  43358. /**
  43359. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43360. * the shown objects.
  43361. */
  43362. groundYBias: number;
  43363. /**
  43364. * Specifies wether or not to create a skybox.
  43365. * True by default.
  43366. */
  43367. createSkybox: boolean;
  43368. /**
  43369. * Specifies the skybox size.
  43370. * 20 by default.
  43371. */
  43372. skyboxSize: number;
  43373. /**
  43374. * The texture used on the skybox for the main color.
  43375. * Comes from the BabylonJS CDN by default.
  43376. *
  43377. * Remarks: Can be either a texture or a url.
  43378. */
  43379. skyboxTexture: string | BaseTexture;
  43380. /**
  43381. * The color mixed in the skybox texture by default.
  43382. * BabylonJS clearColor by default.
  43383. */
  43384. skyboxColor: Color3;
  43385. /**
  43386. * The background rotation around the Y axis of the scene.
  43387. * This helps aligning the key lights of your scene with the background.
  43388. * 0 by default.
  43389. */
  43390. backgroundYRotation: number;
  43391. /**
  43392. * Compute automatically the size of the elements to best fit with the scene.
  43393. */
  43394. sizeAuto: boolean;
  43395. /**
  43396. * Default position of the rootMesh if autoSize is not true.
  43397. */
  43398. rootPosition: Vector3;
  43399. /**
  43400. * Sets up the image processing in the scene.
  43401. * true by default.
  43402. */
  43403. setupImageProcessing: boolean;
  43404. /**
  43405. * The texture used as your environment texture in the scene.
  43406. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43407. *
  43408. * Remarks: Can be either a texture or a url.
  43409. */
  43410. environmentTexture: string | BaseTexture;
  43411. /**
  43412. * The value of the exposure to apply to the scene.
  43413. * 0.6 by default if setupImageProcessing is true.
  43414. */
  43415. cameraExposure: number;
  43416. /**
  43417. * The value of the contrast to apply to the scene.
  43418. * 1.6 by default if setupImageProcessing is true.
  43419. */
  43420. cameraContrast: number;
  43421. /**
  43422. * Specifies wether or not tonemapping should be enabled in the scene.
  43423. * true by default if setupImageProcessing is true.
  43424. */
  43425. toneMappingEnabled: boolean;
  43426. }
  43427. /**
  43428. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43429. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43430. * It also helps with the default setup of your imageProcessing configuration.
  43431. */
  43432. export class EnvironmentHelper {
  43433. /**
  43434. * Default ground texture URL.
  43435. */
  43436. private static _groundTextureCDNUrl;
  43437. /**
  43438. * Default skybox texture URL.
  43439. */
  43440. private static _skyboxTextureCDNUrl;
  43441. /**
  43442. * Default environment texture URL.
  43443. */
  43444. private static _environmentTextureCDNUrl;
  43445. /**
  43446. * Creates the default options for the helper.
  43447. */
  43448. private static _getDefaultOptions;
  43449. private _rootMesh;
  43450. /**
  43451. * Gets the root mesh created by the helper.
  43452. */
  43453. readonly rootMesh: Mesh;
  43454. private _skybox;
  43455. /**
  43456. * Gets the skybox created by the helper.
  43457. */
  43458. readonly skybox: Nullable<Mesh>;
  43459. private _skyboxTexture;
  43460. /**
  43461. * Gets the skybox texture created by the helper.
  43462. */
  43463. readonly skyboxTexture: Nullable<BaseTexture>;
  43464. private _skyboxMaterial;
  43465. /**
  43466. * Gets the skybox material created by the helper.
  43467. */
  43468. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43469. private _ground;
  43470. /**
  43471. * Gets the ground mesh created by the helper.
  43472. */
  43473. readonly ground: Nullable<Mesh>;
  43474. private _groundTexture;
  43475. /**
  43476. * Gets the ground texture created by the helper.
  43477. */
  43478. readonly groundTexture: Nullable<BaseTexture>;
  43479. private _groundMirror;
  43480. /**
  43481. * Gets the ground mirror created by the helper.
  43482. */
  43483. readonly groundMirror: Nullable<MirrorTexture>;
  43484. /**
  43485. * Gets the ground mirror render list to helps pushing the meshes
  43486. * you wish in the ground reflection.
  43487. */
  43488. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43489. private _groundMaterial;
  43490. /**
  43491. * Gets the ground material created by the helper.
  43492. */
  43493. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43494. /**
  43495. * Stores the creation options.
  43496. */
  43497. private readonly _scene;
  43498. private _options;
  43499. /**
  43500. * This observable will be notified with any error during the creation of the environment,
  43501. * mainly texture creation errors.
  43502. */
  43503. onErrorObservable: Observable<{
  43504. message?: string;
  43505. exception?: any;
  43506. }>;
  43507. /**
  43508. * constructor
  43509. * @param options Defines the options we want to customize the helper
  43510. * @param scene The scene to add the material to
  43511. */
  43512. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43513. /**
  43514. * Updates the background according to the new options
  43515. * @param options
  43516. */
  43517. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43518. /**
  43519. * Sets the primary color of all the available elements.
  43520. * @param color the main color to affect to the ground and the background
  43521. */
  43522. setMainColor(color: Color3): void;
  43523. /**
  43524. * Setup the image processing according to the specified options.
  43525. */
  43526. private _setupImageProcessing;
  43527. /**
  43528. * Setup the environment texture according to the specified options.
  43529. */
  43530. private _setupEnvironmentTexture;
  43531. /**
  43532. * Setup the background according to the specified options.
  43533. */
  43534. private _setupBackground;
  43535. /**
  43536. * Get the scene sizes according to the setup.
  43537. */
  43538. private _getSceneSize;
  43539. /**
  43540. * Setup the ground according to the specified options.
  43541. */
  43542. private _setupGround;
  43543. /**
  43544. * Setup the ground material according to the specified options.
  43545. */
  43546. private _setupGroundMaterial;
  43547. /**
  43548. * Setup the ground diffuse texture according to the specified options.
  43549. */
  43550. private _setupGroundDiffuseTexture;
  43551. /**
  43552. * Setup the ground mirror texture according to the specified options.
  43553. */
  43554. private _setupGroundMirrorTexture;
  43555. /**
  43556. * Setup the ground to receive the mirror texture.
  43557. */
  43558. private _setupMirrorInGroundMaterial;
  43559. /**
  43560. * Setup the skybox according to the specified options.
  43561. */
  43562. private _setupSkybox;
  43563. /**
  43564. * Setup the skybox material according to the specified options.
  43565. */
  43566. private _setupSkyboxMaterial;
  43567. /**
  43568. * Setup the skybox reflection texture according to the specified options.
  43569. */
  43570. private _setupSkyboxReflectionTexture;
  43571. private _errorHandler;
  43572. /**
  43573. * Dispose all the elements created by the Helper.
  43574. */
  43575. dispose(): void;
  43576. }
  43577. }
  43578. declare module BABYLON {
  43579. /**
  43580. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43581. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43582. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43583. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43584. */
  43585. export class PhotoDome extends TransformNode {
  43586. private _useDirectMapping;
  43587. /**
  43588. * The texture being displayed on the sphere
  43589. */
  43590. protected _photoTexture: Texture;
  43591. /**
  43592. * Gets or sets the texture being displayed on the sphere
  43593. */
  43594. photoTexture: Texture;
  43595. /**
  43596. * Observable raised when an error occured while loading the 360 image
  43597. */
  43598. onLoadErrorObservable: Observable<string>;
  43599. /**
  43600. * The skybox material
  43601. */
  43602. protected _material: BackgroundMaterial;
  43603. /**
  43604. * The surface used for the skybox
  43605. */
  43606. protected _mesh: Mesh;
  43607. /**
  43608. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43609. * Also see the options.resolution property.
  43610. */
  43611. fovMultiplier: number;
  43612. /**
  43613. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43614. * @param name Element's name, child elements will append suffixes for their own names.
  43615. * @param urlsOfPhoto defines the url of the photo to display
  43616. * @param options defines an object containing optional or exposed sub element properties
  43617. * @param onError defines a callback called when an error occured while loading the texture
  43618. */
  43619. constructor(name: string, urlOfPhoto: string, options: {
  43620. resolution?: number;
  43621. size?: number;
  43622. useDirectMapping?: boolean;
  43623. faceForward?: boolean;
  43624. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43625. /**
  43626. * Releases resources associated with this node.
  43627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43629. */
  43630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. /** @hidden */
  43635. export var rgbdDecodePixelShader: {
  43636. name: string;
  43637. shader: string;
  43638. };
  43639. }
  43640. declare module BABYLON {
  43641. /**
  43642. * Class used to host texture specific utilities
  43643. */
  43644. export class BRDFTextureTools {
  43645. /**
  43646. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43647. * @param texture the texture to expand.
  43648. */
  43649. private static _ExpandDefaultBRDFTexture;
  43650. /**
  43651. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43652. * @param scene defines the hosting scene
  43653. * @returns the environment BRDF texture
  43654. */
  43655. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43656. private static _environmentBRDFBase64Texture;
  43657. }
  43658. }
  43659. declare module BABYLON {
  43660. /**
  43661. * @hidden
  43662. */
  43663. export interface IMaterialClearCoatDefines {
  43664. CLEARCOAT: boolean;
  43665. CLEARCOAT_DEFAULTIOR: boolean;
  43666. CLEARCOAT_TEXTURE: boolean;
  43667. CLEARCOAT_TEXTUREDIRECTUV: number;
  43668. CLEARCOAT_BUMP: boolean;
  43669. CLEARCOAT_BUMPDIRECTUV: number;
  43670. CLEARCOAT_TINT: boolean;
  43671. CLEARCOAT_TINT_TEXTURE: boolean;
  43672. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43673. /** @hidden */
  43674. _areTexturesDirty: boolean;
  43675. }
  43676. /**
  43677. * Define the code related to the clear coat parameters of the pbr material.
  43678. */
  43679. export class PBRClearCoatConfiguration {
  43680. /**
  43681. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43682. * The default fits with a polyurethane material.
  43683. */
  43684. private static readonly _DefaultIndiceOfRefraction;
  43685. private _isEnabled;
  43686. /**
  43687. * Defines if the clear coat is enabled in the material.
  43688. */
  43689. isEnabled: boolean;
  43690. /**
  43691. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43692. */
  43693. intensity: number;
  43694. /**
  43695. * Defines the clear coat layer roughness.
  43696. */
  43697. roughness: number;
  43698. private _indiceOfRefraction;
  43699. /**
  43700. * Defines the indice of refraction of the clear coat.
  43701. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43702. * The default fits with a polyurethane material.
  43703. * Changing the default value is more performance intensive.
  43704. */
  43705. indiceOfRefraction: number;
  43706. private _texture;
  43707. /**
  43708. * Stores the clear coat values in a texture.
  43709. */
  43710. texture: Nullable<BaseTexture>;
  43711. private _bumpTexture;
  43712. /**
  43713. * Define the clear coat specific bump texture.
  43714. */
  43715. bumpTexture: Nullable<BaseTexture>;
  43716. private _isTintEnabled;
  43717. /**
  43718. * Defines if the clear coat tint is enabled in the material.
  43719. */
  43720. isTintEnabled: boolean;
  43721. /**
  43722. * Defines the clear coat tint of the material.
  43723. * This is only use if tint is enabled
  43724. */
  43725. tintColor: Color3;
  43726. /**
  43727. * Defines the distance at which the tint color should be found in the
  43728. * clear coat media.
  43729. * This is only use if tint is enabled
  43730. */
  43731. tintColorAtDistance: number;
  43732. /**
  43733. * Defines the clear coat layer thickness.
  43734. * This is only use if tint is enabled
  43735. */
  43736. tintThickness: number;
  43737. private _tintTexture;
  43738. /**
  43739. * Stores the clear tint values in a texture.
  43740. * rgb is tint
  43741. * a is a thickness factor
  43742. */
  43743. tintTexture: Nullable<BaseTexture>;
  43744. /** @hidden */
  43745. private _internalMarkAllSubMeshesAsTexturesDirty;
  43746. /** @hidden */
  43747. _markAllSubMeshesAsTexturesDirty(): void;
  43748. /**
  43749. * Instantiate a new istance of clear coat configuration.
  43750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43751. */
  43752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43753. /**
  43754. * Gets wehter the submesh is ready to be used or not.
  43755. * @param defines the list of "defines" to update.
  43756. * @param scene defines the scene the material belongs to.
  43757. * @param engine defines the engine the material belongs to.
  43758. * @param disableBumpMap defines wether the material disables bump or not.
  43759. * @returns - boolean indicating that the submesh is ready or not.
  43760. */
  43761. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43762. /**
  43763. * Checks to see if a texture is used in the material.
  43764. * @param defines the list of "defines" to update.
  43765. * @param scene defines the scene to the material belongs to.
  43766. */
  43767. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43768. /**
  43769. * Binds the material data.
  43770. * @param uniformBuffer defines the Uniform buffer to fill in.
  43771. * @param scene defines the scene the material belongs to.
  43772. * @param engine defines the engine the material belongs to.
  43773. * @param disableBumpMap defines wether the material disables bump or not.
  43774. * @param isFrozen defines wether the material is frozen or not.
  43775. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43776. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43777. */
  43778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43779. /**
  43780. * Checks to see if a texture is used in the material.
  43781. * @param texture - Base texture to use.
  43782. * @returns - Boolean specifying if a texture is used in the material.
  43783. */
  43784. hasTexture(texture: BaseTexture): boolean;
  43785. /**
  43786. * Returns an array of the actively used textures.
  43787. * @param activeTextures Array of BaseTextures
  43788. */
  43789. getActiveTextures(activeTextures: BaseTexture[]): void;
  43790. /**
  43791. * Returns the animatable textures.
  43792. * @param animatables Array of animatable textures.
  43793. */
  43794. getAnimatables(animatables: IAnimatable[]): void;
  43795. /**
  43796. * Disposes the resources of the material.
  43797. * @param forceDisposeTextures - Forces the disposal of all textures.
  43798. */
  43799. dispose(forceDisposeTextures?: boolean): void;
  43800. /**
  43801. * Get the current class name of the texture useful for serialization or dynamic coding.
  43802. * @returns "PBRClearCoatConfiguration"
  43803. */
  43804. getClassName(): string;
  43805. /**
  43806. * Add fallbacks to the effect fallbacks list.
  43807. * @param defines defines the Base texture to use.
  43808. * @param fallbacks defines the current fallback list.
  43809. * @param currentRank defines the current fallback rank.
  43810. * @returns the new fallback rank.
  43811. */
  43812. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43813. /**
  43814. * Add the required uniforms to the current list.
  43815. * @param uniforms defines the current uniform list.
  43816. */
  43817. static AddUniforms(uniforms: string[]): void;
  43818. /**
  43819. * Add the required samplers to the current list.
  43820. * @param samplers defines the current sampler list.
  43821. */
  43822. static AddSamplers(samplers: string[]): void;
  43823. /**
  43824. * Add the required uniforms to the current buffer.
  43825. * @param uniformBuffer defines the current uniform buffer.
  43826. */
  43827. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43828. /**
  43829. * Makes a duplicate of the current configuration into another one.
  43830. * @param clearCoatConfiguration define the config where to copy the info
  43831. */
  43832. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43833. /**
  43834. * Serializes this clear coat configuration.
  43835. * @returns - An object with the serialized config.
  43836. */
  43837. serialize(): any;
  43838. /**
  43839. * Parses a Clear Coat Configuration from a serialized object.
  43840. * @param source - Serialized object.
  43841. */
  43842. parse(source: any): void;
  43843. }
  43844. }
  43845. declare module BABYLON {
  43846. /**
  43847. * @hidden
  43848. */
  43849. export interface IMaterialAnisotropicDefines {
  43850. ANISOTROPIC: boolean;
  43851. ANISOTROPIC_TEXTURE: boolean;
  43852. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43853. MAINUV1: boolean;
  43854. _areTexturesDirty: boolean;
  43855. _needUVs: boolean;
  43856. }
  43857. /**
  43858. * Define the code related to the anisotropic parameters of the pbr material.
  43859. */
  43860. export class PBRAnisotropicConfiguration {
  43861. private _isEnabled;
  43862. /**
  43863. * Defines if the anisotropy is enabled in the material.
  43864. */
  43865. isEnabled: boolean;
  43866. /**
  43867. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43868. */
  43869. intensity: number;
  43870. /**
  43871. * Defines if the effect is along the tangents, bitangents or in between.
  43872. * By default, the effect is "strectching" the highlights along the tangents.
  43873. */
  43874. direction: Vector2;
  43875. private _texture;
  43876. /**
  43877. * Stores the anisotropy values in a texture.
  43878. * rg is direction (like normal from -1 to 1)
  43879. * b is a intensity
  43880. */
  43881. texture: Nullable<BaseTexture>;
  43882. /** @hidden */
  43883. private _internalMarkAllSubMeshesAsTexturesDirty;
  43884. /** @hidden */
  43885. _markAllSubMeshesAsTexturesDirty(): void;
  43886. /**
  43887. * Instantiate a new istance of anisotropy configuration.
  43888. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43889. */
  43890. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43891. /**
  43892. * Specifies that the submesh is ready to be used.
  43893. * @param defines the list of "defines" to update.
  43894. * @param scene defines the scene the material belongs to.
  43895. * @returns - boolean indicating that the submesh is ready or not.
  43896. */
  43897. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43898. /**
  43899. * Checks to see if a texture is used in the material.
  43900. * @param defines the list of "defines" to update.
  43901. * @param mesh the mesh we are preparing the defines for.
  43902. * @param scene defines the scene the material belongs to.
  43903. */
  43904. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43905. /**
  43906. * Binds the material data.
  43907. * @param uniformBuffer defines the Uniform buffer to fill in.
  43908. * @param scene defines the scene the material belongs to.
  43909. * @param isFrozen defines wether the material is frozen or not.
  43910. */
  43911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43912. /**
  43913. * Checks to see if a texture is used in the material.
  43914. * @param texture - Base texture to use.
  43915. * @returns - Boolean specifying if a texture is used in the material.
  43916. */
  43917. hasTexture(texture: BaseTexture): boolean;
  43918. /**
  43919. * Returns an array of the actively used textures.
  43920. * @param activeTextures Array of BaseTextures
  43921. */
  43922. getActiveTextures(activeTextures: BaseTexture[]): void;
  43923. /**
  43924. * Returns the animatable textures.
  43925. * @param animatables Array of animatable textures.
  43926. */
  43927. getAnimatables(animatables: IAnimatable[]): void;
  43928. /**
  43929. * Disposes the resources of the material.
  43930. * @param forceDisposeTextures - Forces the disposal of all textures.
  43931. */
  43932. dispose(forceDisposeTextures?: boolean): void;
  43933. /**
  43934. * Get the current class name of the texture useful for serialization or dynamic coding.
  43935. * @returns "PBRAnisotropicConfiguration"
  43936. */
  43937. getClassName(): string;
  43938. /**
  43939. * Add fallbacks to the effect fallbacks list.
  43940. * @param defines defines the Base texture to use.
  43941. * @param fallbacks defines the current fallback list.
  43942. * @param currentRank defines the current fallback rank.
  43943. * @returns the new fallback rank.
  43944. */
  43945. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43946. /**
  43947. * Add the required uniforms to the current list.
  43948. * @param uniforms defines the current uniform list.
  43949. */
  43950. static AddUniforms(uniforms: string[]): void;
  43951. /**
  43952. * Add the required uniforms to the current buffer.
  43953. * @param uniformBuffer defines the current uniform buffer.
  43954. */
  43955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43956. /**
  43957. * Add the required samplers to the current list.
  43958. * @param samplers defines the current sampler list.
  43959. */
  43960. static AddSamplers(samplers: string[]): void;
  43961. /**
  43962. * Makes a duplicate of the current configuration into another one.
  43963. * @param anisotropicConfiguration define the config where to copy the info
  43964. */
  43965. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43966. /**
  43967. * Serializes this anisotropy configuration.
  43968. * @returns - An object with the serialized config.
  43969. */
  43970. serialize(): any;
  43971. /**
  43972. * Parses a anisotropy Configuration from a serialized object.
  43973. * @param source - Serialized object.
  43974. */
  43975. parse(source: any): void;
  43976. }
  43977. }
  43978. declare module BABYLON {
  43979. /**
  43980. * @hidden
  43981. */
  43982. export interface IMaterialBRDFDefines {
  43983. BRDF_V_HEIGHT_CORRELATED: boolean;
  43984. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43985. /** @hidden */
  43986. _areMiscDirty: boolean;
  43987. }
  43988. /**
  43989. * Define the code related to the BRDF parameters of the pbr material.
  43990. */
  43991. export class PBRBRDFConfiguration {
  43992. /**
  43993. * Default value used for the energy conservation.
  43994. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43995. */
  43996. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43997. /**
  43998. * Default value used for the Smith Visibility Height Correlated mode.
  43999. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44000. */
  44001. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44002. private _useEnergyConservation;
  44003. /**
  44004. * Defines if the material uses energy conservation.
  44005. */
  44006. useEnergyConservation: boolean;
  44007. private _useSmithVisibilityHeightCorrelated;
  44008. /**
  44009. * LEGACY Mode set to false
  44010. * Defines if the material uses height smith correlated visibility term.
  44011. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44012. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44013. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44014. * Not relying on height correlated will also disable energy conservation.
  44015. */
  44016. useSmithVisibilityHeightCorrelated: boolean;
  44017. /** @hidden */
  44018. private _internalMarkAllSubMeshesAsMiscDirty;
  44019. /** @hidden */
  44020. _markAllSubMeshesAsMiscDirty(): void;
  44021. /**
  44022. * Instantiate a new istance of clear coat configuration.
  44023. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44024. */
  44025. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44026. /**
  44027. * Checks to see if a texture is used in the material.
  44028. * @param defines the list of "defines" to update.
  44029. */
  44030. prepareDefines(defines: IMaterialBRDFDefines): void;
  44031. /**
  44032. * Get the current class name of the texture useful for serialization or dynamic coding.
  44033. * @returns "PBRClearCoatConfiguration"
  44034. */
  44035. getClassName(): string;
  44036. /**
  44037. * Makes a duplicate of the current configuration into another one.
  44038. * @param brdfConfiguration define the config where to copy the info
  44039. */
  44040. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44041. /**
  44042. * Serializes this BRDF configuration.
  44043. * @returns - An object with the serialized config.
  44044. */
  44045. serialize(): any;
  44046. /**
  44047. * Parses a BRDF Configuration from a serialized object.
  44048. * @param source - Serialized object.
  44049. */
  44050. parse(source: any): void;
  44051. }
  44052. }
  44053. declare module BABYLON {
  44054. /**
  44055. * @hidden
  44056. */
  44057. export interface IMaterialSheenDefines {
  44058. SHEEN: boolean;
  44059. SHEEN_TEXTURE: boolean;
  44060. SHEEN_TEXTUREDIRECTUV: number;
  44061. SHEEN_LINKWITHALBEDO: boolean;
  44062. /** @hidden */
  44063. _areTexturesDirty: boolean;
  44064. }
  44065. /**
  44066. * Define the code related to the Sheen parameters of the pbr material.
  44067. */
  44068. export class PBRSheenConfiguration {
  44069. private _isEnabled;
  44070. /**
  44071. * Defines if the material uses sheen.
  44072. */
  44073. isEnabled: boolean;
  44074. private _linkSheenWithAlbedo;
  44075. /**
  44076. * Defines if the sheen is linked to the sheen color.
  44077. */
  44078. linkSheenWithAlbedo: boolean;
  44079. /**
  44080. * Defines the sheen intensity.
  44081. */
  44082. intensity: number;
  44083. /**
  44084. * Defines the sheen color.
  44085. */
  44086. color: Color3;
  44087. private _texture;
  44088. /**
  44089. * Stores the sheen tint values in a texture.
  44090. * rgb is tint
  44091. * a is a intensity
  44092. */
  44093. texture: Nullable<BaseTexture>;
  44094. /** @hidden */
  44095. private _internalMarkAllSubMeshesAsTexturesDirty;
  44096. /** @hidden */
  44097. _markAllSubMeshesAsTexturesDirty(): void;
  44098. /**
  44099. * Instantiate a new istance of clear coat configuration.
  44100. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44101. */
  44102. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44103. /**
  44104. * Specifies that the submesh is ready to be used.
  44105. * @param defines the list of "defines" to update.
  44106. * @param scene defines the scene the material belongs to.
  44107. * @returns - boolean indicating that the submesh is ready or not.
  44108. */
  44109. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44110. /**
  44111. * Checks to see if a texture is used in the material.
  44112. * @param defines the list of "defines" to update.
  44113. * @param scene defines the scene the material belongs to.
  44114. */
  44115. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44116. /**
  44117. * Binds the material data.
  44118. * @param uniformBuffer defines the Uniform buffer to fill in.
  44119. * @param scene defines the scene the material belongs to.
  44120. * @param isFrozen defines wether the material is frozen or not.
  44121. */
  44122. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44123. /**
  44124. * Checks to see if a texture is used in the material.
  44125. * @param texture - Base texture to use.
  44126. * @returns - Boolean specifying if a texture is used in the material.
  44127. */
  44128. hasTexture(texture: BaseTexture): boolean;
  44129. /**
  44130. * Returns an array of the actively used textures.
  44131. * @param activeTextures Array of BaseTextures
  44132. */
  44133. getActiveTextures(activeTextures: BaseTexture[]): void;
  44134. /**
  44135. * Returns the animatable textures.
  44136. * @param animatables Array of animatable textures.
  44137. */
  44138. getAnimatables(animatables: IAnimatable[]): void;
  44139. /**
  44140. * Disposes the resources of the material.
  44141. * @param forceDisposeTextures - Forces the disposal of all textures.
  44142. */
  44143. dispose(forceDisposeTextures?: boolean): void;
  44144. /**
  44145. * Get the current class name of the texture useful for serialization or dynamic coding.
  44146. * @returns "PBRSheenConfiguration"
  44147. */
  44148. getClassName(): string;
  44149. /**
  44150. * Add fallbacks to the effect fallbacks list.
  44151. * @param defines defines the Base texture to use.
  44152. * @param fallbacks defines the current fallback list.
  44153. * @param currentRank defines the current fallback rank.
  44154. * @returns the new fallback rank.
  44155. */
  44156. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44157. /**
  44158. * Add the required uniforms to the current list.
  44159. * @param uniforms defines the current uniform list.
  44160. */
  44161. static AddUniforms(uniforms: string[]): void;
  44162. /**
  44163. * Add the required uniforms to the current buffer.
  44164. * @param uniformBuffer defines the current uniform buffer.
  44165. */
  44166. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44167. /**
  44168. * Add the required samplers to the current list.
  44169. * @param samplers defines the current sampler list.
  44170. */
  44171. static AddSamplers(samplers: string[]): void;
  44172. /**
  44173. * Makes a duplicate of the current configuration into another one.
  44174. * @param sheenConfiguration define the config where to copy the info
  44175. */
  44176. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44177. /**
  44178. * Serializes this BRDF configuration.
  44179. * @returns - An object with the serialized config.
  44180. */
  44181. serialize(): any;
  44182. /**
  44183. * Parses a Sheen Configuration from a serialized object.
  44184. * @param source - Serialized object.
  44185. */
  44186. parse(source: any): void;
  44187. }
  44188. }
  44189. declare module BABYLON {
  44190. /**
  44191. * @hidden
  44192. */
  44193. export interface IMaterialSubSurfaceDefines {
  44194. SUBSURFACE: boolean;
  44195. SS_REFRACTION: boolean;
  44196. SS_TRANSLUCENCY: boolean;
  44197. SS_SCATERRING: boolean;
  44198. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44199. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44200. SS_REFRACTIONMAP_3D: boolean;
  44201. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44202. SS_LODINREFRACTIONALPHA: boolean;
  44203. SS_GAMMAREFRACTION: boolean;
  44204. SS_RGBDREFRACTION: boolean;
  44205. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44206. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44207. /** @hidden */
  44208. _areTexturesDirty: boolean;
  44209. }
  44210. /**
  44211. * Define the code related to the sub surface parameters of the pbr material.
  44212. */
  44213. export class PBRSubSurfaceConfiguration {
  44214. private _isRefractionEnabled;
  44215. /**
  44216. * Defines if the refraction is enabled in the material.
  44217. */
  44218. isRefractionEnabled: boolean;
  44219. private _isTranslucencyEnabled;
  44220. /**
  44221. * Defines if the translucency is enabled in the material.
  44222. */
  44223. isTranslucencyEnabled: boolean;
  44224. private _isScatteringEnabled;
  44225. /**
  44226. * Defines the refraction intensity of the material.
  44227. * The refraction when enabled replaces the Diffuse part of the material.
  44228. * The intensity helps transitionning between diffuse and refraction.
  44229. */
  44230. refractionIntensity: number;
  44231. /**
  44232. * Defines the translucency intensity of the material.
  44233. * When translucency has been enabled, this defines how much of the "translucency"
  44234. * is addded to the diffuse part of the material.
  44235. */
  44236. translucencyIntensity: number;
  44237. /**
  44238. * Defines the scattering intensity of the material.
  44239. * When scattering has been enabled, this defines how much of the "scattered light"
  44240. * is addded to the diffuse part of the material.
  44241. */
  44242. scatteringIntensity: number;
  44243. private _thicknessTexture;
  44244. /**
  44245. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44246. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44247. * 0 would mean minimumThickness
  44248. * 1 would mean maximumThickness
  44249. * The other channels might be use as a mask to vary the different effects intensity.
  44250. */
  44251. thicknessTexture: Nullable<BaseTexture>;
  44252. private _refractionTexture;
  44253. /**
  44254. * Defines the texture to use for refraction.
  44255. */
  44256. refractionTexture: Nullable<BaseTexture>;
  44257. private _indexOfRefraction;
  44258. /**
  44259. * Defines the indice of refraction used in the material.
  44260. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44261. */
  44262. indexOfRefraction: number;
  44263. private _invertRefractionY;
  44264. /**
  44265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44266. */
  44267. invertRefractionY: boolean;
  44268. private _linkRefractionWithTransparency;
  44269. /**
  44270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44271. * Materials half opaque for instance using refraction could benefit from this control.
  44272. */
  44273. linkRefractionWithTransparency: boolean;
  44274. /**
  44275. * Defines the minimum thickness stored in the thickness map.
  44276. * If no thickness map is defined, this value will be used to simulate thickness.
  44277. */
  44278. minimumThickness: number;
  44279. /**
  44280. * Defines the maximum thickness stored in the thickness map.
  44281. */
  44282. maximumThickness: number;
  44283. /**
  44284. * Defines the volume tint of the material.
  44285. * This is used for both translucency and scattering.
  44286. */
  44287. tintColor: Color3;
  44288. /**
  44289. * Defines the distance at which the tint color should be found in the media.
  44290. * This is used for refraction only.
  44291. */
  44292. tintColorAtDistance: number;
  44293. /**
  44294. * Defines how far each channel transmit through the media.
  44295. * It is defined as a color to simplify it selection.
  44296. */
  44297. diffusionDistance: Color3;
  44298. private _useMaskFromThicknessTexture;
  44299. /**
  44300. * Stores the intensity of the different subsurface effects in the thickness texture.
  44301. * * the green channel is the translucency intensity.
  44302. * * the blue channel is the scattering intensity.
  44303. * * the alpha channel is the refraction intensity.
  44304. */
  44305. useMaskFromThicknessTexture: boolean;
  44306. /** @hidden */
  44307. private _internalMarkAllSubMeshesAsTexturesDirty;
  44308. /** @hidden */
  44309. _markAllSubMeshesAsTexturesDirty(): void;
  44310. /**
  44311. * Instantiate a new istance of sub surface configuration.
  44312. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44313. */
  44314. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44315. /**
  44316. * Gets wehter the submesh is ready to be used or not.
  44317. * @param defines the list of "defines" to update.
  44318. * @param scene defines the scene the material belongs to.
  44319. * @returns - boolean indicating that the submesh is ready or not.
  44320. */
  44321. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44322. /**
  44323. * Checks to see if a texture is used in the material.
  44324. * @param defines the list of "defines" to update.
  44325. * @param scene defines the scene to the material belongs to.
  44326. */
  44327. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44328. /**
  44329. * Binds the material data.
  44330. * @param uniformBuffer defines the Uniform buffer to fill in.
  44331. * @param scene defines the scene the material belongs to.
  44332. * @param engine defines the engine the material belongs to.
  44333. * @param isFrozen defines wether the material is frozen or not.
  44334. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44335. */
  44336. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44337. /**
  44338. * Unbinds the material from the mesh.
  44339. * @param activeEffect defines the effect that should be unbound from.
  44340. * @returns true if unbound, otherwise false
  44341. */
  44342. unbind(activeEffect: Effect): boolean;
  44343. /**
  44344. * Returns the texture used for refraction or null if none is used.
  44345. * @param scene defines the scene the material belongs to.
  44346. * @returns - Refraction texture if present. If no refraction texture and refraction
  44347. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44348. */
  44349. private _getRefractionTexture;
  44350. /**
  44351. * Returns true if alpha blending should be disabled.
  44352. */
  44353. readonly disableAlphaBlending: boolean;
  44354. /**
  44355. * Fills the list of render target textures.
  44356. * @param renderTargets the list of render targets to update
  44357. */
  44358. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44359. /**
  44360. * Checks to see if a texture is used in the material.
  44361. * @param texture - Base texture to use.
  44362. * @returns - Boolean specifying if a texture is used in the material.
  44363. */
  44364. hasTexture(texture: BaseTexture): boolean;
  44365. /**
  44366. * Gets a boolean indicating that current material needs to register RTT
  44367. * @returns true if this uses a render target otherwise false.
  44368. */
  44369. hasRenderTargetTextures(): boolean;
  44370. /**
  44371. * Returns an array of the actively used textures.
  44372. * @param activeTextures Array of BaseTextures
  44373. */
  44374. getActiveTextures(activeTextures: BaseTexture[]): void;
  44375. /**
  44376. * Returns the animatable textures.
  44377. * @param animatables Array of animatable textures.
  44378. */
  44379. getAnimatables(animatables: IAnimatable[]): void;
  44380. /**
  44381. * Disposes the resources of the material.
  44382. * @param forceDisposeTextures - Forces the disposal of all textures.
  44383. */
  44384. dispose(forceDisposeTextures?: boolean): void;
  44385. /**
  44386. * Get the current class name of the texture useful for serialization or dynamic coding.
  44387. * @returns "PBRSubSurfaceConfiguration"
  44388. */
  44389. getClassName(): string;
  44390. /**
  44391. * Add fallbacks to the effect fallbacks list.
  44392. * @param defines defines the Base texture to use.
  44393. * @param fallbacks defines the current fallback list.
  44394. * @param currentRank defines the current fallback rank.
  44395. * @returns the new fallback rank.
  44396. */
  44397. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44398. /**
  44399. * Add the required uniforms to the current list.
  44400. * @param uniforms defines the current uniform list.
  44401. */
  44402. static AddUniforms(uniforms: string[]): void;
  44403. /**
  44404. * Add the required samplers to the current list.
  44405. * @param samplers defines the current sampler list.
  44406. */
  44407. static AddSamplers(samplers: string[]): void;
  44408. /**
  44409. * Add the required uniforms to the current buffer.
  44410. * @param uniformBuffer defines the current uniform buffer.
  44411. */
  44412. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44413. /**
  44414. * Makes a duplicate of the current configuration into another one.
  44415. * @param configuration define the config where to copy the info
  44416. */
  44417. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44418. /**
  44419. * Serializes this Sub Surface configuration.
  44420. * @returns - An object with the serialized config.
  44421. */
  44422. serialize(): any;
  44423. /**
  44424. * Parses a Sub Surface Configuration from a serialized object.
  44425. * @param source - Serialized object.
  44426. */
  44427. parse(source: any): void;
  44428. }
  44429. }
  44430. declare module BABYLON {
  44431. /** @hidden */
  44432. export var pbrFragmentDeclaration: {
  44433. name: string;
  44434. shader: string;
  44435. };
  44436. }
  44437. declare module BABYLON {
  44438. /** @hidden */
  44439. export var pbrUboDeclaration: {
  44440. name: string;
  44441. shader: string;
  44442. };
  44443. }
  44444. declare module BABYLON {
  44445. /** @hidden */
  44446. export var pbrFragmentExtraDeclaration: {
  44447. name: string;
  44448. shader: string;
  44449. };
  44450. }
  44451. declare module BABYLON {
  44452. /** @hidden */
  44453. export var pbrFragmentSamplersDeclaration: {
  44454. name: string;
  44455. shader: string;
  44456. };
  44457. }
  44458. declare module BABYLON {
  44459. /** @hidden */
  44460. export var pbrHelperFunctions: {
  44461. name: string;
  44462. shader: string;
  44463. };
  44464. }
  44465. declare module BABYLON {
  44466. /** @hidden */
  44467. export var harmonicsFunctions: {
  44468. name: string;
  44469. shader: string;
  44470. };
  44471. }
  44472. declare module BABYLON {
  44473. /** @hidden */
  44474. export var pbrDirectLightingSetupFunctions: {
  44475. name: string;
  44476. shader: string;
  44477. };
  44478. }
  44479. declare module BABYLON {
  44480. /** @hidden */
  44481. export var pbrDirectLightingFalloffFunctions: {
  44482. name: string;
  44483. shader: string;
  44484. };
  44485. }
  44486. declare module BABYLON {
  44487. /** @hidden */
  44488. export var pbrBRDFFunctions: {
  44489. name: string;
  44490. shader: string;
  44491. };
  44492. }
  44493. declare module BABYLON {
  44494. /** @hidden */
  44495. export var pbrDirectLightingFunctions: {
  44496. name: string;
  44497. shader: string;
  44498. };
  44499. }
  44500. declare module BABYLON {
  44501. /** @hidden */
  44502. export var pbrIBLFunctions: {
  44503. name: string;
  44504. shader: string;
  44505. };
  44506. }
  44507. declare module BABYLON {
  44508. /** @hidden */
  44509. export var pbrDebug: {
  44510. name: string;
  44511. shader: string;
  44512. };
  44513. }
  44514. declare module BABYLON {
  44515. /** @hidden */
  44516. export var pbrPixelShader: {
  44517. name: string;
  44518. shader: string;
  44519. };
  44520. }
  44521. declare module BABYLON {
  44522. /** @hidden */
  44523. export var pbrVertexDeclaration: {
  44524. name: string;
  44525. shader: string;
  44526. };
  44527. }
  44528. declare module BABYLON {
  44529. /** @hidden */
  44530. export var pbrVertexShader: {
  44531. name: string;
  44532. shader: string;
  44533. };
  44534. }
  44535. declare module BABYLON {
  44536. /**
  44537. * Manages the defines for the PBR Material.
  44538. * @hidden
  44539. */
  44540. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44541. PBR: boolean;
  44542. MAINUV1: boolean;
  44543. MAINUV2: boolean;
  44544. UV1: boolean;
  44545. UV2: boolean;
  44546. ALBEDO: boolean;
  44547. ALBEDODIRECTUV: number;
  44548. VERTEXCOLOR: boolean;
  44549. AMBIENT: boolean;
  44550. AMBIENTDIRECTUV: number;
  44551. AMBIENTINGRAYSCALE: boolean;
  44552. OPACITY: boolean;
  44553. VERTEXALPHA: boolean;
  44554. OPACITYDIRECTUV: number;
  44555. OPACITYRGB: boolean;
  44556. ALPHATEST: boolean;
  44557. DEPTHPREPASS: boolean;
  44558. ALPHABLEND: boolean;
  44559. ALPHAFROMALBEDO: boolean;
  44560. ALPHATESTVALUE: string;
  44561. SPECULAROVERALPHA: boolean;
  44562. RADIANCEOVERALPHA: boolean;
  44563. ALPHAFRESNEL: boolean;
  44564. LINEARALPHAFRESNEL: boolean;
  44565. PREMULTIPLYALPHA: boolean;
  44566. EMISSIVE: boolean;
  44567. EMISSIVEDIRECTUV: number;
  44568. REFLECTIVITY: boolean;
  44569. REFLECTIVITYDIRECTUV: number;
  44570. SPECULARTERM: boolean;
  44571. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44572. MICROSURFACEAUTOMATIC: boolean;
  44573. LODBASEDMICROSFURACE: boolean;
  44574. MICROSURFACEMAP: boolean;
  44575. MICROSURFACEMAPDIRECTUV: number;
  44576. METALLICWORKFLOW: boolean;
  44577. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44578. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44579. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44580. AOSTOREINMETALMAPRED: boolean;
  44581. ENVIRONMENTBRDF: boolean;
  44582. ENVIRONMENTBRDF_RGBD: boolean;
  44583. NORMAL: boolean;
  44584. TANGENT: boolean;
  44585. BUMP: boolean;
  44586. BUMPDIRECTUV: number;
  44587. OBJECTSPACE_NORMALMAP: boolean;
  44588. PARALLAX: boolean;
  44589. PARALLAXOCCLUSION: boolean;
  44590. NORMALXYSCALE: boolean;
  44591. LIGHTMAP: boolean;
  44592. LIGHTMAPDIRECTUV: number;
  44593. USELIGHTMAPASSHADOWMAP: boolean;
  44594. GAMMALIGHTMAP: boolean;
  44595. REFLECTION: boolean;
  44596. REFLECTIONMAP_3D: boolean;
  44597. REFLECTIONMAP_SPHERICAL: boolean;
  44598. REFLECTIONMAP_PLANAR: boolean;
  44599. REFLECTIONMAP_CUBIC: boolean;
  44600. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44601. REFLECTIONMAP_PROJECTION: boolean;
  44602. REFLECTIONMAP_SKYBOX: boolean;
  44603. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44604. REFLECTIONMAP_EXPLICIT: boolean;
  44605. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44606. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44607. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44608. INVERTCUBICMAP: boolean;
  44609. USESPHERICALFROMREFLECTIONMAP: boolean;
  44610. USESPHERICALINVERTEX: boolean;
  44611. REFLECTIONMAP_OPPOSITEZ: boolean;
  44612. LODINREFLECTIONALPHA: boolean;
  44613. GAMMAREFLECTION: boolean;
  44614. RGBDREFLECTION: boolean;
  44615. RADIANCEOCCLUSION: boolean;
  44616. HORIZONOCCLUSION: boolean;
  44617. INSTANCES: boolean;
  44618. NUM_BONE_INFLUENCERS: number;
  44619. BonesPerMesh: number;
  44620. BONETEXTURE: boolean;
  44621. NONUNIFORMSCALING: boolean;
  44622. MORPHTARGETS: boolean;
  44623. MORPHTARGETS_NORMAL: boolean;
  44624. MORPHTARGETS_TANGENT: boolean;
  44625. NUM_MORPH_INFLUENCERS: number;
  44626. IMAGEPROCESSING: boolean;
  44627. VIGNETTE: boolean;
  44628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44629. VIGNETTEBLENDMODEOPAQUE: boolean;
  44630. TONEMAPPING: boolean;
  44631. TONEMAPPING_ACES: boolean;
  44632. CONTRAST: boolean;
  44633. COLORCURVES: boolean;
  44634. COLORGRADING: boolean;
  44635. COLORGRADING3D: boolean;
  44636. SAMPLER3DGREENDEPTH: boolean;
  44637. SAMPLER3DBGRMAP: boolean;
  44638. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44639. EXPOSURE: boolean;
  44640. MULTIVIEW: boolean;
  44641. USEPHYSICALLIGHTFALLOFF: boolean;
  44642. USEGLTFLIGHTFALLOFF: boolean;
  44643. TWOSIDEDLIGHTING: boolean;
  44644. SHADOWFLOAT: boolean;
  44645. CLIPPLANE: boolean;
  44646. CLIPPLANE2: boolean;
  44647. CLIPPLANE3: boolean;
  44648. CLIPPLANE4: boolean;
  44649. POINTSIZE: boolean;
  44650. FOG: boolean;
  44651. LOGARITHMICDEPTH: boolean;
  44652. FORCENORMALFORWARD: boolean;
  44653. SPECULARAA: boolean;
  44654. CLEARCOAT: boolean;
  44655. CLEARCOAT_DEFAULTIOR: boolean;
  44656. CLEARCOAT_TEXTURE: boolean;
  44657. CLEARCOAT_TEXTUREDIRECTUV: number;
  44658. CLEARCOAT_BUMP: boolean;
  44659. CLEARCOAT_BUMPDIRECTUV: number;
  44660. CLEARCOAT_TINT: boolean;
  44661. CLEARCOAT_TINT_TEXTURE: boolean;
  44662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44663. ANISOTROPIC: boolean;
  44664. ANISOTROPIC_TEXTURE: boolean;
  44665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44666. BRDF_V_HEIGHT_CORRELATED: boolean;
  44667. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44668. SHEEN: boolean;
  44669. SHEEN_TEXTURE: boolean;
  44670. SHEEN_TEXTUREDIRECTUV: number;
  44671. SHEEN_LINKWITHALBEDO: boolean;
  44672. SUBSURFACE: boolean;
  44673. SS_REFRACTION: boolean;
  44674. SS_TRANSLUCENCY: boolean;
  44675. SS_SCATERRING: boolean;
  44676. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44677. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44678. SS_REFRACTIONMAP_3D: boolean;
  44679. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44680. SS_LODINREFRACTIONALPHA: boolean;
  44681. SS_GAMMAREFRACTION: boolean;
  44682. SS_RGBDREFRACTION: boolean;
  44683. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44684. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44685. UNLIT: boolean;
  44686. DEBUGMODE: number;
  44687. /**
  44688. * Initializes the PBR Material defines.
  44689. */
  44690. constructor();
  44691. /**
  44692. * Resets the PBR Material defines.
  44693. */
  44694. reset(): void;
  44695. }
  44696. /**
  44697. * The Physically based material base class of BJS.
  44698. *
  44699. * This offers the main features of a standard PBR material.
  44700. * For more information, please refer to the documentation :
  44701. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44702. */
  44703. export abstract class PBRBaseMaterial extends PushMaterial {
  44704. /**
  44705. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44706. */
  44707. static readonly PBRMATERIAL_OPAQUE: number;
  44708. /**
  44709. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44710. */
  44711. static readonly PBRMATERIAL_ALPHATEST: number;
  44712. /**
  44713. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44714. */
  44715. static readonly PBRMATERIAL_ALPHABLEND: number;
  44716. /**
  44717. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44718. * They are also discarded below the alpha cutoff threshold to improve performances.
  44719. */
  44720. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44721. /**
  44722. * Defines the default value of how much AO map is occluding the analytical lights
  44723. * (point spot...).
  44724. */
  44725. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44726. /**
  44727. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44728. */
  44729. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44730. /**
  44731. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44732. * to enhance interoperability with other engines.
  44733. */
  44734. static readonly LIGHTFALLOFF_GLTF: number;
  44735. /**
  44736. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44737. * to enhance interoperability with other materials.
  44738. */
  44739. static readonly LIGHTFALLOFF_STANDARD: number;
  44740. /**
  44741. * Intensity of the direct lights e.g. the four lights available in your scene.
  44742. * This impacts both the direct diffuse and specular highlights.
  44743. */
  44744. protected _directIntensity: number;
  44745. /**
  44746. * Intensity of the emissive part of the material.
  44747. * This helps controlling the emissive effect without modifying the emissive color.
  44748. */
  44749. protected _emissiveIntensity: number;
  44750. /**
  44751. * Intensity of the environment e.g. how much the environment will light the object
  44752. * either through harmonics for rough material or through the refelction for shiny ones.
  44753. */
  44754. protected _environmentIntensity: number;
  44755. /**
  44756. * This is a special control allowing the reduction of the specular highlights coming from the
  44757. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44758. */
  44759. protected _specularIntensity: number;
  44760. /**
  44761. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44762. */
  44763. private _lightingInfos;
  44764. /**
  44765. * Debug Control allowing disabling the bump map on this material.
  44766. */
  44767. protected _disableBumpMap: boolean;
  44768. /**
  44769. * AKA Diffuse Texture in standard nomenclature.
  44770. */
  44771. protected _albedoTexture: Nullable<BaseTexture>;
  44772. /**
  44773. * AKA Occlusion Texture in other nomenclature.
  44774. */
  44775. protected _ambientTexture: Nullable<BaseTexture>;
  44776. /**
  44777. * AKA Occlusion Texture Intensity in other nomenclature.
  44778. */
  44779. protected _ambientTextureStrength: number;
  44780. /**
  44781. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44782. * 1 means it completely occludes it
  44783. * 0 mean it has no impact
  44784. */
  44785. protected _ambientTextureImpactOnAnalyticalLights: number;
  44786. /**
  44787. * Stores the alpha values in a texture.
  44788. */
  44789. protected _opacityTexture: Nullable<BaseTexture>;
  44790. /**
  44791. * Stores the reflection values in a texture.
  44792. */
  44793. protected _reflectionTexture: Nullable<BaseTexture>;
  44794. /**
  44795. * Stores the emissive values in a texture.
  44796. */
  44797. protected _emissiveTexture: Nullable<BaseTexture>;
  44798. /**
  44799. * AKA Specular texture in other nomenclature.
  44800. */
  44801. protected _reflectivityTexture: Nullable<BaseTexture>;
  44802. /**
  44803. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44804. */
  44805. protected _metallicTexture: Nullable<BaseTexture>;
  44806. /**
  44807. * Specifies the metallic scalar of the metallic/roughness workflow.
  44808. * Can also be used to scale the metalness values of the metallic texture.
  44809. */
  44810. protected _metallic: Nullable<number>;
  44811. /**
  44812. * Specifies the roughness scalar of the metallic/roughness workflow.
  44813. * Can also be used to scale the roughness values of the metallic texture.
  44814. */
  44815. protected _roughness: Nullable<number>;
  44816. /**
  44817. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44818. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44819. */
  44820. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44821. /**
  44822. * Stores surface normal data used to displace a mesh in a texture.
  44823. */
  44824. protected _bumpTexture: Nullable<BaseTexture>;
  44825. /**
  44826. * Stores the pre-calculated light information of a mesh in a texture.
  44827. */
  44828. protected _lightmapTexture: Nullable<BaseTexture>;
  44829. /**
  44830. * The color of a material in ambient lighting.
  44831. */
  44832. protected _ambientColor: Color3;
  44833. /**
  44834. * AKA Diffuse Color in other nomenclature.
  44835. */
  44836. protected _albedoColor: Color3;
  44837. /**
  44838. * AKA Specular Color in other nomenclature.
  44839. */
  44840. protected _reflectivityColor: Color3;
  44841. /**
  44842. * The color applied when light is reflected from a material.
  44843. */
  44844. protected _reflectionColor: Color3;
  44845. /**
  44846. * The color applied when light is emitted from a material.
  44847. */
  44848. protected _emissiveColor: Color3;
  44849. /**
  44850. * AKA Glossiness in other nomenclature.
  44851. */
  44852. protected _microSurface: number;
  44853. /**
  44854. * Specifies that the material will use the light map as a show map.
  44855. */
  44856. protected _useLightmapAsShadowmap: boolean;
  44857. /**
  44858. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44859. * makes the reflect vector face the model (under horizon).
  44860. */
  44861. protected _useHorizonOcclusion: boolean;
  44862. /**
  44863. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44864. * too much the area relying on ambient texture to define their ambient occlusion.
  44865. */
  44866. protected _useRadianceOcclusion: boolean;
  44867. /**
  44868. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44869. */
  44870. protected _useAlphaFromAlbedoTexture: boolean;
  44871. /**
  44872. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44873. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44874. */
  44875. protected _useSpecularOverAlpha: boolean;
  44876. /**
  44877. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44878. */
  44879. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44880. /**
  44881. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44882. */
  44883. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44884. /**
  44885. * Specifies if the metallic texture contains the roughness information in its green channel.
  44886. */
  44887. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44888. /**
  44889. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44890. */
  44891. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44892. /**
  44893. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44894. */
  44895. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44896. /**
  44897. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44898. */
  44899. protected _useAmbientInGrayScale: boolean;
  44900. /**
  44901. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44902. * The material will try to infer what glossiness each pixel should be.
  44903. */
  44904. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44905. /**
  44906. * Defines the falloff type used in this material.
  44907. * It by default is Physical.
  44908. */
  44909. protected _lightFalloff: number;
  44910. /**
  44911. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44912. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44913. */
  44914. protected _useRadianceOverAlpha: boolean;
  44915. /**
  44916. * Allows using an object space normal map (instead of tangent space).
  44917. */
  44918. protected _useObjectSpaceNormalMap: boolean;
  44919. /**
  44920. * Allows using the bump map in parallax mode.
  44921. */
  44922. protected _useParallax: boolean;
  44923. /**
  44924. * Allows using the bump map in parallax occlusion mode.
  44925. */
  44926. protected _useParallaxOcclusion: boolean;
  44927. /**
  44928. * Controls the scale bias of the parallax mode.
  44929. */
  44930. protected _parallaxScaleBias: number;
  44931. /**
  44932. * If sets to true, disables all the lights affecting the material.
  44933. */
  44934. protected _disableLighting: boolean;
  44935. /**
  44936. * Number of Simultaneous lights allowed on the material.
  44937. */
  44938. protected _maxSimultaneousLights: number;
  44939. /**
  44940. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44941. */
  44942. protected _invertNormalMapX: boolean;
  44943. /**
  44944. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44945. */
  44946. protected _invertNormalMapY: boolean;
  44947. /**
  44948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44949. */
  44950. protected _twoSidedLighting: boolean;
  44951. /**
  44952. * Defines the alpha limits in alpha test mode.
  44953. */
  44954. protected _alphaCutOff: number;
  44955. /**
  44956. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44957. */
  44958. protected _forceAlphaTest: boolean;
  44959. /**
  44960. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44961. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44962. */
  44963. protected _useAlphaFresnel: boolean;
  44964. /**
  44965. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44966. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44967. */
  44968. protected _useLinearAlphaFresnel: boolean;
  44969. /**
  44970. * The transparency mode of the material.
  44971. */
  44972. protected _transparencyMode: Nullable<number>;
  44973. /**
  44974. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44975. * from cos thetav and roughness:
  44976. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44977. */
  44978. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44979. /**
  44980. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44981. */
  44982. protected _forceIrradianceInFragment: boolean;
  44983. /**
  44984. * Force normal to face away from face.
  44985. */
  44986. protected _forceNormalForward: boolean;
  44987. /**
  44988. * Enables specular anti aliasing in the PBR shader.
  44989. * It will both interacts on the Geometry for analytical and IBL lighting.
  44990. * It also prefilter the roughness map based on the bump values.
  44991. */
  44992. protected _enableSpecularAntiAliasing: boolean;
  44993. /**
  44994. * Default configuration related to image processing available in the PBR Material.
  44995. */
  44996. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44997. /**
  44998. * Keep track of the image processing observer to allow dispose and replace.
  44999. */
  45000. private _imageProcessingObserver;
  45001. /**
  45002. * Attaches a new image processing configuration to the PBR Material.
  45003. * @param configuration
  45004. */
  45005. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45006. /**
  45007. * Stores the available render targets.
  45008. */
  45009. private _renderTargets;
  45010. /**
  45011. * Sets the global ambient color for the material used in lighting calculations.
  45012. */
  45013. private _globalAmbientColor;
  45014. /**
  45015. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45016. */
  45017. private _useLogarithmicDepth;
  45018. /**
  45019. * If set to true, no lighting calculations will be applied.
  45020. */
  45021. private _unlit;
  45022. private _debugMode;
  45023. /**
  45024. * @hidden
  45025. * This is reserved for the inspector.
  45026. * Defines the material debug mode.
  45027. * It helps seeing only some components of the material while troubleshooting.
  45028. */
  45029. debugMode: number;
  45030. /**
  45031. * @hidden
  45032. * This is reserved for the inspector.
  45033. * Specify from where on screen the debug mode should start.
  45034. * The value goes from -1 (full screen) to 1 (not visible)
  45035. * It helps with side by side comparison against the final render
  45036. * This defaults to -1
  45037. */
  45038. private debugLimit;
  45039. /**
  45040. * @hidden
  45041. * This is reserved for the inspector.
  45042. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45043. * You can use the factor to better multiply the final value.
  45044. */
  45045. private debugFactor;
  45046. /**
  45047. * Defines the clear coat layer parameters for the material.
  45048. */
  45049. readonly clearCoat: PBRClearCoatConfiguration;
  45050. /**
  45051. * Defines the anisotropic parameters for the material.
  45052. */
  45053. readonly anisotropy: PBRAnisotropicConfiguration;
  45054. /**
  45055. * Defines the BRDF parameters for the material.
  45056. */
  45057. readonly brdf: PBRBRDFConfiguration;
  45058. /**
  45059. * Defines the Sheen parameters for the material.
  45060. */
  45061. readonly sheen: PBRSheenConfiguration;
  45062. /**
  45063. * Defines the SubSurface parameters for the material.
  45064. */
  45065. readonly subSurface: PBRSubSurfaceConfiguration;
  45066. /**
  45067. * Custom callback helping to override the default shader used in the material.
  45068. */
  45069. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45070. /**
  45071. * Instantiates a new PBRMaterial instance.
  45072. *
  45073. * @param name The material name
  45074. * @param scene The scene the material will be use in.
  45075. */
  45076. constructor(name: string, scene: Scene);
  45077. /**
  45078. * Gets a boolean indicating that current material needs to register RTT
  45079. */
  45080. readonly hasRenderTargetTextures: boolean;
  45081. /**
  45082. * Gets the name of the material class.
  45083. */
  45084. getClassName(): string;
  45085. /**
  45086. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45087. */
  45088. /**
  45089. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45090. */
  45091. useLogarithmicDepth: boolean;
  45092. /**
  45093. * Gets the current transparency mode.
  45094. */
  45095. /**
  45096. * Sets the transparency mode of the material.
  45097. *
  45098. * | Value | Type | Description |
  45099. * | ----- | ----------------------------------- | ----------- |
  45100. * | 0 | OPAQUE | |
  45101. * | 1 | ALPHATEST | |
  45102. * | 2 | ALPHABLEND | |
  45103. * | 3 | ALPHATESTANDBLEND | |
  45104. *
  45105. */
  45106. transparencyMode: Nullable<number>;
  45107. /**
  45108. * Returns true if alpha blending should be disabled.
  45109. */
  45110. private readonly _disableAlphaBlending;
  45111. /**
  45112. * Specifies whether or not this material should be rendered in alpha blend mode.
  45113. */
  45114. needAlphaBlending(): boolean;
  45115. /**
  45116. * Specifies if the mesh will require alpha blending.
  45117. * @param mesh - BJS mesh.
  45118. */
  45119. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45120. /**
  45121. * Specifies whether or not this material should be rendered in alpha test mode.
  45122. */
  45123. needAlphaTesting(): boolean;
  45124. /**
  45125. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45126. */
  45127. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45128. /**
  45129. * Gets the texture used for the alpha test.
  45130. */
  45131. getAlphaTestTexture(): Nullable<BaseTexture>;
  45132. /**
  45133. * Specifies that the submesh is ready to be used.
  45134. * @param mesh - BJS mesh.
  45135. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45136. * @param useInstances - Specifies that instances should be used.
  45137. * @returns - boolean indicating that the submesh is ready or not.
  45138. */
  45139. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45140. /**
  45141. * Specifies if the material uses metallic roughness workflow.
  45142. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45143. */
  45144. isMetallicWorkflow(): boolean;
  45145. private _prepareEffect;
  45146. private _prepareDefines;
  45147. /**
  45148. * Force shader compilation
  45149. */
  45150. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45151. clipPlane: boolean;
  45152. }>): void;
  45153. /**
  45154. * Initializes the uniform buffer layout for the shader.
  45155. */
  45156. buildUniformLayout(): void;
  45157. /**
  45158. * Unbinds the material from the mesh
  45159. */
  45160. unbind(): void;
  45161. /**
  45162. * Binds the submesh data.
  45163. * @param world - The world matrix.
  45164. * @param mesh - The BJS mesh.
  45165. * @param subMesh - A submesh of the BJS mesh.
  45166. */
  45167. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45168. /**
  45169. * Returns the animatable textures.
  45170. * @returns - Array of animatable textures.
  45171. */
  45172. getAnimatables(): IAnimatable[];
  45173. /**
  45174. * Returns the texture used for reflections.
  45175. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45176. */
  45177. private _getReflectionTexture;
  45178. /**
  45179. * Returns an array of the actively used textures.
  45180. * @returns - Array of BaseTextures
  45181. */
  45182. getActiveTextures(): BaseTexture[];
  45183. /**
  45184. * Checks to see if a texture is used in the material.
  45185. * @param texture - Base texture to use.
  45186. * @returns - Boolean specifying if a texture is used in the material.
  45187. */
  45188. hasTexture(texture: BaseTexture): boolean;
  45189. /**
  45190. * Disposes the resources of the material.
  45191. * @param forceDisposeEffect - Forces the disposal of effects.
  45192. * @param forceDisposeTextures - Forces the disposal of all textures.
  45193. */
  45194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45195. }
  45196. }
  45197. declare module BABYLON {
  45198. /**
  45199. * The Physically based material of BJS.
  45200. *
  45201. * This offers the main features of a standard PBR material.
  45202. * For more information, please refer to the documentation :
  45203. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45204. */
  45205. export class PBRMaterial extends PBRBaseMaterial {
  45206. /**
  45207. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45208. */
  45209. static readonly PBRMATERIAL_OPAQUE: number;
  45210. /**
  45211. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45212. */
  45213. static readonly PBRMATERIAL_ALPHATEST: number;
  45214. /**
  45215. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45216. */
  45217. static readonly PBRMATERIAL_ALPHABLEND: number;
  45218. /**
  45219. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45220. * They are also discarded below the alpha cutoff threshold to improve performances.
  45221. */
  45222. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45223. /**
  45224. * Defines the default value of how much AO map is occluding the analytical lights
  45225. * (point spot...).
  45226. */
  45227. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45228. /**
  45229. * Intensity of the direct lights e.g. the four lights available in your scene.
  45230. * This impacts both the direct diffuse and specular highlights.
  45231. */
  45232. directIntensity: number;
  45233. /**
  45234. * Intensity of the emissive part of the material.
  45235. * This helps controlling the emissive effect without modifying the emissive color.
  45236. */
  45237. emissiveIntensity: number;
  45238. /**
  45239. * Intensity of the environment e.g. how much the environment will light the object
  45240. * either through harmonics for rough material or through the refelction for shiny ones.
  45241. */
  45242. environmentIntensity: number;
  45243. /**
  45244. * This is a special control allowing the reduction of the specular highlights coming from the
  45245. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45246. */
  45247. specularIntensity: number;
  45248. /**
  45249. * Debug Control allowing disabling the bump map on this material.
  45250. */
  45251. disableBumpMap: boolean;
  45252. /**
  45253. * AKA Diffuse Texture in standard nomenclature.
  45254. */
  45255. albedoTexture: BaseTexture;
  45256. /**
  45257. * AKA Occlusion Texture in other nomenclature.
  45258. */
  45259. ambientTexture: BaseTexture;
  45260. /**
  45261. * AKA Occlusion Texture Intensity in other nomenclature.
  45262. */
  45263. ambientTextureStrength: number;
  45264. /**
  45265. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45266. * 1 means it completely occludes it
  45267. * 0 mean it has no impact
  45268. */
  45269. ambientTextureImpactOnAnalyticalLights: number;
  45270. /**
  45271. * Stores the alpha values in a texture.
  45272. */
  45273. opacityTexture: BaseTexture;
  45274. /**
  45275. * Stores the reflection values in a texture.
  45276. */
  45277. reflectionTexture: Nullable<BaseTexture>;
  45278. /**
  45279. * Stores the emissive values in a texture.
  45280. */
  45281. emissiveTexture: BaseTexture;
  45282. /**
  45283. * AKA Specular texture in other nomenclature.
  45284. */
  45285. reflectivityTexture: BaseTexture;
  45286. /**
  45287. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45288. */
  45289. metallicTexture: BaseTexture;
  45290. /**
  45291. * Specifies the metallic scalar of the metallic/roughness workflow.
  45292. * Can also be used to scale the metalness values of the metallic texture.
  45293. */
  45294. metallic: Nullable<number>;
  45295. /**
  45296. * Specifies the roughness scalar of the metallic/roughness workflow.
  45297. * Can also be used to scale the roughness values of the metallic texture.
  45298. */
  45299. roughness: Nullable<number>;
  45300. /**
  45301. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45302. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45303. */
  45304. microSurfaceTexture: BaseTexture;
  45305. /**
  45306. * Stores surface normal data used to displace a mesh in a texture.
  45307. */
  45308. bumpTexture: BaseTexture;
  45309. /**
  45310. * Stores the pre-calculated light information of a mesh in a texture.
  45311. */
  45312. lightmapTexture: BaseTexture;
  45313. /**
  45314. * Stores the refracted light information in a texture.
  45315. */
  45316. refractionTexture: Nullable<BaseTexture>;
  45317. /**
  45318. * The color of a material in ambient lighting.
  45319. */
  45320. ambientColor: Color3;
  45321. /**
  45322. * AKA Diffuse Color in other nomenclature.
  45323. */
  45324. albedoColor: Color3;
  45325. /**
  45326. * AKA Specular Color in other nomenclature.
  45327. */
  45328. reflectivityColor: Color3;
  45329. /**
  45330. * The color reflected from the material.
  45331. */
  45332. reflectionColor: Color3;
  45333. /**
  45334. * The color emitted from the material.
  45335. */
  45336. emissiveColor: Color3;
  45337. /**
  45338. * AKA Glossiness in other nomenclature.
  45339. */
  45340. microSurface: number;
  45341. /**
  45342. * source material index of refraction (IOR)' / 'destination material IOR.
  45343. */
  45344. indexOfRefraction: number;
  45345. /**
  45346. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45347. */
  45348. invertRefractionY: boolean;
  45349. /**
  45350. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45351. * Materials half opaque for instance using refraction could benefit from this control.
  45352. */
  45353. linkRefractionWithTransparency: boolean;
  45354. /**
  45355. * If true, the light map contains occlusion information instead of lighting info.
  45356. */
  45357. useLightmapAsShadowmap: boolean;
  45358. /**
  45359. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45360. */
  45361. useAlphaFromAlbedoTexture: boolean;
  45362. /**
  45363. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45364. */
  45365. forceAlphaTest: boolean;
  45366. /**
  45367. * Defines the alpha limits in alpha test mode.
  45368. */
  45369. alphaCutOff: number;
  45370. /**
  45371. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45372. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45373. */
  45374. useSpecularOverAlpha: boolean;
  45375. /**
  45376. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45377. */
  45378. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45379. /**
  45380. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45381. */
  45382. useRoughnessFromMetallicTextureAlpha: boolean;
  45383. /**
  45384. * Specifies if the metallic texture contains the roughness information in its green channel.
  45385. */
  45386. useRoughnessFromMetallicTextureGreen: boolean;
  45387. /**
  45388. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45389. */
  45390. useMetallnessFromMetallicTextureBlue: boolean;
  45391. /**
  45392. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45393. */
  45394. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45395. /**
  45396. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45397. */
  45398. useAmbientInGrayScale: boolean;
  45399. /**
  45400. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45401. * The material will try to infer what glossiness each pixel should be.
  45402. */
  45403. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45404. /**
  45405. * BJS is using an harcoded light falloff based on a manually sets up range.
  45406. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45407. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45408. */
  45409. /**
  45410. * BJS is using an harcoded light falloff based on a manually sets up range.
  45411. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45412. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45413. */
  45414. usePhysicalLightFalloff: boolean;
  45415. /**
  45416. * In order to support the falloff compatibility with gltf, a special mode has been added
  45417. * to reproduce the gltf light falloff.
  45418. */
  45419. /**
  45420. * In order to support the falloff compatibility with gltf, a special mode has been added
  45421. * to reproduce the gltf light falloff.
  45422. */
  45423. useGLTFLightFalloff: boolean;
  45424. /**
  45425. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45426. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45427. */
  45428. useRadianceOverAlpha: boolean;
  45429. /**
  45430. * Allows using an object space normal map (instead of tangent space).
  45431. */
  45432. useObjectSpaceNormalMap: boolean;
  45433. /**
  45434. * Allows using the bump map in parallax mode.
  45435. */
  45436. useParallax: boolean;
  45437. /**
  45438. * Allows using the bump map in parallax occlusion mode.
  45439. */
  45440. useParallaxOcclusion: boolean;
  45441. /**
  45442. * Controls the scale bias of the parallax mode.
  45443. */
  45444. parallaxScaleBias: number;
  45445. /**
  45446. * If sets to true, disables all the lights affecting the material.
  45447. */
  45448. disableLighting: boolean;
  45449. /**
  45450. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45451. */
  45452. forceIrradianceInFragment: boolean;
  45453. /**
  45454. * Number of Simultaneous lights allowed on the material.
  45455. */
  45456. maxSimultaneousLights: number;
  45457. /**
  45458. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45459. */
  45460. invertNormalMapX: boolean;
  45461. /**
  45462. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45463. */
  45464. invertNormalMapY: boolean;
  45465. /**
  45466. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45467. */
  45468. twoSidedLighting: boolean;
  45469. /**
  45470. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45471. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45472. */
  45473. useAlphaFresnel: boolean;
  45474. /**
  45475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45476. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45477. */
  45478. useLinearAlphaFresnel: boolean;
  45479. /**
  45480. * Let user defines the brdf lookup texture used for IBL.
  45481. * A default 8bit version is embedded but you could point at :
  45482. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45483. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45484. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45485. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45486. */
  45487. environmentBRDFTexture: Nullable<BaseTexture>;
  45488. /**
  45489. * Force normal to face away from face.
  45490. */
  45491. forceNormalForward: boolean;
  45492. /**
  45493. * Enables specular anti aliasing in the PBR shader.
  45494. * It will both interacts on the Geometry for analytical and IBL lighting.
  45495. * It also prefilter the roughness map based on the bump values.
  45496. */
  45497. enableSpecularAntiAliasing: boolean;
  45498. /**
  45499. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45500. * makes the reflect vector face the model (under horizon).
  45501. */
  45502. useHorizonOcclusion: boolean;
  45503. /**
  45504. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45505. * too much the area relying on ambient texture to define their ambient occlusion.
  45506. */
  45507. useRadianceOcclusion: boolean;
  45508. /**
  45509. * If set to true, no lighting calculations will be applied.
  45510. */
  45511. unlit: boolean;
  45512. /**
  45513. * Gets the image processing configuration used either in this material.
  45514. */
  45515. /**
  45516. * Sets the Default image processing configuration used either in the this material.
  45517. *
  45518. * If sets to null, the scene one is in use.
  45519. */
  45520. imageProcessingConfiguration: ImageProcessingConfiguration;
  45521. /**
  45522. * Gets wether the color curves effect is enabled.
  45523. */
  45524. /**
  45525. * Sets wether the color curves effect is enabled.
  45526. */
  45527. cameraColorCurvesEnabled: boolean;
  45528. /**
  45529. * Gets wether the color grading effect is enabled.
  45530. */
  45531. /**
  45532. * Gets wether the color grading effect is enabled.
  45533. */
  45534. cameraColorGradingEnabled: boolean;
  45535. /**
  45536. * Gets wether tonemapping is enabled or not.
  45537. */
  45538. /**
  45539. * Sets wether tonemapping is enabled or not
  45540. */
  45541. cameraToneMappingEnabled: boolean;
  45542. /**
  45543. * The camera exposure used on this material.
  45544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45545. * This corresponds to a photographic exposure.
  45546. */
  45547. /**
  45548. * The camera exposure used on this material.
  45549. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45550. * This corresponds to a photographic exposure.
  45551. */
  45552. cameraExposure: number;
  45553. /**
  45554. * Gets The camera contrast used on this material.
  45555. */
  45556. /**
  45557. * Sets The camera contrast used on this material.
  45558. */
  45559. cameraContrast: number;
  45560. /**
  45561. * Gets the Color Grading 2D Lookup Texture.
  45562. */
  45563. /**
  45564. * Sets the Color Grading 2D Lookup Texture.
  45565. */
  45566. cameraColorGradingTexture: Nullable<BaseTexture>;
  45567. /**
  45568. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45569. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45570. * 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;
  45571. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45572. */
  45573. /**
  45574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45576. * 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;
  45577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45578. */
  45579. cameraColorCurves: Nullable<ColorCurves>;
  45580. /**
  45581. * Instantiates a new PBRMaterial instance.
  45582. *
  45583. * @param name The material name
  45584. * @param scene The scene the material will be use in.
  45585. */
  45586. constructor(name: string, scene: Scene);
  45587. /**
  45588. * Returns the name of this material class.
  45589. */
  45590. getClassName(): string;
  45591. /**
  45592. * Makes a duplicate of the current material.
  45593. * @param name - name to use for the new material.
  45594. */
  45595. clone(name: string): PBRMaterial;
  45596. /**
  45597. * Serializes this PBR Material.
  45598. * @returns - An object with the serialized material.
  45599. */
  45600. serialize(): any;
  45601. /**
  45602. * Parses a PBR Material from a serialized object.
  45603. * @param source - Serialized object.
  45604. * @param scene - BJS scene instance.
  45605. * @param rootUrl - url for the scene object
  45606. * @returns - PBRMaterial
  45607. */
  45608. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45609. }
  45610. }
  45611. declare module BABYLON {
  45612. /**
  45613. * Direct draw surface info
  45614. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45615. */
  45616. export interface DDSInfo {
  45617. /**
  45618. * Width of the texture
  45619. */
  45620. width: number;
  45621. /**
  45622. * Width of the texture
  45623. */
  45624. height: number;
  45625. /**
  45626. * Number of Mipmaps for the texture
  45627. * @see https://en.wikipedia.org/wiki/Mipmap
  45628. */
  45629. mipmapCount: number;
  45630. /**
  45631. * If the textures format is a known fourCC format
  45632. * @see https://www.fourcc.org/
  45633. */
  45634. isFourCC: boolean;
  45635. /**
  45636. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45637. */
  45638. isRGB: boolean;
  45639. /**
  45640. * If the texture is a lumincance format
  45641. */
  45642. isLuminance: boolean;
  45643. /**
  45644. * If this is a cube texture
  45645. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45646. */
  45647. isCube: boolean;
  45648. /**
  45649. * If the texture is a compressed format eg. FOURCC_DXT1
  45650. */
  45651. isCompressed: boolean;
  45652. /**
  45653. * The dxgiFormat of the texture
  45654. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45655. */
  45656. dxgiFormat: number;
  45657. /**
  45658. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45659. */
  45660. textureType: number;
  45661. /**
  45662. * Sphericle polynomial created for the dds texture
  45663. */
  45664. sphericalPolynomial?: SphericalPolynomial;
  45665. }
  45666. /**
  45667. * Class used to provide DDS decompression tools
  45668. */
  45669. export class DDSTools {
  45670. /**
  45671. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45672. */
  45673. static StoreLODInAlphaChannel: boolean;
  45674. /**
  45675. * Gets DDS information from an array buffer
  45676. * @param arrayBuffer defines the array buffer to read data from
  45677. * @returns the DDS information
  45678. */
  45679. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45680. private static _FloatView;
  45681. private static _Int32View;
  45682. private static _ToHalfFloat;
  45683. private static _FromHalfFloat;
  45684. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45685. private static _GetHalfFloatRGBAArrayBuffer;
  45686. private static _GetFloatRGBAArrayBuffer;
  45687. private static _GetFloatAsUIntRGBAArrayBuffer;
  45688. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45689. private static _GetRGBAArrayBuffer;
  45690. private static _ExtractLongWordOrder;
  45691. private static _GetRGBArrayBuffer;
  45692. private static _GetLuminanceArrayBuffer;
  45693. /**
  45694. * Uploads DDS Levels to a Babylon Texture
  45695. * @hidden
  45696. */
  45697. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45698. }
  45699. interface Engine {
  45700. /**
  45701. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45702. * @param rootUrl defines the url where the file to load is located
  45703. * @param scene defines the current scene
  45704. * @param lodScale defines scale to apply to the mip map selection
  45705. * @param lodOffset defines offset to apply to the mip map selection
  45706. * @param onLoad defines an optional callback raised when the texture is loaded
  45707. * @param onError defines an optional callback raised if there is an issue to load the texture
  45708. * @param format defines the format of the data
  45709. * @param forcedExtension defines the extension to use to pick the right loader
  45710. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45711. * @returns the cube texture as an InternalTexture
  45712. */
  45713. 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;
  45714. }
  45715. }
  45716. declare module BABYLON {
  45717. /**
  45718. * Implementation of the DDS Texture Loader.
  45719. * @hidden
  45720. */
  45721. export class _DDSTextureLoader implements IInternalTextureLoader {
  45722. /**
  45723. * Defines wether the loader supports cascade loading the different faces.
  45724. */
  45725. readonly supportCascades: boolean;
  45726. /**
  45727. * This returns if the loader support the current file information.
  45728. * @param extension defines the file extension of the file being loaded
  45729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45730. * @param fallback defines the fallback internal texture if any
  45731. * @param isBase64 defines whether the texture is encoded as a base64
  45732. * @param isBuffer defines whether the texture data are stored as a buffer
  45733. * @returns true if the loader can load the specified file
  45734. */
  45735. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45736. /**
  45737. * Transform the url before loading if required.
  45738. * @param rootUrl the url of the texture
  45739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45740. * @returns the transformed texture
  45741. */
  45742. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45743. /**
  45744. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45745. * @param rootUrl the url of the texture
  45746. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45747. * @returns the fallback texture
  45748. */
  45749. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45750. /**
  45751. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45752. * @param data contains the texture data
  45753. * @param texture defines the BabylonJS internal texture
  45754. * @param createPolynomials will be true if polynomials have been requested
  45755. * @param onLoad defines the callback to trigger once the texture is ready
  45756. * @param onError defines the callback to trigger in case of error
  45757. */
  45758. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45759. /**
  45760. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45761. * @param data contains the texture data
  45762. * @param texture defines the BabylonJS internal texture
  45763. * @param callback defines the method to call once ready to upload
  45764. */
  45765. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /** @hidden */
  45770. export var rgbdEncodePixelShader: {
  45771. name: string;
  45772. shader: string;
  45773. };
  45774. }
  45775. declare module BABYLON {
  45776. /**
  45777. * Raw texture data and descriptor sufficient for WebGL texture upload
  45778. */
  45779. export interface EnvironmentTextureInfo {
  45780. /**
  45781. * Version of the environment map
  45782. */
  45783. version: number;
  45784. /**
  45785. * Width of image
  45786. */
  45787. width: number;
  45788. /**
  45789. * Irradiance information stored in the file.
  45790. */
  45791. irradiance: any;
  45792. /**
  45793. * Specular information stored in the file.
  45794. */
  45795. specular: any;
  45796. }
  45797. /**
  45798. * Sets of helpers addressing the serialization and deserialization of environment texture
  45799. * stored in a BabylonJS env file.
  45800. * Those files are usually stored as .env files.
  45801. */
  45802. export class EnvironmentTextureTools {
  45803. /**
  45804. * Magic number identifying the env file.
  45805. */
  45806. private static _MagicBytes;
  45807. /**
  45808. * Gets the environment info from an env file.
  45809. * @param data The array buffer containing the .env bytes.
  45810. * @returns the environment file info (the json header) if successfully parsed.
  45811. */
  45812. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45813. /**
  45814. * Creates an environment texture from a loaded cube texture.
  45815. * @param texture defines the cube texture to convert in env file
  45816. * @return a promise containing the environment data if succesfull.
  45817. */
  45818. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45819. /**
  45820. * Creates a JSON representation of the spherical data.
  45821. * @param texture defines the texture containing the polynomials
  45822. * @return the JSON representation of the spherical info
  45823. */
  45824. private static _CreateEnvTextureIrradiance;
  45825. /**
  45826. * Uploads the texture info contained in the env file to the GPU.
  45827. * @param texture defines the internal texture to upload to
  45828. * @param arrayBuffer defines the buffer cotaining the data to load
  45829. * @param info defines the texture info retrieved through the GetEnvInfo method
  45830. * @returns a promise
  45831. */
  45832. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45833. /**
  45834. * Uploads the levels of image data to the GPU.
  45835. * @param texture defines the internal texture to upload to
  45836. * @param imageData defines the array buffer views of image data [mipmap][face]
  45837. * @returns a promise
  45838. */
  45839. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45840. /**
  45841. * Uploads spherical polynomials information to the texture.
  45842. * @param texture defines the texture we are trying to upload the information to
  45843. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45844. */
  45845. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45846. /** @hidden */
  45847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45848. }
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * Implementation of the ENV Texture Loader.
  45853. * @hidden
  45854. */
  45855. export class _ENVTextureLoader implements IInternalTextureLoader {
  45856. /**
  45857. * Defines wether the loader supports cascade loading the different faces.
  45858. */
  45859. readonly supportCascades: boolean;
  45860. /**
  45861. * This returns if the loader support the current file information.
  45862. * @param extension defines the file extension of the file being loaded
  45863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45864. * @param fallback defines the fallback internal texture if any
  45865. * @param isBase64 defines whether the texture is encoded as a base64
  45866. * @param isBuffer defines whether the texture data are stored as a buffer
  45867. * @returns true if the loader can load the specified file
  45868. */
  45869. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45870. /**
  45871. * Transform the url before loading if required.
  45872. * @param rootUrl the url of the texture
  45873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45874. * @returns the transformed texture
  45875. */
  45876. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45877. /**
  45878. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45879. * @param rootUrl the url of the texture
  45880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45881. * @returns the fallback texture
  45882. */
  45883. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45884. /**
  45885. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45886. * @param data contains the texture data
  45887. * @param texture defines the BabylonJS internal texture
  45888. * @param createPolynomials will be true if polynomials have been requested
  45889. * @param onLoad defines the callback to trigger once the texture is ready
  45890. * @param onError defines the callback to trigger in case of error
  45891. */
  45892. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45893. /**
  45894. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45895. * @param data contains the texture data
  45896. * @param texture defines the BabylonJS internal texture
  45897. * @param callback defines the method to call once ready to upload
  45898. */
  45899. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45900. }
  45901. }
  45902. declare module BABYLON {
  45903. /**
  45904. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45905. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45906. */
  45907. export class KhronosTextureContainer {
  45908. /** contents of the KTX container file */
  45909. arrayBuffer: any;
  45910. private static HEADER_LEN;
  45911. private static COMPRESSED_2D;
  45912. private static COMPRESSED_3D;
  45913. private static TEX_2D;
  45914. private static TEX_3D;
  45915. /**
  45916. * Gets the openGL type
  45917. */
  45918. glType: number;
  45919. /**
  45920. * Gets the openGL type size
  45921. */
  45922. glTypeSize: number;
  45923. /**
  45924. * Gets the openGL format
  45925. */
  45926. glFormat: number;
  45927. /**
  45928. * Gets the openGL internal format
  45929. */
  45930. glInternalFormat: number;
  45931. /**
  45932. * Gets the base internal format
  45933. */
  45934. glBaseInternalFormat: number;
  45935. /**
  45936. * Gets image width in pixel
  45937. */
  45938. pixelWidth: number;
  45939. /**
  45940. * Gets image height in pixel
  45941. */
  45942. pixelHeight: number;
  45943. /**
  45944. * Gets image depth in pixels
  45945. */
  45946. pixelDepth: number;
  45947. /**
  45948. * Gets the number of array elements
  45949. */
  45950. numberOfArrayElements: number;
  45951. /**
  45952. * Gets the number of faces
  45953. */
  45954. numberOfFaces: number;
  45955. /**
  45956. * Gets the number of mipmap levels
  45957. */
  45958. numberOfMipmapLevels: number;
  45959. /**
  45960. * Gets the bytes of key value data
  45961. */
  45962. bytesOfKeyValueData: number;
  45963. /**
  45964. * Gets the load type
  45965. */
  45966. loadType: number;
  45967. /**
  45968. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45969. */
  45970. isInvalid: boolean;
  45971. /**
  45972. * Creates a new KhronosTextureContainer
  45973. * @param arrayBuffer contents of the KTX container file
  45974. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45975. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45976. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45977. */
  45978. constructor(
  45979. /** contents of the KTX container file */
  45980. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45981. /**
  45982. * Uploads KTX content to a Babylon Texture.
  45983. * It is assumed that the texture has already been created & is currently bound
  45984. * @hidden
  45985. */
  45986. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45987. private _upload2DCompressedLevels;
  45988. }
  45989. }
  45990. declare module BABYLON {
  45991. /**
  45992. * Implementation of the KTX Texture Loader.
  45993. * @hidden
  45994. */
  45995. export class _KTXTextureLoader implements IInternalTextureLoader {
  45996. /**
  45997. * Defines wether the loader supports cascade loading the different faces.
  45998. */
  45999. readonly supportCascades: boolean;
  46000. /**
  46001. * This returns if the loader support the current file information.
  46002. * @param extension defines the file extension of the file being loaded
  46003. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46004. * @param fallback defines the fallback internal texture if any
  46005. * @param isBase64 defines whether the texture is encoded as a base64
  46006. * @param isBuffer defines whether the texture data are stored as a buffer
  46007. * @returns true if the loader can load the specified file
  46008. */
  46009. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46010. /**
  46011. * Transform the url before loading if required.
  46012. * @param rootUrl the url of the texture
  46013. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46014. * @returns the transformed texture
  46015. */
  46016. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46017. /**
  46018. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46019. * @param rootUrl the url of the texture
  46020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46021. * @returns the fallback texture
  46022. */
  46023. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46024. /**
  46025. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46026. * @param data contains the texture data
  46027. * @param texture defines the BabylonJS internal texture
  46028. * @param createPolynomials will be true if polynomials have been requested
  46029. * @param onLoad defines the callback to trigger once the texture is ready
  46030. * @param onError defines the callback to trigger in case of error
  46031. */
  46032. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46033. /**
  46034. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46035. * @param data contains the texture data
  46036. * @param texture defines the BabylonJS internal texture
  46037. * @param callback defines the method to call once ready to upload
  46038. */
  46039. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46040. }
  46041. }
  46042. declare module BABYLON {
  46043. /** @hidden */
  46044. export var _forceSceneHelpersToBundle: boolean;
  46045. interface Scene {
  46046. /**
  46047. * Creates a default light for the scene.
  46048. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46049. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46050. */
  46051. createDefaultLight(replace?: boolean): void;
  46052. /**
  46053. * Creates a default camera for the scene.
  46054. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46055. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46056. * @param replace has default false, when true replaces the active camera in the scene
  46057. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46058. */
  46059. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46060. /**
  46061. * Creates a default camera and a default light.
  46062. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46063. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46064. * @param replace has the default false, when true replaces the active camera/light in the scene
  46065. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46066. */
  46067. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46068. /**
  46069. * Creates a new sky box
  46070. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46071. * @param environmentTexture defines the texture to use as environment texture
  46072. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46073. * @param scale defines the overall scale of the skybox
  46074. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46075. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46076. * @returns a new mesh holding the sky box
  46077. */
  46078. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46079. /**
  46080. * Creates a new environment
  46081. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46082. * @param options defines the options you can use to configure the environment
  46083. * @returns the new EnvironmentHelper
  46084. */
  46085. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46086. /**
  46087. * Creates a new VREXperienceHelper
  46088. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46089. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46090. * @returns a new VREXperienceHelper
  46091. */
  46092. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46093. /**
  46094. * Creates a new XREXperienceHelper
  46095. * @see http://doc.babylonjs.com/how_to/webxr
  46096. * @returns a promise for a new XREXperienceHelper
  46097. */
  46098. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46099. }
  46100. }
  46101. declare module BABYLON {
  46102. /**
  46103. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46104. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46105. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46106. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46107. */
  46108. export class VideoDome extends TransformNode {
  46109. /**
  46110. * Define the video source as a Monoscopic panoramic 360 video.
  46111. */
  46112. static readonly MODE_MONOSCOPIC: number;
  46113. /**
  46114. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46115. */
  46116. static readonly MODE_TOPBOTTOM: number;
  46117. /**
  46118. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46119. */
  46120. static readonly MODE_SIDEBYSIDE: number;
  46121. private _useDirectMapping;
  46122. /**
  46123. * The video texture being displayed on the sphere
  46124. */
  46125. protected _videoTexture: VideoTexture;
  46126. /**
  46127. * Gets the video texture being displayed on the sphere
  46128. */
  46129. readonly videoTexture: VideoTexture;
  46130. /**
  46131. * The skybox material
  46132. */
  46133. protected _material: BackgroundMaterial;
  46134. /**
  46135. * The surface used for the skybox
  46136. */
  46137. protected _mesh: Mesh;
  46138. /**
  46139. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46140. * Also see the options.resolution property.
  46141. */
  46142. fovMultiplier: number;
  46143. private _videoMode;
  46144. /**
  46145. * Gets or set the current video mode for the video. It can be:
  46146. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46147. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46148. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46149. */
  46150. videoMode: number;
  46151. /**
  46152. * Oberserver used in Stereoscopic VR Mode.
  46153. */
  46154. private _onBeforeCameraRenderObserver;
  46155. /**
  46156. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46157. * @param name Element's name, child elements will append suffixes for their own names.
  46158. * @param urlsOrVideo defines the url(s) or the video element to use
  46159. * @param options An object containing optional or exposed sub element properties
  46160. */
  46161. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46162. resolution?: number;
  46163. clickToPlay?: boolean;
  46164. autoPlay?: boolean;
  46165. loop?: boolean;
  46166. size?: number;
  46167. poster?: string;
  46168. faceForward?: boolean;
  46169. useDirectMapping?: boolean;
  46170. }, scene: Scene);
  46171. private _changeVideoMode;
  46172. /**
  46173. * Releases resources associated with this node.
  46174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46176. */
  46177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46178. }
  46179. }
  46180. declare module BABYLON {
  46181. /**
  46182. * This class can be used to get instrumentation data from a Babylon engine
  46183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46184. */
  46185. export class EngineInstrumentation implements IDisposable {
  46186. /**
  46187. * Define the instrumented engine.
  46188. */
  46189. engine: Engine;
  46190. private _captureGPUFrameTime;
  46191. private _gpuFrameTimeToken;
  46192. private _gpuFrameTime;
  46193. private _captureShaderCompilationTime;
  46194. private _shaderCompilationTime;
  46195. private _onBeginFrameObserver;
  46196. private _onEndFrameObserver;
  46197. private _onBeforeShaderCompilationObserver;
  46198. private _onAfterShaderCompilationObserver;
  46199. /**
  46200. * Gets the perf counter used for GPU frame time
  46201. */
  46202. readonly gpuFrameTimeCounter: PerfCounter;
  46203. /**
  46204. * Gets the GPU frame time capture status
  46205. */
  46206. /**
  46207. * Enable or disable the GPU frame time capture
  46208. */
  46209. captureGPUFrameTime: boolean;
  46210. /**
  46211. * Gets the perf counter used for shader compilation time
  46212. */
  46213. readonly shaderCompilationTimeCounter: PerfCounter;
  46214. /**
  46215. * Gets the shader compilation time capture status
  46216. */
  46217. /**
  46218. * Enable or disable the shader compilation time capture
  46219. */
  46220. captureShaderCompilationTime: boolean;
  46221. /**
  46222. * Instantiates a new engine instrumentation.
  46223. * This class can be used to get instrumentation data from a Babylon engine
  46224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46225. * @param engine Defines the engine to instrument
  46226. */
  46227. constructor(
  46228. /**
  46229. * Define the instrumented engine.
  46230. */
  46231. engine: Engine);
  46232. /**
  46233. * Dispose and release associated resources.
  46234. */
  46235. dispose(): void;
  46236. }
  46237. }
  46238. declare module BABYLON {
  46239. /**
  46240. * This class can be used to get instrumentation data from a Babylon engine
  46241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46242. */
  46243. export class SceneInstrumentation implements IDisposable {
  46244. /**
  46245. * Defines the scene to instrument
  46246. */
  46247. scene: Scene;
  46248. private _captureActiveMeshesEvaluationTime;
  46249. private _activeMeshesEvaluationTime;
  46250. private _captureRenderTargetsRenderTime;
  46251. private _renderTargetsRenderTime;
  46252. private _captureFrameTime;
  46253. private _frameTime;
  46254. private _captureRenderTime;
  46255. private _renderTime;
  46256. private _captureInterFrameTime;
  46257. private _interFrameTime;
  46258. private _captureParticlesRenderTime;
  46259. private _particlesRenderTime;
  46260. private _captureSpritesRenderTime;
  46261. private _spritesRenderTime;
  46262. private _capturePhysicsTime;
  46263. private _physicsTime;
  46264. private _captureAnimationsTime;
  46265. private _animationsTime;
  46266. private _captureCameraRenderTime;
  46267. private _cameraRenderTime;
  46268. private _onBeforeActiveMeshesEvaluationObserver;
  46269. private _onAfterActiveMeshesEvaluationObserver;
  46270. private _onBeforeRenderTargetsRenderObserver;
  46271. private _onAfterRenderTargetsRenderObserver;
  46272. private _onAfterRenderObserver;
  46273. private _onBeforeDrawPhaseObserver;
  46274. private _onAfterDrawPhaseObserver;
  46275. private _onBeforeAnimationsObserver;
  46276. private _onBeforeParticlesRenderingObserver;
  46277. private _onAfterParticlesRenderingObserver;
  46278. private _onBeforeSpritesRenderingObserver;
  46279. private _onAfterSpritesRenderingObserver;
  46280. private _onBeforePhysicsObserver;
  46281. private _onAfterPhysicsObserver;
  46282. private _onAfterAnimationsObserver;
  46283. private _onBeforeCameraRenderObserver;
  46284. private _onAfterCameraRenderObserver;
  46285. /**
  46286. * Gets the perf counter used for active meshes evaluation time
  46287. */
  46288. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46289. /**
  46290. * Gets the active meshes evaluation time capture status
  46291. */
  46292. /**
  46293. * Enable or disable the active meshes evaluation time capture
  46294. */
  46295. captureActiveMeshesEvaluationTime: boolean;
  46296. /**
  46297. * Gets the perf counter used for render targets render time
  46298. */
  46299. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46300. /**
  46301. * Gets the render targets render time capture status
  46302. */
  46303. /**
  46304. * Enable or disable the render targets render time capture
  46305. */
  46306. captureRenderTargetsRenderTime: boolean;
  46307. /**
  46308. * Gets the perf counter used for particles render time
  46309. */
  46310. readonly particlesRenderTimeCounter: PerfCounter;
  46311. /**
  46312. * Gets the particles render time capture status
  46313. */
  46314. /**
  46315. * Enable or disable the particles render time capture
  46316. */
  46317. captureParticlesRenderTime: boolean;
  46318. /**
  46319. * Gets the perf counter used for sprites render time
  46320. */
  46321. readonly spritesRenderTimeCounter: PerfCounter;
  46322. /**
  46323. * Gets the sprites render time capture status
  46324. */
  46325. /**
  46326. * Enable or disable the sprites render time capture
  46327. */
  46328. captureSpritesRenderTime: boolean;
  46329. /**
  46330. * Gets the perf counter used for physics time
  46331. */
  46332. readonly physicsTimeCounter: PerfCounter;
  46333. /**
  46334. * Gets the physics time capture status
  46335. */
  46336. /**
  46337. * Enable or disable the physics time capture
  46338. */
  46339. capturePhysicsTime: boolean;
  46340. /**
  46341. * Gets the perf counter used for animations time
  46342. */
  46343. readonly animationsTimeCounter: PerfCounter;
  46344. /**
  46345. * Gets the animations time capture status
  46346. */
  46347. /**
  46348. * Enable or disable the animations time capture
  46349. */
  46350. captureAnimationsTime: boolean;
  46351. /**
  46352. * Gets the perf counter used for frame time capture
  46353. */
  46354. readonly frameTimeCounter: PerfCounter;
  46355. /**
  46356. * Gets the frame time capture status
  46357. */
  46358. /**
  46359. * Enable or disable the frame time capture
  46360. */
  46361. captureFrameTime: boolean;
  46362. /**
  46363. * Gets the perf counter used for inter-frames time capture
  46364. */
  46365. readonly interFrameTimeCounter: PerfCounter;
  46366. /**
  46367. * Gets the inter-frames time capture status
  46368. */
  46369. /**
  46370. * Enable or disable the inter-frames time capture
  46371. */
  46372. captureInterFrameTime: boolean;
  46373. /**
  46374. * Gets the perf counter used for render time capture
  46375. */
  46376. readonly renderTimeCounter: PerfCounter;
  46377. /**
  46378. * Gets the render time capture status
  46379. */
  46380. /**
  46381. * Enable or disable the render time capture
  46382. */
  46383. captureRenderTime: boolean;
  46384. /**
  46385. * Gets the perf counter used for camera render time capture
  46386. */
  46387. readonly cameraRenderTimeCounter: PerfCounter;
  46388. /**
  46389. * Gets the camera render time capture status
  46390. */
  46391. /**
  46392. * Enable or disable the camera render time capture
  46393. */
  46394. captureCameraRenderTime: boolean;
  46395. /**
  46396. * Gets the perf counter used for draw calls
  46397. */
  46398. readonly drawCallsCounter: PerfCounter;
  46399. /**
  46400. * Instantiates a new scene instrumentation.
  46401. * This class can be used to get instrumentation data from a Babylon engine
  46402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46403. * @param scene Defines the scene to instrument
  46404. */
  46405. constructor(
  46406. /**
  46407. * Defines the scene to instrument
  46408. */
  46409. scene: Scene);
  46410. /**
  46411. * Dispose and release associated resources.
  46412. */
  46413. dispose(): void;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /** @hidden */
  46418. export var glowMapGenerationPixelShader: {
  46419. name: string;
  46420. shader: string;
  46421. };
  46422. }
  46423. declare module BABYLON {
  46424. /** @hidden */
  46425. export var glowMapGenerationVertexShader: {
  46426. name: string;
  46427. shader: string;
  46428. };
  46429. }
  46430. declare module BABYLON {
  46431. /**
  46432. * Effect layer options. This helps customizing the behaviour
  46433. * of the effect layer.
  46434. */
  46435. export interface IEffectLayerOptions {
  46436. /**
  46437. * Multiplication factor apply to the canvas size to compute the render target size
  46438. * used to generated the objects (the smaller the faster).
  46439. */
  46440. mainTextureRatio: number;
  46441. /**
  46442. * Enforces a fixed size texture to ensure effect stability across devices.
  46443. */
  46444. mainTextureFixedSize?: number;
  46445. /**
  46446. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46447. */
  46448. alphaBlendingMode: number;
  46449. /**
  46450. * The camera attached to the layer.
  46451. */
  46452. camera: Nullable<Camera>;
  46453. /**
  46454. * The rendering group to draw the layer in.
  46455. */
  46456. renderingGroupId: number;
  46457. }
  46458. /**
  46459. * The effect layer Helps adding post process effect blended with the main pass.
  46460. *
  46461. * This can be for instance use to generate glow or higlight effects on the scene.
  46462. *
  46463. * The effect layer class can not be used directly and is intented to inherited from to be
  46464. * customized per effects.
  46465. */
  46466. export abstract class EffectLayer {
  46467. private _vertexBuffers;
  46468. private _indexBuffer;
  46469. private _cachedDefines;
  46470. private _effectLayerMapGenerationEffect;
  46471. private _effectLayerOptions;
  46472. private _mergeEffect;
  46473. protected _scene: Scene;
  46474. protected _engine: Engine;
  46475. protected _maxSize: number;
  46476. protected _mainTextureDesiredSize: ISize;
  46477. protected _mainTexture: RenderTargetTexture;
  46478. protected _shouldRender: boolean;
  46479. protected _postProcesses: PostProcess[];
  46480. protected _textures: BaseTexture[];
  46481. protected _emissiveTextureAndColor: {
  46482. texture: Nullable<BaseTexture>;
  46483. color: Color4;
  46484. };
  46485. /**
  46486. * The name of the layer
  46487. */
  46488. name: string;
  46489. /**
  46490. * The clear color of the texture used to generate the glow map.
  46491. */
  46492. neutralColor: Color4;
  46493. /**
  46494. * Specifies wether the highlight layer is enabled or not.
  46495. */
  46496. isEnabled: boolean;
  46497. /**
  46498. * Gets the camera attached to the layer.
  46499. */
  46500. readonly camera: Nullable<Camera>;
  46501. /**
  46502. * Gets the rendering group id the layer should render in.
  46503. */
  46504. readonly renderingGroupId: number;
  46505. /**
  46506. * An event triggered when the effect layer has been disposed.
  46507. */
  46508. onDisposeObservable: Observable<EffectLayer>;
  46509. /**
  46510. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46511. */
  46512. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46513. /**
  46514. * An event triggered when the generated texture is being merged in the scene.
  46515. */
  46516. onBeforeComposeObservable: Observable<EffectLayer>;
  46517. /**
  46518. * An event triggered when the generated texture has been merged in the scene.
  46519. */
  46520. onAfterComposeObservable: Observable<EffectLayer>;
  46521. /**
  46522. * An event triggered when the efffect layer changes its size.
  46523. */
  46524. onSizeChangedObservable: Observable<EffectLayer>;
  46525. /** @hidden */
  46526. static _SceneComponentInitialization: (scene: Scene) => void;
  46527. /**
  46528. * Instantiates a new effect Layer and references it in the scene.
  46529. * @param name The name of the layer
  46530. * @param scene The scene to use the layer in
  46531. */
  46532. constructor(
  46533. /** The Friendly of the effect in the scene */
  46534. name: string, scene: Scene);
  46535. /**
  46536. * Get the effect name of the layer.
  46537. * @return The effect name
  46538. */
  46539. abstract getEffectName(): string;
  46540. /**
  46541. * Checks for the readiness of the element composing the layer.
  46542. * @param subMesh the mesh to check for
  46543. * @param useInstances specify wether or not to use instances to render the mesh
  46544. * @return true if ready otherwise, false
  46545. */
  46546. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46547. /**
  46548. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46549. * @returns true if the effect requires stencil during the main canvas render pass.
  46550. */
  46551. abstract needStencil(): boolean;
  46552. /**
  46553. * Create the merge effect. This is the shader use to blit the information back
  46554. * to the main canvas at the end of the scene rendering.
  46555. * @returns The effect containing the shader used to merge the effect on the main canvas
  46556. */
  46557. protected abstract _createMergeEffect(): Effect;
  46558. /**
  46559. * Creates the render target textures and post processes used in the effect layer.
  46560. */
  46561. protected abstract _createTextureAndPostProcesses(): void;
  46562. /**
  46563. * Implementation specific of rendering the generating effect on the main canvas.
  46564. * @param effect The effect used to render through
  46565. */
  46566. protected abstract _internalRender(effect: Effect): void;
  46567. /**
  46568. * Sets the required values for both the emissive texture and and the main color.
  46569. */
  46570. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46571. /**
  46572. * Free any resources and references associated to a mesh.
  46573. * Internal use
  46574. * @param mesh The mesh to free.
  46575. */
  46576. abstract _disposeMesh(mesh: Mesh): void;
  46577. /**
  46578. * Serializes this layer (Glow or Highlight for example)
  46579. * @returns a serialized layer object
  46580. */
  46581. abstract serialize?(): any;
  46582. /**
  46583. * Initializes the effect layer with the required options.
  46584. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46585. */
  46586. protected _init(options: Partial<IEffectLayerOptions>): void;
  46587. /**
  46588. * Generates the index buffer of the full screen quad blending to the main canvas.
  46589. */
  46590. private _generateIndexBuffer;
  46591. /**
  46592. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46593. */
  46594. private _genrateVertexBuffer;
  46595. /**
  46596. * Sets the main texture desired size which is the closest power of two
  46597. * of the engine canvas size.
  46598. */
  46599. private _setMainTextureSize;
  46600. /**
  46601. * Creates the main texture for the effect layer.
  46602. */
  46603. protected _createMainTexture(): void;
  46604. /**
  46605. * Adds specific effects defines.
  46606. * @param defines The defines to add specifics to.
  46607. */
  46608. protected _addCustomEffectDefines(defines: string[]): void;
  46609. /**
  46610. * Checks for the readiness of the element composing the layer.
  46611. * @param subMesh the mesh to check for
  46612. * @param useInstances specify wether or not to use instances to render the mesh
  46613. * @param emissiveTexture the associated emissive texture used to generate the glow
  46614. * @return true if ready otherwise, false
  46615. */
  46616. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46617. /**
  46618. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46619. */
  46620. render(): void;
  46621. /**
  46622. * Determine if a given mesh will be used in the current effect.
  46623. * @param mesh mesh to test
  46624. * @returns true if the mesh will be used
  46625. */
  46626. hasMesh(mesh: AbstractMesh): boolean;
  46627. /**
  46628. * Returns true if the layer contains information to display, otherwise false.
  46629. * @returns true if the glow layer should be rendered
  46630. */
  46631. shouldRender(): boolean;
  46632. /**
  46633. * Returns true if the mesh should render, otherwise false.
  46634. * @param mesh The mesh to render
  46635. * @returns true if it should render otherwise false
  46636. */
  46637. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46638. /**
  46639. * Returns true if the mesh can be rendered, otherwise false.
  46640. * @param mesh The mesh to render
  46641. * @param material The material used on the mesh
  46642. * @returns true if it can be rendered otherwise false
  46643. */
  46644. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46645. /**
  46646. * Returns true if the mesh should render, otherwise false.
  46647. * @param mesh The mesh to render
  46648. * @returns true if it should render otherwise false
  46649. */
  46650. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46651. /**
  46652. * Renders the submesh passed in parameter to the generation map.
  46653. */
  46654. protected _renderSubMesh(subMesh: SubMesh): void;
  46655. /**
  46656. * Rebuild the required buffers.
  46657. * @hidden Internal use only.
  46658. */
  46659. _rebuild(): void;
  46660. /**
  46661. * Dispose only the render target textures and post process.
  46662. */
  46663. private _disposeTextureAndPostProcesses;
  46664. /**
  46665. * Dispose the highlight layer and free resources.
  46666. */
  46667. dispose(): void;
  46668. /**
  46669. * Gets the class name of the effect layer
  46670. * @returns the string with the class name of the effect layer
  46671. */
  46672. getClassName(): string;
  46673. /**
  46674. * Creates an effect layer from parsed effect layer data
  46675. * @param parsedEffectLayer defines effect layer data
  46676. * @param scene defines the current scene
  46677. * @param rootUrl defines the root URL containing the effect layer information
  46678. * @returns a parsed effect Layer
  46679. */
  46680. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46681. }
  46682. }
  46683. declare module BABYLON {
  46684. interface AbstractScene {
  46685. /**
  46686. * The list of effect layers (highlights/glow) added to the scene
  46687. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46688. * @see http://doc.babylonjs.com/how_to/glow_layer
  46689. */
  46690. effectLayers: Array<EffectLayer>;
  46691. /**
  46692. * Removes the given effect layer from this scene.
  46693. * @param toRemove defines the effect layer to remove
  46694. * @returns the index of the removed effect layer
  46695. */
  46696. removeEffectLayer(toRemove: EffectLayer): number;
  46697. /**
  46698. * Adds the given effect layer to this scene
  46699. * @param newEffectLayer defines the effect layer to add
  46700. */
  46701. addEffectLayer(newEffectLayer: EffectLayer): void;
  46702. }
  46703. /**
  46704. * Defines the layer scene component responsible to manage any effect layers
  46705. * in a given scene.
  46706. */
  46707. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46708. /**
  46709. * The component name helpfull to identify the component in the list of scene components.
  46710. */
  46711. readonly name: string;
  46712. /**
  46713. * The scene the component belongs to.
  46714. */
  46715. scene: Scene;
  46716. private _engine;
  46717. private _renderEffects;
  46718. private _needStencil;
  46719. private _previousStencilState;
  46720. /**
  46721. * Creates a new instance of the component for the given scene
  46722. * @param scene Defines the scene to register the component in
  46723. */
  46724. constructor(scene: Scene);
  46725. /**
  46726. * Registers the component in a given scene
  46727. */
  46728. register(): void;
  46729. /**
  46730. * Rebuilds the elements related to this component in case of
  46731. * context lost for instance.
  46732. */
  46733. rebuild(): void;
  46734. /**
  46735. * Serializes the component data to the specified json object
  46736. * @param serializationObject The object to serialize to
  46737. */
  46738. serialize(serializationObject: any): void;
  46739. /**
  46740. * Adds all the element from the container to the scene
  46741. * @param container the container holding the elements
  46742. */
  46743. addFromContainer(container: AbstractScene): void;
  46744. /**
  46745. * Removes all the elements in the container from the scene
  46746. * @param container contains the elements to remove
  46747. * @param dispose if the removed element should be disposed (default: false)
  46748. */
  46749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46750. /**
  46751. * Disposes the component and the associated ressources.
  46752. */
  46753. dispose(): void;
  46754. private _isReadyForMesh;
  46755. private _renderMainTexture;
  46756. private _setStencil;
  46757. private _setStencilBack;
  46758. private _draw;
  46759. private _drawCamera;
  46760. private _drawRenderingGroup;
  46761. }
  46762. }
  46763. declare module BABYLON {
  46764. /** @hidden */
  46765. export var glowMapMergePixelShader: {
  46766. name: string;
  46767. shader: string;
  46768. };
  46769. }
  46770. declare module BABYLON {
  46771. /** @hidden */
  46772. export var glowMapMergeVertexShader: {
  46773. name: string;
  46774. shader: string;
  46775. };
  46776. }
  46777. declare module BABYLON {
  46778. interface AbstractScene {
  46779. /**
  46780. * Return a the first highlight layer of the scene with a given name.
  46781. * @param name The name of the highlight layer to look for.
  46782. * @return The highlight layer if found otherwise null.
  46783. */
  46784. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46785. }
  46786. /**
  46787. * Glow layer options. This helps customizing the behaviour
  46788. * of the glow layer.
  46789. */
  46790. export interface IGlowLayerOptions {
  46791. /**
  46792. * Multiplication factor apply to the canvas size to compute the render target size
  46793. * used to generated the glowing objects (the smaller the faster).
  46794. */
  46795. mainTextureRatio: number;
  46796. /**
  46797. * Enforces a fixed size texture to ensure resize independant blur.
  46798. */
  46799. mainTextureFixedSize?: number;
  46800. /**
  46801. * How big is the kernel of the blur texture.
  46802. */
  46803. blurKernelSize: number;
  46804. /**
  46805. * The camera attached to the layer.
  46806. */
  46807. camera: Nullable<Camera>;
  46808. /**
  46809. * Enable MSAA by chosing the number of samples.
  46810. */
  46811. mainTextureSamples?: number;
  46812. /**
  46813. * The rendering group to draw the layer in.
  46814. */
  46815. renderingGroupId: number;
  46816. }
  46817. /**
  46818. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46819. *
  46820. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46821. * glowy meshes to your scene.
  46822. *
  46823. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46824. */
  46825. export class GlowLayer extends EffectLayer {
  46826. /**
  46827. * Effect Name of the layer.
  46828. */
  46829. static readonly EffectName: string;
  46830. /**
  46831. * The default blur kernel size used for the glow.
  46832. */
  46833. static DefaultBlurKernelSize: number;
  46834. /**
  46835. * The default texture size ratio used for the glow.
  46836. */
  46837. static DefaultTextureRatio: number;
  46838. /**
  46839. * Sets the kernel size of the blur.
  46840. */
  46841. /**
  46842. * Gets the kernel size of the blur.
  46843. */
  46844. blurKernelSize: number;
  46845. /**
  46846. * Sets the glow intensity.
  46847. */
  46848. /**
  46849. * Gets the glow intensity.
  46850. */
  46851. intensity: number;
  46852. private _options;
  46853. private _intensity;
  46854. private _horizontalBlurPostprocess1;
  46855. private _verticalBlurPostprocess1;
  46856. private _horizontalBlurPostprocess2;
  46857. private _verticalBlurPostprocess2;
  46858. private _blurTexture1;
  46859. private _blurTexture2;
  46860. private _postProcesses1;
  46861. private _postProcesses2;
  46862. private _includedOnlyMeshes;
  46863. private _excludedMeshes;
  46864. /**
  46865. * Callback used to let the user override the color selection on a per mesh basis
  46866. */
  46867. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46868. /**
  46869. * Callback used to let the user override the texture selection on a per mesh basis
  46870. */
  46871. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46872. /**
  46873. * Instantiates a new glow Layer and references it to the scene.
  46874. * @param name The name of the layer
  46875. * @param scene The scene to use the layer in
  46876. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46877. */
  46878. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46879. /**
  46880. * Get the effect name of the layer.
  46881. * @return The effect name
  46882. */
  46883. getEffectName(): string;
  46884. /**
  46885. * Create the merge effect. This is the shader use to blit the information back
  46886. * to the main canvas at the end of the scene rendering.
  46887. */
  46888. protected _createMergeEffect(): Effect;
  46889. /**
  46890. * Creates the render target textures and post processes used in the glow layer.
  46891. */
  46892. protected _createTextureAndPostProcesses(): void;
  46893. /**
  46894. * Checks for the readiness of the element composing the layer.
  46895. * @param subMesh the mesh to check for
  46896. * @param useInstances specify wether or not to use instances to render the mesh
  46897. * @param emissiveTexture the associated emissive texture used to generate the glow
  46898. * @return true if ready otherwise, false
  46899. */
  46900. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46901. /**
  46902. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46903. */
  46904. needStencil(): boolean;
  46905. /**
  46906. * Returns true if the mesh can be rendered, otherwise false.
  46907. * @param mesh The mesh to render
  46908. * @param material The material used on the mesh
  46909. * @returns true if it can be rendered otherwise false
  46910. */
  46911. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46912. /**
  46913. * Implementation specific of rendering the generating effect on the main canvas.
  46914. * @param effect The effect used to render through
  46915. */
  46916. protected _internalRender(effect: Effect): void;
  46917. /**
  46918. * Sets the required values for both the emissive texture and and the main color.
  46919. */
  46920. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46921. /**
  46922. * Returns true if the mesh should render, otherwise false.
  46923. * @param mesh The mesh to render
  46924. * @returns true if it should render otherwise false
  46925. */
  46926. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46927. /**
  46928. * Adds specific effects defines.
  46929. * @param defines The defines to add specifics to.
  46930. */
  46931. protected _addCustomEffectDefines(defines: string[]): void;
  46932. /**
  46933. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46934. * @param mesh The mesh to exclude from the glow layer
  46935. */
  46936. addExcludedMesh(mesh: Mesh): void;
  46937. /**
  46938. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46939. * @param mesh The mesh to remove
  46940. */
  46941. removeExcludedMesh(mesh: Mesh): void;
  46942. /**
  46943. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46944. * @param mesh The mesh to include in the glow layer
  46945. */
  46946. addIncludedOnlyMesh(mesh: Mesh): void;
  46947. /**
  46948. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46949. * @param mesh The mesh to remove
  46950. */
  46951. removeIncludedOnlyMesh(mesh: Mesh): void;
  46952. /**
  46953. * Determine if a given mesh will be used in the glow layer
  46954. * @param mesh The mesh to test
  46955. * @returns true if the mesh will be highlighted by the current glow layer
  46956. */
  46957. hasMesh(mesh: AbstractMesh): boolean;
  46958. /**
  46959. * Free any resources and references associated to a mesh.
  46960. * Internal use
  46961. * @param mesh The mesh to free.
  46962. * @hidden
  46963. */
  46964. _disposeMesh(mesh: Mesh): void;
  46965. /**
  46966. * Gets the class name of the effect layer
  46967. * @returns the string with the class name of the effect layer
  46968. */
  46969. getClassName(): string;
  46970. /**
  46971. * Serializes this glow layer
  46972. * @returns a serialized glow layer object
  46973. */
  46974. serialize(): any;
  46975. /**
  46976. * Creates a Glow Layer from parsed glow layer data
  46977. * @param parsedGlowLayer defines glow layer data
  46978. * @param scene defines the current scene
  46979. * @param rootUrl defines the root URL containing the glow layer information
  46980. * @returns a parsed Glow Layer
  46981. */
  46982. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46983. }
  46984. }
  46985. declare module BABYLON {
  46986. /** @hidden */
  46987. export var glowBlurPostProcessPixelShader: {
  46988. name: string;
  46989. shader: string;
  46990. };
  46991. }
  46992. declare module BABYLON {
  46993. interface AbstractScene {
  46994. /**
  46995. * Return a the first highlight layer of the scene with a given name.
  46996. * @param name The name of the highlight layer to look for.
  46997. * @return The highlight layer if found otherwise null.
  46998. */
  46999. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47000. }
  47001. /**
  47002. * Highlight layer options. This helps customizing the behaviour
  47003. * of the highlight layer.
  47004. */
  47005. export interface IHighlightLayerOptions {
  47006. /**
  47007. * Multiplication factor apply to the canvas size to compute the render target size
  47008. * used to generated the glowing objects (the smaller the faster).
  47009. */
  47010. mainTextureRatio: number;
  47011. /**
  47012. * Enforces a fixed size texture to ensure resize independant blur.
  47013. */
  47014. mainTextureFixedSize?: number;
  47015. /**
  47016. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47017. * of the picture to blur (the smaller the faster).
  47018. */
  47019. blurTextureSizeRatio: number;
  47020. /**
  47021. * How big in texel of the blur texture is the vertical blur.
  47022. */
  47023. blurVerticalSize: number;
  47024. /**
  47025. * How big in texel of the blur texture is the horizontal blur.
  47026. */
  47027. blurHorizontalSize: number;
  47028. /**
  47029. * Alpha blending mode used to apply the blur. Default is combine.
  47030. */
  47031. alphaBlendingMode: number;
  47032. /**
  47033. * The camera attached to the layer.
  47034. */
  47035. camera: Nullable<Camera>;
  47036. /**
  47037. * Should we display highlight as a solid stroke?
  47038. */
  47039. isStroke?: boolean;
  47040. /**
  47041. * The rendering group to draw the layer in.
  47042. */
  47043. renderingGroupId: number;
  47044. }
  47045. /**
  47046. * The highlight layer Helps adding a glow effect around a mesh.
  47047. *
  47048. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47049. * glowy meshes to your scene.
  47050. *
  47051. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47052. */
  47053. export class HighlightLayer extends EffectLayer {
  47054. name: string;
  47055. /**
  47056. * Effect Name of the highlight layer.
  47057. */
  47058. static readonly EffectName: string;
  47059. /**
  47060. * The neutral color used during the preparation of the glow effect.
  47061. * This is black by default as the blend operation is a blend operation.
  47062. */
  47063. static NeutralColor: Color4;
  47064. /**
  47065. * Stencil value used for glowing meshes.
  47066. */
  47067. static GlowingMeshStencilReference: number;
  47068. /**
  47069. * Stencil value used for the other meshes in the scene.
  47070. */
  47071. static NormalMeshStencilReference: number;
  47072. /**
  47073. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47074. */
  47075. innerGlow: boolean;
  47076. /**
  47077. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47078. */
  47079. outerGlow: boolean;
  47080. /**
  47081. * Specifies the horizontal size of the blur.
  47082. */
  47083. /**
  47084. * Gets the horizontal size of the blur.
  47085. */
  47086. blurHorizontalSize: number;
  47087. /**
  47088. * Specifies the vertical size of the blur.
  47089. */
  47090. /**
  47091. * Gets the vertical size of the blur.
  47092. */
  47093. blurVerticalSize: number;
  47094. /**
  47095. * An event triggered when the highlight layer is being blurred.
  47096. */
  47097. onBeforeBlurObservable: Observable<HighlightLayer>;
  47098. /**
  47099. * An event triggered when the highlight layer has been blurred.
  47100. */
  47101. onAfterBlurObservable: Observable<HighlightLayer>;
  47102. private _instanceGlowingMeshStencilReference;
  47103. private _options;
  47104. private _downSamplePostprocess;
  47105. private _horizontalBlurPostprocess;
  47106. private _verticalBlurPostprocess;
  47107. private _blurTexture;
  47108. private _meshes;
  47109. private _excludedMeshes;
  47110. /**
  47111. * Instantiates a new highlight Layer and references it to the scene..
  47112. * @param name The name of the layer
  47113. * @param scene The scene to use the layer in
  47114. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47115. */
  47116. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47117. /**
  47118. * Get the effect name of the layer.
  47119. * @return The effect name
  47120. */
  47121. getEffectName(): string;
  47122. /**
  47123. * Create the merge effect. This is the shader use to blit the information back
  47124. * to the main canvas at the end of the scene rendering.
  47125. */
  47126. protected _createMergeEffect(): Effect;
  47127. /**
  47128. * Creates the render target textures and post processes used in the highlight layer.
  47129. */
  47130. protected _createTextureAndPostProcesses(): void;
  47131. /**
  47132. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47133. */
  47134. needStencil(): boolean;
  47135. /**
  47136. * Checks for the readiness of the element composing the layer.
  47137. * @param subMesh the mesh to check for
  47138. * @param useInstances specify wether or not to use instances to render the mesh
  47139. * @param emissiveTexture the associated emissive texture used to generate the glow
  47140. * @return true if ready otherwise, false
  47141. */
  47142. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47143. /**
  47144. * Implementation specific of rendering the generating effect on the main canvas.
  47145. * @param effect The effect used to render through
  47146. */
  47147. protected _internalRender(effect: Effect): void;
  47148. /**
  47149. * Returns true if the layer contains information to display, otherwise false.
  47150. */
  47151. shouldRender(): boolean;
  47152. /**
  47153. * Returns true if the mesh should render, otherwise false.
  47154. * @param mesh The mesh to render
  47155. * @returns true if it should render otherwise false
  47156. */
  47157. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47158. /**
  47159. * Sets the required values for both the emissive texture and and the main color.
  47160. */
  47161. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47162. /**
  47163. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47164. * @param mesh The mesh to exclude from the highlight layer
  47165. */
  47166. addExcludedMesh(mesh: Mesh): void;
  47167. /**
  47168. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47169. * @param mesh The mesh to highlight
  47170. */
  47171. removeExcludedMesh(mesh: Mesh): void;
  47172. /**
  47173. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47174. * @param mesh mesh to test
  47175. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47176. */
  47177. hasMesh(mesh: AbstractMesh): boolean;
  47178. /**
  47179. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47180. * @param mesh The mesh to highlight
  47181. * @param color The color of the highlight
  47182. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47183. */
  47184. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47185. /**
  47186. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47187. * @param mesh The mesh to highlight
  47188. */
  47189. removeMesh(mesh: Mesh): void;
  47190. /**
  47191. * Force the stencil to the normal expected value for none glowing parts
  47192. */
  47193. private _defaultStencilReference;
  47194. /**
  47195. * Free any resources and references associated to a mesh.
  47196. * Internal use
  47197. * @param mesh The mesh to free.
  47198. * @hidden
  47199. */
  47200. _disposeMesh(mesh: Mesh): void;
  47201. /**
  47202. * Dispose the highlight layer and free resources.
  47203. */
  47204. dispose(): void;
  47205. /**
  47206. * Gets the class name of the effect layer
  47207. * @returns the string with the class name of the effect layer
  47208. */
  47209. getClassName(): string;
  47210. /**
  47211. * Serializes this Highlight layer
  47212. * @returns a serialized Highlight layer object
  47213. */
  47214. serialize(): any;
  47215. /**
  47216. * Creates a Highlight layer from parsed Highlight layer data
  47217. * @param parsedHightlightLayer defines the Highlight layer data
  47218. * @param scene defines the current scene
  47219. * @param rootUrl defines the root URL containing the Highlight layer information
  47220. * @returns a parsed Highlight layer
  47221. */
  47222. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47223. }
  47224. }
  47225. declare module BABYLON {
  47226. /** @hidden */
  47227. export var lensFlarePixelShader: {
  47228. name: string;
  47229. shader: string;
  47230. };
  47231. }
  47232. declare module BABYLON {
  47233. /** @hidden */
  47234. export var lensFlareVertexShader: {
  47235. name: string;
  47236. shader: string;
  47237. };
  47238. }
  47239. declare module BABYLON {
  47240. /**
  47241. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47242. * It is usually composed of several `lensFlare`.
  47243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47244. */
  47245. export class LensFlareSystem {
  47246. /**
  47247. * Define the name of the lens flare system
  47248. */
  47249. name: string;
  47250. /**
  47251. * List of lens flares used in this system.
  47252. */
  47253. lensFlares: LensFlare[];
  47254. /**
  47255. * Define a limit from the border the lens flare can be visible.
  47256. */
  47257. borderLimit: number;
  47258. /**
  47259. * Define a viewport border we do not want to see the lens flare in.
  47260. */
  47261. viewportBorder: number;
  47262. /**
  47263. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47264. */
  47265. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47266. /**
  47267. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47268. */
  47269. layerMask: number;
  47270. /**
  47271. * Define the id of the lens flare system in the scene.
  47272. * (equal to name by default)
  47273. */
  47274. id: string;
  47275. private _scene;
  47276. private _emitter;
  47277. private _vertexBuffers;
  47278. private _indexBuffer;
  47279. private _effect;
  47280. private _positionX;
  47281. private _positionY;
  47282. private _isEnabled;
  47283. /** @hidden */
  47284. static _SceneComponentInitialization: (scene: Scene) => void;
  47285. /**
  47286. * Instantiates a lens flare system.
  47287. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47288. * It is usually composed of several `lensFlare`.
  47289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47290. * @param name Define the name of the lens flare system in the scene
  47291. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47292. * @param scene Define the scene the lens flare system belongs to
  47293. */
  47294. constructor(
  47295. /**
  47296. * Define the name of the lens flare system
  47297. */
  47298. name: string, emitter: any, scene: Scene);
  47299. /**
  47300. * Define if the lens flare system is enabled.
  47301. */
  47302. isEnabled: boolean;
  47303. /**
  47304. * Get the scene the effects belongs to.
  47305. * @returns the scene holding the lens flare system
  47306. */
  47307. getScene(): Scene;
  47308. /**
  47309. * Get the emitter of the lens flare system.
  47310. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47311. * @returns the emitter of the lens flare system
  47312. */
  47313. getEmitter(): any;
  47314. /**
  47315. * Set the emitter of the lens flare system.
  47316. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47317. * @param newEmitter Define the new emitter of the system
  47318. */
  47319. setEmitter(newEmitter: any): void;
  47320. /**
  47321. * Get the lens flare system emitter position.
  47322. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47323. * @returns the position
  47324. */
  47325. getEmitterPosition(): Vector3;
  47326. /**
  47327. * @hidden
  47328. */
  47329. computeEffectivePosition(globalViewport: Viewport): boolean;
  47330. /** @hidden */
  47331. _isVisible(): boolean;
  47332. /**
  47333. * @hidden
  47334. */
  47335. render(): boolean;
  47336. /**
  47337. * Dispose and release the lens flare with its associated resources.
  47338. */
  47339. dispose(): void;
  47340. /**
  47341. * Parse a lens flare system from a JSON repressentation
  47342. * @param parsedLensFlareSystem Define the JSON to parse
  47343. * @param scene Define the scene the parsed system should be instantiated in
  47344. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47345. * @returns the parsed system
  47346. */
  47347. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47348. /**
  47349. * Serialize the current Lens Flare System into a JSON representation.
  47350. * @returns the serialized JSON
  47351. */
  47352. serialize(): any;
  47353. }
  47354. }
  47355. declare module BABYLON {
  47356. /**
  47357. * This represents one of the lens effect in a `lensFlareSystem`.
  47358. * It controls one of the indiviual texture used in the effect.
  47359. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47360. */
  47361. export class LensFlare {
  47362. /**
  47363. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47364. */
  47365. size: number;
  47366. /**
  47367. * 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.
  47368. */
  47369. position: number;
  47370. /**
  47371. * Define the lens color.
  47372. */
  47373. color: Color3;
  47374. /**
  47375. * Define the lens texture.
  47376. */
  47377. texture: Nullable<Texture>;
  47378. /**
  47379. * Define the alpha mode to render this particular lens.
  47380. */
  47381. alphaMode: number;
  47382. private _system;
  47383. /**
  47384. * Creates a new Lens Flare.
  47385. * This represents one of the lens effect in a `lensFlareSystem`.
  47386. * It controls one of the indiviual texture used in the effect.
  47387. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47388. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47389. * @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.
  47390. * @param color Define the lens color
  47391. * @param imgUrl Define the lens texture url
  47392. * @param system Define the `lensFlareSystem` this flare is part of
  47393. * @returns The newly created Lens Flare
  47394. */
  47395. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47396. /**
  47397. * Instantiates a new Lens Flare.
  47398. * This represents one of the lens effect in a `lensFlareSystem`.
  47399. * It controls one of the indiviual texture used in the effect.
  47400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47401. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47402. * @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.
  47403. * @param color Define the lens color
  47404. * @param imgUrl Define the lens texture url
  47405. * @param system Define the `lensFlareSystem` this flare is part of
  47406. */
  47407. constructor(
  47408. /**
  47409. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47410. */
  47411. size: number,
  47412. /**
  47413. * 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.
  47414. */
  47415. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47416. /**
  47417. * Dispose and release the lens flare with its associated resources.
  47418. */
  47419. dispose(): void;
  47420. }
  47421. }
  47422. declare module BABYLON {
  47423. interface AbstractScene {
  47424. /**
  47425. * The list of lens flare system added to the scene
  47426. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47427. */
  47428. lensFlareSystems: Array<LensFlareSystem>;
  47429. /**
  47430. * Removes the given lens flare system from this scene.
  47431. * @param toRemove The lens flare system to remove
  47432. * @returns The index of the removed lens flare system
  47433. */
  47434. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47435. /**
  47436. * Adds the given lens flare system to this scene
  47437. * @param newLensFlareSystem The lens flare system to add
  47438. */
  47439. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47440. /**
  47441. * Gets a lens flare system using its name
  47442. * @param name defines the name to look for
  47443. * @returns the lens flare system or null if not found
  47444. */
  47445. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47446. /**
  47447. * Gets a lens flare system using its id
  47448. * @param id defines the id to look for
  47449. * @returns the lens flare system or null if not found
  47450. */
  47451. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47452. }
  47453. /**
  47454. * Defines the lens flare scene component responsible to manage any lens flares
  47455. * in a given scene.
  47456. */
  47457. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47458. /**
  47459. * The component name helpfull to identify the component in the list of scene components.
  47460. */
  47461. readonly name: string;
  47462. /**
  47463. * The scene the component belongs to.
  47464. */
  47465. scene: Scene;
  47466. /**
  47467. * Creates a new instance of the component for the given scene
  47468. * @param scene Defines the scene to register the component in
  47469. */
  47470. constructor(scene: Scene);
  47471. /**
  47472. * Registers the component in a given scene
  47473. */
  47474. register(): void;
  47475. /**
  47476. * Rebuilds the elements related to this component in case of
  47477. * context lost for instance.
  47478. */
  47479. rebuild(): void;
  47480. /**
  47481. * Adds all the element from the container to the scene
  47482. * @param container the container holding the elements
  47483. */
  47484. addFromContainer(container: AbstractScene): void;
  47485. /**
  47486. * Removes all the elements in the container from the scene
  47487. * @param container contains the elements to remove
  47488. * @param dispose if the removed element should be disposed (default: false)
  47489. */
  47490. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47491. /**
  47492. * Serializes the component data to the specified json object
  47493. * @param serializationObject The object to serialize to
  47494. */
  47495. serialize(serializationObject: any): void;
  47496. /**
  47497. * Disposes the component and the associated ressources.
  47498. */
  47499. dispose(): void;
  47500. private _draw;
  47501. }
  47502. }
  47503. declare module BABYLON {
  47504. /**
  47505. * Defines the shadow generator component responsible to manage any shadow generators
  47506. * in a given scene.
  47507. */
  47508. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47509. /**
  47510. * The component name helpfull to identify the component in the list of scene components.
  47511. */
  47512. readonly name: string;
  47513. /**
  47514. * The scene the component belongs to.
  47515. */
  47516. scene: Scene;
  47517. /**
  47518. * Creates a new instance of the component for the given scene
  47519. * @param scene Defines the scene to register the component in
  47520. */
  47521. constructor(scene: Scene);
  47522. /**
  47523. * Registers the component in a given scene
  47524. */
  47525. register(): void;
  47526. /**
  47527. * Rebuilds the elements related to this component in case of
  47528. * context lost for instance.
  47529. */
  47530. rebuild(): void;
  47531. /**
  47532. * Serializes the component data to the specified json object
  47533. * @param serializationObject The object to serialize to
  47534. */
  47535. serialize(serializationObject: any): void;
  47536. /**
  47537. * Adds all the element from the container to the scene
  47538. * @param container the container holding the elements
  47539. */
  47540. addFromContainer(container: AbstractScene): void;
  47541. /**
  47542. * Removes all the elements in the container from the scene
  47543. * @param container contains the elements to remove
  47544. * @param dispose if the removed element should be disposed (default: false)
  47545. */
  47546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47547. /**
  47548. * Rebuilds the elements related to this component in case of
  47549. * context lost for instance.
  47550. */
  47551. dispose(): void;
  47552. private _gatherRenderTargets;
  47553. }
  47554. }
  47555. declare module BABYLON {
  47556. /**
  47557. * A point light is a light defined by an unique point in world space.
  47558. * The light is emitted in every direction from this point.
  47559. * A good example of a point light is a standard light bulb.
  47560. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47561. */
  47562. export class PointLight extends ShadowLight {
  47563. private _shadowAngle;
  47564. /**
  47565. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47566. * This specifies what angle the shadow will use to be created.
  47567. *
  47568. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47569. */
  47570. /**
  47571. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47572. * This specifies what angle the shadow will use to be created.
  47573. *
  47574. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47575. */
  47576. shadowAngle: number;
  47577. /**
  47578. * Gets the direction if it has been set.
  47579. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47580. */
  47581. /**
  47582. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47583. */
  47584. direction: Vector3;
  47585. /**
  47586. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47587. * A PointLight emits the light in every direction.
  47588. * It can cast shadows.
  47589. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47590. * ```javascript
  47591. * var pointLight = new PointLight("pl", camera.position, scene);
  47592. * ```
  47593. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47594. * @param name The light friendly name
  47595. * @param position The position of the point light in the scene
  47596. * @param scene The scene the lights belongs to
  47597. */
  47598. constructor(name: string, position: Vector3, scene: Scene);
  47599. /**
  47600. * Returns the string "PointLight"
  47601. * @returns the class name
  47602. */
  47603. getClassName(): string;
  47604. /**
  47605. * Returns the integer 0.
  47606. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47607. */
  47608. getTypeID(): number;
  47609. /**
  47610. * Specifies wether or not the shadowmap should be a cube texture.
  47611. * @returns true if the shadowmap needs to be a cube texture.
  47612. */
  47613. needCube(): boolean;
  47614. /**
  47615. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47616. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47617. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47618. */
  47619. getShadowDirection(faceIndex?: number): Vector3;
  47620. /**
  47621. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47622. * - fov = PI / 2
  47623. * - aspect ratio : 1.0
  47624. * - z-near and far equal to the active camera minZ and maxZ.
  47625. * Returns the PointLight.
  47626. */
  47627. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47628. protected _buildUniformLayout(): void;
  47629. /**
  47630. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47631. * @param effect The effect to update
  47632. * @param lightIndex The index of the light in the effect to update
  47633. * @returns The point light
  47634. */
  47635. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47636. /**
  47637. * Prepares the list of defines specific to the light type.
  47638. * @param defines the list of defines
  47639. * @param lightIndex defines the index of the light for the effect
  47640. */
  47641. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47642. }
  47643. }
  47644. declare module BABYLON {
  47645. /**
  47646. * Header information of HDR texture files.
  47647. */
  47648. export interface HDRInfo {
  47649. /**
  47650. * The height of the texture in pixels.
  47651. */
  47652. height: number;
  47653. /**
  47654. * The width of the texture in pixels.
  47655. */
  47656. width: number;
  47657. /**
  47658. * The index of the beginning of the data in the binary file.
  47659. */
  47660. dataPosition: number;
  47661. }
  47662. /**
  47663. * This groups tools to convert HDR texture to native colors array.
  47664. */
  47665. export class HDRTools {
  47666. private static Ldexp;
  47667. private static Rgbe2float;
  47668. private static readStringLine;
  47669. /**
  47670. * Reads header information from an RGBE texture stored in a native array.
  47671. * More information on this format are available here:
  47672. * https://en.wikipedia.org/wiki/RGBE_image_format
  47673. *
  47674. * @param uint8array The binary file stored in native array.
  47675. * @return The header information.
  47676. */
  47677. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47678. /**
  47679. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47680. * This RGBE texture needs to store the information as a panorama.
  47681. *
  47682. * More information on this format are available here:
  47683. * https://en.wikipedia.org/wiki/RGBE_image_format
  47684. *
  47685. * @param buffer The binary file stored in an array buffer.
  47686. * @param size The expected size of the extracted cubemap.
  47687. * @return The Cube Map information.
  47688. */
  47689. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47690. /**
  47691. * Returns the pixels data extracted from an RGBE texture.
  47692. * This pixels will be stored left to right up to down in the R G B order in one array.
  47693. *
  47694. * More information on this format are available here:
  47695. * https://en.wikipedia.org/wiki/RGBE_image_format
  47696. *
  47697. * @param uint8array The binary file stored in an array buffer.
  47698. * @param hdrInfo The header information of the file.
  47699. * @return The pixels data in RGB right to left up to down order.
  47700. */
  47701. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47702. private static RGBE_ReadPixels_RLE;
  47703. }
  47704. }
  47705. declare module BABYLON {
  47706. /**
  47707. * This represents a texture coming from an HDR input.
  47708. *
  47709. * The only supported format is currently panorama picture stored in RGBE format.
  47710. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47711. */
  47712. export class HDRCubeTexture extends BaseTexture {
  47713. private static _facesMapping;
  47714. private _generateHarmonics;
  47715. private _noMipmap;
  47716. private _textureMatrix;
  47717. private _size;
  47718. private _onLoad;
  47719. private _onError;
  47720. /**
  47721. * The texture URL.
  47722. */
  47723. url: string;
  47724. /**
  47725. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47726. */
  47727. coordinatesMode: number;
  47728. protected _isBlocking: boolean;
  47729. /**
  47730. * Sets wether or not the texture is blocking during loading.
  47731. */
  47732. /**
  47733. * Gets wether or not the texture is blocking during loading.
  47734. */
  47735. isBlocking: boolean;
  47736. protected _rotationY: number;
  47737. /**
  47738. * Sets texture matrix rotation angle around Y axis in radians.
  47739. */
  47740. /**
  47741. * Gets texture matrix rotation angle around Y axis radians.
  47742. */
  47743. rotationY: number;
  47744. /**
  47745. * Gets or sets the center of the bounding box associated with the cube texture
  47746. * It must define where the camera used to render the texture was set
  47747. */
  47748. boundingBoxPosition: Vector3;
  47749. private _boundingBoxSize;
  47750. /**
  47751. * Gets or sets the size of the bounding box associated with the cube texture
  47752. * When defined, the cubemap will switch to local mode
  47753. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47754. * @example https://www.babylonjs-playground.com/#RNASML
  47755. */
  47756. boundingBoxSize: Vector3;
  47757. /**
  47758. * Instantiates an HDRTexture from the following parameters.
  47759. *
  47760. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47761. * @param scene The scene the texture will be used in
  47762. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47763. * @param noMipmap Forces to not generate the mipmap if true
  47764. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47765. * @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)
  47766. * @param reserved Reserved flag for internal use.
  47767. */
  47768. 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>);
  47769. /**
  47770. * Get the current class name of the texture useful for serialization or dynamic coding.
  47771. * @returns "HDRCubeTexture"
  47772. */
  47773. getClassName(): string;
  47774. /**
  47775. * Occurs when the file is raw .hdr file.
  47776. */
  47777. private loadTexture;
  47778. clone(): HDRCubeTexture;
  47779. delayLoad(): void;
  47780. /**
  47781. * Get the texture reflection matrix used to rotate/transform the reflection.
  47782. * @returns the reflection matrix
  47783. */
  47784. getReflectionTextureMatrix(): Matrix;
  47785. /**
  47786. * Set the texture reflection matrix used to rotate/transform the reflection.
  47787. * @param value Define the reflection matrix to set
  47788. */
  47789. setReflectionTextureMatrix(value: Matrix): void;
  47790. /**
  47791. * Parses a JSON representation of an HDR Texture in order to create the texture
  47792. * @param parsedTexture Define the JSON representation
  47793. * @param scene Define the scene the texture should be created in
  47794. * @param rootUrl Define the root url in case we need to load relative dependencies
  47795. * @returns the newly created texture after parsing
  47796. */
  47797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47798. serialize(): any;
  47799. }
  47800. }
  47801. declare module BABYLON {
  47802. /**
  47803. * Class used to control physics engine
  47804. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47805. */
  47806. export class PhysicsEngine implements IPhysicsEngine {
  47807. private _physicsPlugin;
  47808. /**
  47809. * Global value used to control the smallest number supported by the simulation
  47810. */
  47811. static Epsilon: number;
  47812. private _impostors;
  47813. private _joints;
  47814. /**
  47815. * Gets the gravity vector used by the simulation
  47816. */
  47817. gravity: Vector3;
  47818. /**
  47819. * Factory used to create the default physics plugin.
  47820. * @returns The default physics plugin
  47821. */
  47822. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47823. /**
  47824. * Creates a new Physics Engine
  47825. * @param gravity defines the gravity vector used by the simulation
  47826. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47827. */
  47828. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47829. /**
  47830. * Sets the gravity vector used by the simulation
  47831. * @param gravity defines the gravity vector to use
  47832. */
  47833. setGravity(gravity: Vector3): void;
  47834. /**
  47835. * Set the time step of the physics engine.
  47836. * Default is 1/60.
  47837. * To slow it down, enter 1/600 for example.
  47838. * To speed it up, 1/30
  47839. * @param newTimeStep defines the new timestep to apply to this world.
  47840. */
  47841. setTimeStep(newTimeStep?: number): void;
  47842. /**
  47843. * Get the time step of the physics engine.
  47844. * @returns the current time step
  47845. */
  47846. getTimeStep(): number;
  47847. /**
  47848. * Release all resources
  47849. */
  47850. dispose(): void;
  47851. /**
  47852. * Gets the name of the current physics plugin
  47853. * @returns the name of the plugin
  47854. */
  47855. getPhysicsPluginName(): string;
  47856. /**
  47857. * Adding a new impostor for the impostor tracking.
  47858. * This will be done by the impostor itself.
  47859. * @param impostor the impostor to add
  47860. */
  47861. addImpostor(impostor: PhysicsImpostor): void;
  47862. /**
  47863. * Remove an impostor from the engine.
  47864. * This impostor and its mesh will not longer be updated by the physics engine.
  47865. * @param impostor the impostor to remove
  47866. */
  47867. removeImpostor(impostor: PhysicsImpostor): void;
  47868. /**
  47869. * Add a joint to the physics engine
  47870. * @param mainImpostor defines the main impostor to which the joint is added.
  47871. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47872. * @param joint defines the joint that will connect both impostors.
  47873. */
  47874. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47875. /**
  47876. * Removes a joint from the simulation
  47877. * @param mainImpostor defines the impostor used with the joint
  47878. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47879. * @param joint defines the joint to remove
  47880. */
  47881. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47882. /**
  47883. * Called by the scene. No need to call it.
  47884. * @param delta defines the timespam between frames
  47885. */
  47886. _step(delta: number): void;
  47887. /**
  47888. * Gets the current plugin used to run the simulation
  47889. * @returns current plugin
  47890. */
  47891. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47892. /**
  47893. * Gets the list of physic impostors
  47894. * @returns an array of PhysicsImpostor
  47895. */
  47896. getImpostors(): Array<PhysicsImpostor>;
  47897. /**
  47898. * Gets the impostor for a physics enabled object
  47899. * @param object defines the object impersonated by the impostor
  47900. * @returns the PhysicsImpostor or null if not found
  47901. */
  47902. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47903. /**
  47904. * Gets the impostor for a physics body object
  47905. * @param body defines physics body used by the impostor
  47906. * @returns the PhysicsImpostor or null if not found
  47907. */
  47908. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47909. /**
  47910. * Does a raycast in the physics world
  47911. * @param from when should the ray start?
  47912. * @param to when should the ray end?
  47913. * @returns PhysicsRaycastResult
  47914. */
  47915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47916. }
  47917. }
  47918. declare module BABYLON {
  47919. /** @hidden */
  47920. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47921. private _useDeltaForWorldStep;
  47922. world: any;
  47923. name: string;
  47924. private _physicsMaterials;
  47925. private _fixedTimeStep;
  47926. private _cannonRaycastResult;
  47927. private _raycastResult;
  47928. private _removeAfterStep;
  47929. BJSCANNON: any;
  47930. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47931. setGravity(gravity: Vector3): void;
  47932. setTimeStep(timeStep: number): void;
  47933. getTimeStep(): number;
  47934. executeStep(delta: number): void;
  47935. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47936. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47937. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47938. private _processChildMeshes;
  47939. removePhysicsBody(impostor: PhysicsImpostor): void;
  47940. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47941. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47942. private _addMaterial;
  47943. private _checkWithEpsilon;
  47944. private _createShape;
  47945. private _createHeightmap;
  47946. private _minus90X;
  47947. private _plus90X;
  47948. private _tmpPosition;
  47949. private _tmpDeltaPosition;
  47950. private _tmpUnityRotation;
  47951. private _updatePhysicsBodyTransformation;
  47952. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47953. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47954. isSupported(): boolean;
  47955. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47956. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47957. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47958. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47959. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47960. getBodyMass(impostor: PhysicsImpostor): number;
  47961. getBodyFriction(impostor: PhysicsImpostor): number;
  47962. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47963. getBodyRestitution(impostor: PhysicsImpostor): number;
  47964. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47965. sleepBody(impostor: PhysicsImpostor): void;
  47966. wakeUpBody(impostor: PhysicsImpostor): void;
  47967. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47968. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47969. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47970. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47971. getRadius(impostor: PhysicsImpostor): number;
  47972. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47973. dispose(): void;
  47974. private _extendNamespace;
  47975. /**
  47976. * Does a raycast in the physics world
  47977. * @param from when should the ray start?
  47978. * @param to when should the ray end?
  47979. * @returns PhysicsRaycastResult
  47980. */
  47981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. /** @hidden */
  47986. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47987. world: any;
  47988. name: string;
  47989. BJSOIMO: any;
  47990. private _raycastResult;
  47991. constructor(iterations?: number, oimoInjection?: any);
  47992. setGravity(gravity: Vector3): void;
  47993. setTimeStep(timeStep: number): void;
  47994. getTimeStep(): number;
  47995. private _tmpImpostorsArray;
  47996. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47997. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47998. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47999. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48000. private _tmpPositionVector;
  48001. removePhysicsBody(impostor: PhysicsImpostor): void;
  48002. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48003. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48004. isSupported(): boolean;
  48005. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48006. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48007. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48008. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48009. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48010. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48011. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48012. getBodyMass(impostor: PhysicsImpostor): number;
  48013. getBodyFriction(impostor: PhysicsImpostor): number;
  48014. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48015. getBodyRestitution(impostor: PhysicsImpostor): number;
  48016. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48017. sleepBody(impostor: PhysicsImpostor): void;
  48018. wakeUpBody(impostor: PhysicsImpostor): void;
  48019. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48020. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48021. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48022. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48023. getRadius(impostor: PhysicsImpostor): number;
  48024. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48025. dispose(): void;
  48026. /**
  48027. * Does a raycast in the physics world
  48028. * @param from when should the ray start?
  48029. * @param to when should the ray end?
  48030. * @returns PhysicsRaycastResult
  48031. */
  48032. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48033. }
  48034. }
  48035. declare module BABYLON {
  48036. /**
  48037. * Class containing static functions to help procedurally build meshes
  48038. */
  48039. export class RibbonBuilder {
  48040. /**
  48041. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48042. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48043. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48044. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48045. * * 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
  48046. * * 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
  48047. * * 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
  48048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48049. * * 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
  48050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48051. * * 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
  48052. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48053. * * 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
  48054. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48056. * @param name defines the name of the mesh
  48057. * @param options defines the options used to create the mesh
  48058. * @param scene defines the hosting scene
  48059. * @returns the ribbon mesh
  48060. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48062. */
  48063. static CreateRibbon(name: string, options: {
  48064. pathArray: Vector3[][];
  48065. closeArray?: boolean;
  48066. closePath?: boolean;
  48067. offset?: number;
  48068. updatable?: boolean;
  48069. sideOrientation?: number;
  48070. frontUVs?: Vector4;
  48071. backUVs?: Vector4;
  48072. instance?: Mesh;
  48073. invertUV?: boolean;
  48074. uvs?: Vector2[];
  48075. colors?: Color4[];
  48076. }, scene?: Nullable<Scene>): Mesh;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * Class containing static functions to help procedurally build meshes
  48082. */
  48083. export class ShapeBuilder {
  48084. /**
  48085. * 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.
  48086. * * 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.
  48087. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48088. * * 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.
  48089. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48090. * * 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
  48091. * * 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
  48092. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48094. * * 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
  48095. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48097. * @param name defines the name of the mesh
  48098. * @param options defines the options used to create the mesh
  48099. * @param scene defines the hosting scene
  48100. * @returns the extruded shape mesh
  48101. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48103. */
  48104. static ExtrudeShape(name: string, options: {
  48105. shape: Vector3[];
  48106. path: Vector3[];
  48107. scale?: number;
  48108. rotation?: number;
  48109. cap?: number;
  48110. updatable?: boolean;
  48111. sideOrientation?: number;
  48112. frontUVs?: Vector4;
  48113. backUVs?: Vector4;
  48114. instance?: Mesh;
  48115. invertUV?: boolean;
  48116. }, scene?: Nullable<Scene>): Mesh;
  48117. /**
  48118. * Creates an custom extruded shape mesh.
  48119. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48120. * * 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.
  48121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48122. * * 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
  48123. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48124. * * 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
  48125. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48126. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48127. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48128. * * 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
  48129. * * 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
  48130. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48132. * * 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
  48133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48135. * @param name defines the name of the mesh
  48136. * @param options defines the options used to create the mesh
  48137. * @param scene defines the hosting scene
  48138. * @returns the custom extruded shape mesh
  48139. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48142. */
  48143. static ExtrudeShapeCustom(name: string, options: {
  48144. shape: Vector3[];
  48145. path: Vector3[];
  48146. scaleFunction?: any;
  48147. rotationFunction?: any;
  48148. ribbonCloseArray?: boolean;
  48149. ribbonClosePath?: boolean;
  48150. cap?: number;
  48151. updatable?: boolean;
  48152. sideOrientation?: number;
  48153. frontUVs?: Vector4;
  48154. backUVs?: Vector4;
  48155. instance?: Mesh;
  48156. invertUV?: boolean;
  48157. }, scene?: Nullable<Scene>): Mesh;
  48158. private static _ExtrudeShapeGeneric;
  48159. }
  48160. }
  48161. declare module BABYLON {
  48162. /**
  48163. * AmmoJS Physics plugin
  48164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48165. * @see https://github.com/kripken/ammo.js/
  48166. */
  48167. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48168. private _useDeltaForWorldStep;
  48169. /**
  48170. * Reference to the Ammo library
  48171. */
  48172. bjsAMMO: any;
  48173. /**
  48174. * Created ammoJS world which physics bodies are added to
  48175. */
  48176. world: any;
  48177. /**
  48178. * Name of the plugin
  48179. */
  48180. name: string;
  48181. private _timeStep;
  48182. private _fixedTimeStep;
  48183. private _maxSteps;
  48184. private _tmpQuaternion;
  48185. private _tmpAmmoTransform;
  48186. private _tmpAmmoQuaternion;
  48187. private _tmpAmmoConcreteContactResultCallback;
  48188. private _collisionConfiguration;
  48189. private _dispatcher;
  48190. private _overlappingPairCache;
  48191. private _solver;
  48192. private _softBodySolver;
  48193. private _tmpAmmoVectorA;
  48194. private _tmpAmmoVectorB;
  48195. private _tmpAmmoVectorC;
  48196. private _tmpAmmoVectorD;
  48197. private _tmpContactCallbackResult;
  48198. private _tmpAmmoVectorRCA;
  48199. private _tmpAmmoVectorRCB;
  48200. private _raycastResult;
  48201. private static readonly DISABLE_COLLISION_FLAG;
  48202. private static readonly KINEMATIC_FLAG;
  48203. private static readonly DISABLE_DEACTIVATION_FLAG;
  48204. /**
  48205. * Initializes the ammoJS plugin
  48206. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48207. * @param ammoInjection can be used to inject your own ammo reference
  48208. */
  48209. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48210. /**
  48211. * Sets the gravity of the physics world (m/(s^2))
  48212. * @param gravity Gravity to set
  48213. */
  48214. setGravity(gravity: Vector3): void;
  48215. /**
  48216. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48217. * @param timeStep timestep to use in seconds
  48218. */
  48219. setTimeStep(timeStep: number): void;
  48220. /**
  48221. * 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)
  48222. * @param fixedTimeStep fixedTimeStep to use in seconds
  48223. */
  48224. setFixedTimeStep(fixedTimeStep: number): void;
  48225. /**
  48226. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48227. * @param maxSteps the maximum number of steps by the physics engine per frame
  48228. */
  48229. setMaxSteps(maxSteps: number): void;
  48230. /**
  48231. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48232. * @returns the current timestep in seconds
  48233. */
  48234. getTimeStep(): number;
  48235. private _isImpostorInContact;
  48236. private _isImpostorPairInContact;
  48237. private _stepSimulation;
  48238. /**
  48239. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48240. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48241. * After the step the babylon meshes are set to the position of the physics imposters
  48242. * @param delta amount of time to step forward
  48243. * @param impostors array of imposters to update before/after the step
  48244. */
  48245. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48246. /**
  48247. * Update babylon mesh to match physics world object
  48248. * @param impostor imposter to match
  48249. */
  48250. private _afterSoftStep;
  48251. /**
  48252. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48253. * @param impostor imposter to match
  48254. */
  48255. private _ropeStep;
  48256. /**
  48257. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48258. * @param impostor imposter to match
  48259. */
  48260. private _softbodyOrClothStep;
  48261. private _tmpVector;
  48262. private _tmpMatrix;
  48263. /**
  48264. * Applies an impulse on the imposter
  48265. * @param impostor imposter to apply impulse to
  48266. * @param force amount of force to be applied to the imposter
  48267. * @param contactPoint the location to apply the impulse on the imposter
  48268. */
  48269. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48270. /**
  48271. * Applies a force on the imposter
  48272. * @param impostor imposter to apply force
  48273. * @param force amount of force to be applied to the imposter
  48274. * @param contactPoint the location to apply the force on the imposter
  48275. */
  48276. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48277. /**
  48278. * Creates a physics body using the plugin
  48279. * @param impostor the imposter to create the physics body on
  48280. */
  48281. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48282. /**
  48283. * Removes the physics body from the imposter and disposes of the body's memory
  48284. * @param impostor imposter to remove the physics body from
  48285. */
  48286. removePhysicsBody(impostor: PhysicsImpostor): void;
  48287. /**
  48288. * Generates a joint
  48289. * @param impostorJoint the imposter joint to create the joint with
  48290. */
  48291. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48292. /**
  48293. * Removes a joint
  48294. * @param impostorJoint the imposter joint to remove the joint from
  48295. */
  48296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48297. private _addMeshVerts;
  48298. /**
  48299. * Initialise the soft body vertices to match its object's (mesh) vertices
  48300. * Softbody vertices (nodes) are in world space and to match this
  48301. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48302. * @param impostor to create the softbody for
  48303. */
  48304. private _softVertexData;
  48305. /**
  48306. * Create an impostor's soft body
  48307. * @param impostor to create the softbody for
  48308. */
  48309. private _createSoftbody;
  48310. /**
  48311. * Create cloth for an impostor
  48312. * @param impostor to create the softbody for
  48313. */
  48314. private _createCloth;
  48315. /**
  48316. * Create rope for an impostor
  48317. * @param impostor to create the softbody for
  48318. */
  48319. private _createRope;
  48320. private _addHullVerts;
  48321. private _createShape;
  48322. /**
  48323. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48324. * @param impostor imposter containing the physics body and babylon object
  48325. */
  48326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48327. /**
  48328. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48329. * @param impostor imposter containing the physics body and babylon object
  48330. * @param newPosition new position
  48331. * @param newRotation new rotation
  48332. */
  48333. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48334. /**
  48335. * If this plugin is supported
  48336. * @returns true if its supported
  48337. */
  48338. isSupported(): boolean;
  48339. /**
  48340. * Sets the linear velocity of the physics body
  48341. * @param impostor imposter to set the velocity on
  48342. * @param velocity velocity to set
  48343. */
  48344. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48345. /**
  48346. * Sets the angular velocity of the physics body
  48347. * @param impostor imposter to set the velocity on
  48348. * @param velocity velocity to set
  48349. */
  48350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48351. /**
  48352. * gets the linear velocity
  48353. * @param impostor imposter to get linear velocity from
  48354. * @returns linear velocity
  48355. */
  48356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48357. /**
  48358. * gets the angular velocity
  48359. * @param impostor imposter to get angular velocity from
  48360. * @returns angular velocity
  48361. */
  48362. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48363. /**
  48364. * Sets the mass of physics body
  48365. * @param impostor imposter to set the mass on
  48366. * @param mass mass to set
  48367. */
  48368. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48369. /**
  48370. * Gets the mass of the physics body
  48371. * @param impostor imposter to get the mass from
  48372. * @returns mass
  48373. */
  48374. getBodyMass(impostor: PhysicsImpostor): number;
  48375. /**
  48376. * Gets friction of the impostor
  48377. * @param impostor impostor to get friction from
  48378. * @returns friction value
  48379. */
  48380. getBodyFriction(impostor: PhysicsImpostor): number;
  48381. /**
  48382. * Sets friction of the impostor
  48383. * @param impostor impostor to set friction on
  48384. * @param friction friction value
  48385. */
  48386. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48387. /**
  48388. * Gets restitution of the impostor
  48389. * @param impostor impostor to get restitution from
  48390. * @returns restitution value
  48391. */
  48392. getBodyRestitution(impostor: PhysicsImpostor): number;
  48393. /**
  48394. * Sets resitution of the impostor
  48395. * @param impostor impostor to set resitution on
  48396. * @param restitution resitution value
  48397. */
  48398. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48399. /**
  48400. * Gets pressure inside the impostor
  48401. * @param impostor impostor to get pressure from
  48402. * @returns pressure value
  48403. */
  48404. getBodyPressure(impostor: PhysicsImpostor): number;
  48405. /**
  48406. * Sets pressure inside a soft body impostor
  48407. * Cloth and rope must remain 0 pressure
  48408. * @param impostor impostor to set pressure on
  48409. * @param pressure pressure value
  48410. */
  48411. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48412. /**
  48413. * Gets stiffness of the impostor
  48414. * @param impostor impostor to get stiffness from
  48415. * @returns pressure value
  48416. */
  48417. getBodyStiffness(impostor: PhysicsImpostor): number;
  48418. /**
  48419. * Sets stiffness of the impostor
  48420. * @param impostor impostor to set stiffness on
  48421. * @param stiffness stiffness value from 0 to 1
  48422. */
  48423. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48424. /**
  48425. * Gets velocityIterations of the impostor
  48426. * @param impostor impostor to get velocity iterations from
  48427. * @returns velocityIterations value
  48428. */
  48429. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48430. /**
  48431. * Sets velocityIterations of the impostor
  48432. * @param impostor impostor to set velocity iterations on
  48433. * @param velocityIterations velocityIterations value
  48434. */
  48435. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48436. /**
  48437. * Gets positionIterations of the impostor
  48438. * @param impostor impostor to get position iterations from
  48439. * @returns positionIterations value
  48440. */
  48441. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48442. /**
  48443. * Sets positionIterations of the impostor
  48444. * @param impostor impostor to set position on
  48445. * @param positionIterations positionIterations value
  48446. */
  48447. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48448. /**
  48449. * Append an anchor to a cloth object
  48450. * @param impostor is the cloth impostor to add anchor to
  48451. * @param otherImpostor is the rigid impostor to anchor to
  48452. * @param width ratio across width from 0 to 1
  48453. * @param height ratio up height from 0 to 1
  48454. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48455. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48456. */
  48457. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48458. /**
  48459. * Append an hook to a rope object
  48460. * @param impostor is the rope impostor to add hook to
  48461. * @param otherImpostor is the rigid impostor to hook to
  48462. * @param length ratio along the rope from 0 to 1
  48463. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48464. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48465. */
  48466. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48467. /**
  48468. * Sleeps the physics body and stops it from being active
  48469. * @param impostor impostor to sleep
  48470. */
  48471. sleepBody(impostor: PhysicsImpostor): void;
  48472. /**
  48473. * Activates the physics body
  48474. * @param impostor impostor to activate
  48475. */
  48476. wakeUpBody(impostor: PhysicsImpostor): void;
  48477. /**
  48478. * Updates the distance parameters of the joint
  48479. * @param joint joint to update
  48480. * @param maxDistance maximum distance of the joint
  48481. * @param minDistance minimum distance of the joint
  48482. */
  48483. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48484. /**
  48485. * Sets a motor on the joint
  48486. * @param joint joint to set motor on
  48487. * @param speed speed of the motor
  48488. * @param maxForce maximum force of the motor
  48489. * @param motorIndex index of the motor
  48490. */
  48491. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48492. /**
  48493. * Sets the motors limit
  48494. * @param joint joint to set limit on
  48495. * @param upperLimit upper limit
  48496. * @param lowerLimit lower limit
  48497. */
  48498. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48499. /**
  48500. * Syncs the position and rotation of a mesh with the impostor
  48501. * @param mesh mesh to sync
  48502. * @param impostor impostor to update the mesh with
  48503. */
  48504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48505. /**
  48506. * Gets the radius of the impostor
  48507. * @param impostor impostor to get radius from
  48508. * @returns the radius
  48509. */
  48510. getRadius(impostor: PhysicsImpostor): number;
  48511. /**
  48512. * Gets the box size of the impostor
  48513. * @param impostor impostor to get box size from
  48514. * @param result the resulting box size
  48515. */
  48516. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48517. /**
  48518. * Disposes of the impostor
  48519. */
  48520. dispose(): void;
  48521. /**
  48522. * Does a raycast in the physics world
  48523. * @param from when should the ray start?
  48524. * @param to when should the ray end?
  48525. * @returns PhysicsRaycastResult
  48526. */
  48527. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48528. }
  48529. }
  48530. declare module BABYLON {
  48531. interface AbstractScene {
  48532. /**
  48533. * The list of reflection probes added to the scene
  48534. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48535. */
  48536. reflectionProbes: Array<ReflectionProbe>;
  48537. /**
  48538. * Removes the given reflection probe from this scene.
  48539. * @param toRemove The reflection probe to remove
  48540. * @returns The index of the removed reflection probe
  48541. */
  48542. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48543. /**
  48544. * Adds the given reflection probe to this scene.
  48545. * @param newReflectionProbe The reflection probe to add
  48546. */
  48547. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48548. }
  48549. /**
  48550. * Class used to generate realtime reflection / refraction cube textures
  48551. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48552. */
  48553. export class ReflectionProbe {
  48554. /** defines the name of the probe */
  48555. name: string;
  48556. private _scene;
  48557. private _renderTargetTexture;
  48558. private _projectionMatrix;
  48559. private _viewMatrix;
  48560. private _target;
  48561. private _add;
  48562. private _attachedMesh;
  48563. private _invertYAxis;
  48564. /** Gets or sets probe position (center of the cube map) */
  48565. position: Vector3;
  48566. /**
  48567. * Creates a new reflection probe
  48568. * @param name defines the name of the probe
  48569. * @param size defines the texture resolution (for each face)
  48570. * @param scene defines the hosting scene
  48571. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48572. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48573. */
  48574. constructor(
  48575. /** defines the name of the probe */
  48576. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48577. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48578. samples: number;
  48579. /** Gets or sets the refresh rate to use (on every frame by default) */
  48580. refreshRate: number;
  48581. /**
  48582. * Gets the hosting scene
  48583. * @returns a Scene
  48584. */
  48585. getScene(): Scene;
  48586. /** Gets the internal CubeTexture used to render to */
  48587. readonly cubeTexture: RenderTargetTexture;
  48588. /** Gets the list of meshes to render */
  48589. readonly renderList: Nullable<AbstractMesh[]>;
  48590. /**
  48591. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48592. * @param mesh defines the mesh to attach to
  48593. */
  48594. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48595. /**
  48596. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48597. * @param renderingGroupId The rendering group id corresponding to its index
  48598. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48599. */
  48600. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48601. /**
  48602. * Clean all associated resources
  48603. */
  48604. dispose(): void;
  48605. /**
  48606. * Converts the reflection probe information to a readable string for debug purpose.
  48607. * @param fullDetails Supports for multiple levels of logging within scene loading
  48608. * @returns the human readable reflection probe info
  48609. */
  48610. toString(fullDetails?: boolean): string;
  48611. /**
  48612. * Get the class name of the relfection probe.
  48613. * @returns "ReflectionProbe"
  48614. */
  48615. getClassName(): string;
  48616. /**
  48617. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48618. * @returns The JSON representation of the texture
  48619. */
  48620. serialize(): any;
  48621. /**
  48622. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48623. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48624. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48625. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48626. * @returns The parsed reflection probe if successful
  48627. */
  48628. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48629. }
  48630. }
  48631. declare module BABYLON {
  48632. /** @hidden */
  48633. export var _BabylonLoaderRegistered: boolean;
  48634. }
  48635. declare module BABYLON {
  48636. /**
  48637. * The Physically based simple base material of BJS.
  48638. *
  48639. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48640. * It is used as the base class for both the specGloss and metalRough conventions.
  48641. */
  48642. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48643. /**
  48644. * Number of Simultaneous lights allowed on the material.
  48645. */
  48646. maxSimultaneousLights: number;
  48647. /**
  48648. * If sets to true, disables all the lights affecting the material.
  48649. */
  48650. disableLighting: boolean;
  48651. /**
  48652. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48653. */
  48654. environmentTexture: BaseTexture;
  48655. /**
  48656. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48657. */
  48658. invertNormalMapX: boolean;
  48659. /**
  48660. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48661. */
  48662. invertNormalMapY: boolean;
  48663. /**
  48664. * Normal map used in the model.
  48665. */
  48666. normalTexture: BaseTexture;
  48667. /**
  48668. * Emissivie color used to self-illuminate the model.
  48669. */
  48670. emissiveColor: Color3;
  48671. /**
  48672. * Emissivie texture used to self-illuminate the model.
  48673. */
  48674. emissiveTexture: BaseTexture;
  48675. /**
  48676. * Occlusion Channel Strenght.
  48677. */
  48678. occlusionStrength: number;
  48679. /**
  48680. * Occlusion Texture of the material (adding extra occlusion effects).
  48681. */
  48682. occlusionTexture: BaseTexture;
  48683. /**
  48684. * Defines the alpha limits in alpha test mode.
  48685. */
  48686. alphaCutOff: number;
  48687. /**
  48688. * Gets the current double sided mode.
  48689. */
  48690. /**
  48691. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48692. */
  48693. doubleSided: boolean;
  48694. /**
  48695. * Stores the pre-calculated light information of a mesh in a texture.
  48696. */
  48697. lightmapTexture: BaseTexture;
  48698. /**
  48699. * If true, the light map contains occlusion information instead of lighting info.
  48700. */
  48701. useLightmapAsShadowmap: boolean;
  48702. /**
  48703. * Instantiates a new PBRMaterial instance.
  48704. *
  48705. * @param name The material name
  48706. * @param scene The scene the material will be use in.
  48707. */
  48708. constructor(name: string, scene: Scene);
  48709. getClassName(): string;
  48710. }
  48711. }
  48712. declare module BABYLON {
  48713. /**
  48714. * The PBR material of BJS following the metal roughness convention.
  48715. *
  48716. * This fits to the PBR convention in the GLTF definition:
  48717. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48718. */
  48719. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48720. /**
  48721. * The base color has two different interpretations depending on the value of metalness.
  48722. * When the material is a metal, the base color is the specific measured reflectance value
  48723. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48724. * of the material.
  48725. */
  48726. baseColor: Color3;
  48727. /**
  48728. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48729. * well as opacity information in the alpha channel.
  48730. */
  48731. baseTexture: BaseTexture;
  48732. /**
  48733. * Specifies the metallic scalar value of the material.
  48734. * Can also be used to scale the metalness values of the metallic texture.
  48735. */
  48736. metallic: number;
  48737. /**
  48738. * Specifies the roughness scalar value of the material.
  48739. * Can also be used to scale the roughness values of the metallic texture.
  48740. */
  48741. roughness: number;
  48742. /**
  48743. * Texture containing both the metallic value in the B channel and the
  48744. * roughness value in the G channel to keep better precision.
  48745. */
  48746. metallicRoughnessTexture: BaseTexture;
  48747. /**
  48748. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48749. *
  48750. * @param name The material name
  48751. * @param scene The scene the material will be use in.
  48752. */
  48753. constructor(name: string, scene: Scene);
  48754. /**
  48755. * Return the currrent class name of the material.
  48756. */
  48757. getClassName(): string;
  48758. /**
  48759. * Makes a duplicate of the current material.
  48760. * @param name - name to use for the new material.
  48761. */
  48762. clone(name: string): PBRMetallicRoughnessMaterial;
  48763. /**
  48764. * Serialize the material to a parsable JSON object.
  48765. */
  48766. serialize(): any;
  48767. /**
  48768. * Parses a JSON object correponding to the serialize function.
  48769. */
  48770. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48771. }
  48772. }
  48773. declare module BABYLON {
  48774. /**
  48775. * The PBR material of BJS following the specular glossiness convention.
  48776. *
  48777. * This fits to the PBR convention in the GLTF definition:
  48778. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48779. */
  48780. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48781. /**
  48782. * Specifies the diffuse color of the material.
  48783. */
  48784. diffuseColor: Color3;
  48785. /**
  48786. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48787. * channel.
  48788. */
  48789. diffuseTexture: BaseTexture;
  48790. /**
  48791. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48792. */
  48793. specularColor: Color3;
  48794. /**
  48795. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48796. */
  48797. glossiness: number;
  48798. /**
  48799. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48800. */
  48801. specularGlossinessTexture: BaseTexture;
  48802. /**
  48803. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48804. *
  48805. * @param name The material name
  48806. * @param scene The scene the material will be use in.
  48807. */
  48808. constructor(name: string, scene: Scene);
  48809. /**
  48810. * Return the currrent class name of the material.
  48811. */
  48812. getClassName(): string;
  48813. /**
  48814. * Makes a duplicate of the current material.
  48815. * @param name - name to use for the new material.
  48816. */
  48817. clone(name: string): PBRSpecularGlossinessMaterial;
  48818. /**
  48819. * Serialize the material to a parsable JSON object.
  48820. */
  48821. serialize(): any;
  48822. /**
  48823. * Parses a JSON object correponding to the serialize function.
  48824. */
  48825. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48826. }
  48827. }
  48828. declare module BABYLON {
  48829. /**
  48830. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48831. * It can help converting any input color in a desired output one. This can then be used to create effects
  48832. * from sepia, black and white to sixties or futuristic rendering...
  48833. *
  48834. * The only supported format is currently 3dl.
  48835. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48836. */
  48837. export class ColorGradingTexture extends BaseTexture {
  48838. /**
  48839. * The current texture matrix. (will always be identity in color grading texture)
  48840. */
  48841. private _textureMatrix;
  48842. /**
  48843. * The texture URL.
  48844. */
  48845. url: string;
  48846. /**
  48847. * Empty line regex stored for GC.
  48848. */
  48849. private static _noneEmptyLineRegex;
  48850. private _engine;
  48851. /**
  48852. * Instantiates a ColorGradingTexture from the following parameters.
  48853. *
  48854. * @param url The location of the color gradind data (currently only supporting 3dl)
  48855. * @param scene The scene the texture will be used in
  48856. */
  48857. constructor(url: string, scene: Scene);
  48858. /**
  48859. * Returns the texture matrix used in most of the material.
  48860. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48861. */
  48862. getTextureMatrix(): Matrix;
  48863. /**
  48864. * Occurs when the file being loaded is a .3dl LUT file.
  48865. */
  48866. private load3dlTexture;
  48867. /**
  48868. * Starts the loading process of the texture.
  48869. */
  48870. private loadTexture;
  48871. /**
  48872. * Clones the color gradind texture.
  48873. */
  48874. clone(): ColorGradingTexture;
  48875. /**
  48876. * Called during delayed load for textures.
  48877. */
  48878. delayLoad(): void;
  48879. /**
  48880. * Parses a color grading texture serialized by Babylon.
  48881. * @param parsedTexture The texture information being parsedTexture
  48882. * @param scene The scene to load the texture in
  48883. * @param rootUrl The root url of the data assets to load
  48884. * @return A color gradind texture
  48885. */
  48886. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48887. /**
  48888. * Serializes the LUT texture to json format.
  48889. */
  48890. serialize(): any;
  48891. }
  48892. }
  48893. declare module BABYLON {
  48894. /**
  48895. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48896. */
  48897. export class EquiRectangularCubeTexture extends BaseTexture {
  48898. /** The six faces of the cube. */
  48899. private static _FacesMapping;
  48900. private _noMipmap;
  48901. private _onLoad;
  48902. private _onError;
  48903. /** The size of the cubemap. */
  48904. private _size;
  48905. /** The buffer of the image. */
  48906. private _buffer;
  48907. /** The width of the input image. */
  48908. private _width;
  48909. /** The height of the input image. */
  48910. private _height;
  48911. /** The URL to the image. */
  48912. url: string;
  48913. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48914. coordinatesMode: number;
  48915. /**
  48916. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48917. * @param url The location of the image
  48918. * @param scene The scene the texture will be used in
  48919. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48920. * @param noMipmap Forces to not generate the mipmap if true
  48921. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48922. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48923. * @param onLoad — defines a callback called when texture is loaded
  48924. * @param onError — defines a callback called if there is an error
  48925. */
  48926. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48927. /**
  48928. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48929. */
  48930. private loadImage;
  48931. /**
  48932. * Convert the image buffer into a cubemap and create a CubeTexture.
  48933. */
  48934. private loadTexture;
  48935. /**
  48936. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48937. * @param buffer The ArrayBuffer that should be converted.
  48938. * @returns The buffer as Float32Array.
  48939. */
  48940. private getFloat32ArrayFromArrayBuffer;
  48941. /**
  48942. * Get the current class name of the texture useful for serialization or dynamic coding.
  48943. * @returns "EquiRectangularCubeTexture"
  48944. */
  48945. getClassName(): string;
  48946. /**
  48947. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48948. * @returns A clone of the current EquiRectangularCubeTexture.
  48949. */
  48950. clone(): EquiRectangularCubeTexture;
  48951. }
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * Based on jsTGALoader - Javascript loader for TGA file
  48956. * By Vincent Thibault
  48957. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48958. */
  48959. export class TGATools {
  48960. private static _TYPE_INDEXED;
  48961. private static _TYPE_RGB;
  48962. private static _TYPE_GREY;
  48963. private static _TYPE_RLE_INDEXED;
  48964. private static _TYPE_RLE_RGB;
  48965. private static _TYPE_RLE_GREY;
  48966. private static _ORIGIN_MASK;
  48967. private static _ORIGIN_SHIFT;
  48968. private static _ORIGIN_BL;
  48969. private static _ORIGIN_BR;
  48970. private static _ORIGIN_UL;
  48971. private static _ORIGIN_UR;
  48972. /**
  48973. * Gets the header of a TGA file
  48974. * @param data defines the TGA data
  48975. * @returns the header
  48976. */
  48977. static GetTGAHeader(data: Uint8Array): any;
  48978. /**
  48979. * Uploads TGA content to a Babylon Texture
  48980. * @hidden
  48981. */
  48982. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48983. /** @hidden */
  48984. 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;
  48985. /** @hidden */
  48986. 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;
  48987. /** @hidden */
  48988. 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;
  48989. /** @hidden */
  48990. 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;
  48991. /** @hidden */
  48992. 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;
  48993. /** @hidden */
  48994. 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;
  48995. }
  48996. }
  48997. declare module BABYLON {
  48998. /**
  48999. * Implementation of the TGA Texture Loader.
  49000. * @hidden
  49001. */
  49002. export class _TGATextureLoader implements IInternalTextureLoader {
  49003. /**
  49004. * Defines wether the loader supports cascade loading the different faces.
  49005. */
  49006. readonly supportCascades: boolean;
  49007. /**
  49008. * This returns if the loader support the current file information.
  49009. * @param extension defines the file extension of the file being loaded
  49010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49011. * @param fallback defines the fallback internal texture if any
  49012. * @param isBase64 defines whether the texture is encoded as a base64
  49013. * @param isBuffer defines whether the texture data are stored as a buffer
  49014. * @returns true if the loader can load the specified file
  49015. */
  49016. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49017. /**
  49018. * Transform the url before loading if required.
  49019. * @param rootUrl the url of the texture
  49020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49021. * @returns the transformed texture
  49022. */
  49023. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49024. /**
  49025. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49026. * @param rootUrl the url of the texture
  49027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49028. * @returns the fallback texture
  49029. */
  49030. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49031. /**
  49032. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49033. * @param data contains the texture data
  49034. * @param texture defines the BabylonJS internal texture
  49035. * @param createPolynomials will be true if polynomials have been requested
  49036. * @param onLoad defines the callback to trigger once the texture is ready
  49037. * @param onError defines the callback to trigger in case of error
  49038. */
  49039. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49040. /**
  49041. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49042. * @param data contains the texture data
  49043. * @param texture defines the BabylonJS internal texture
  49044. * @param callback defines the method to call once ready to upload
  49045. */
  49046. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49047. }
  49048. }
  49049. declare module BABYLON {
  49050. /**
  49051. * 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.
  49052. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49053. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49054. */
  49055. export class CustomProceduralTexture extends ProceduralTexture {
  49056. private _animate;
  49057. private _time;
  49058. private _config;
  49059. private _texturePath;
  49060. /**
  49061. * Instantiates a new Custom Procedural Texture.
  49062. * 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.
  49063. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49064. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49065. * @param name Define the name of the texture
  49066. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49067. * @param size Define the size of the texture to create
  49068. * @param scene Define the scene the texture belongs to
  49069. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49070. * @param generateMipMaps Define if the texture should creates mip maps or not
  49071. */
  49072. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49073. private _loadJson;
  49074. /**
  49075. * Is the texture ready to be used ? (rendered at least once)
  49076. * @returns true if ready, otherwise, false.
  49077. */
  49078. isReady(): boolean;
  49079. /**
  49080. * Render the texture to its associated render target.
  49081. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49082. */
  49083. render(useCameraPostProcess?: boolean): void;
  49084. /**
  49085. * Update the list of dependant textures samplers in the shader.
  49086. */
  49087. updateTextures(): void;
  49088. /**
  49089. * Update the uniform values of the procedural texture in the shader.
  49090. */
  49091. updateShaderUniforms(): void;
  49092. /**
  49093. * Define if the texture animates or not.
  49094. */
  49095. animate: boolean;
  49096. }
  49097. }
  49098. declare module BABYLON {
  49099. /** @hidden */
  49100. export var noisePixelShader: {
  49101. name: string;
  49102. shader: string;
  49103. };
  49104. }
  49105. declare module BABYLON {
  49106. /**
  49107. * Class used to generate noise procedural textures
  49108. */
  49109. export class NoiseProceduralTexture extends ProceduralTexture {
  49110. private _time;
  49111. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49112. brightness: number;
  49113. /** Defines the number of octaves to process */
  49114. octaves: number;
  49115. /** Defines the level of persistence (0.8 by default) */
  49116. persistence: number;
  49117. /** Gets or sets animation speed factor (default is 1) */
  49118. animationSpeedFactor: number;
  49119. /**
  49120. * Creates a new NoiseProceduralTexture
  49121. * @param name defines the name fo the texture
  49122. * @param size defines the size of the texture (default is 256)
  49123. * @param scene defines the hosting scene
  49124. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49125. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49126. */
  49127. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49128. private _updateShaderUniforms;
  49129. protected _getDefines(): string;
  49130. /** Generate the current state of the procedural texture */
  49131. render(useCameraPostProcess?: boolean): void;
  49132. /**
  49133. * Serializes this noise procedural texture
  49134. * @returns a serialized noise procedural texture object
  49135. */
  49136. serialize(): any;
  49137. /**
  49138. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49139. * @param parsedTexture defines parsed texture data
  49140. * @param scene defines the current scene
  49141. * @param rootUrl defines the root URL containing noise procedural texture information
  49142. * @returns a parsed NoiseProceduralTexture
  49143. */
  49144. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49145. }
  49146. }
  49147. declare module BABYLON {
  49148. /**
  49149. * Raw cube texture where the raw buffers are passed in
  49150. */
  49151. export class RawCubeTexture extends CubeTexture {
  49152. /**
  49153. * Creates a cube texture where the raw buffers are passed in.
  49154. * @param scene defines the scene the texture is attached to
  49155. * @param data defines the array of data to use to create each face
  49156. * @param size defines the size of the textures
  49157. * @param format defines the format of the data
  49158. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49159. * @param generateMipMaps defines if the engine should generate the mip levels
  49160. * @param invertY defines if data must be stored with Y axis inverted
  49161. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49162. * @param compression defines the compression used (null by default)
  49163. */
  49164. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49165. /**
  49166. * Updates the raw cube texture.
  49167. * @param data defines the data to store
  49168. * @param format defines the data format
  49169. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49170. * @param invertY defines if data must be stored with Y axis inverted
  49171. * @param compression defines the compression used (null by default)
  49172. * @param level defines which level of the texture to update
  49173. */
  49174. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49175. /**
  49176. * Updates a raw cube texture with RGBD encoded data.
  49177. * @param data defines the array of data [mipmap][face] to use to create each face
  49178. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49179. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49180. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49181. * @returns a promsie that resolves when the operation is complete
  49182. */
  49183. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49184. /**
  49185. * Clones the raw cube texture.
  49186. * @return a new cube texture
  49187. */
  49188. clone(): CubeTexture;
  49189. /** @hidden */
  49190. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49191. }
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Class used to store 3D textures containing user data
  49196. */
  49197. export class RawTexture3D extends Texture {
  49198. /** Gets or sets the texture format to use */
  49199. format: number;
  49200. private _engine;
  49201. /**
  49202. * Create a new RawTexture3D
  49203. * @param data defines the data of the texture
  49204. * @param width defines the width of the texture
  49205. * @param height defines the height of the texture
  49206. * @param depth defines the depth of the texture
  49207. * @param format defines the texture format to use
  49208. * @param scene defines the hosting scene
  49209. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49210. * @param invertY defines if texture must be stored with Y axis inverted
  49211. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49212. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49213. */
  49214. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49215. /** Gets or sets the texture format to use */
  49216. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49217. /**
  49218. * Update the texture with new data
  49219. * @param data defines the data to store in the texture
  49220. */
  49221. update(data: ArrayBufferView): void;
  49222. }
  49223. }
  49224. declare module BABYLON {
  49225. /**
  49226. * Creates a refraction texture used by refraction channel of the standard material.
  49227. * It is like a mirror but to see through a material.
  49228. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49229. */
  49230. export class RefractionTexture extends RenderTargetTexture {
  49231. /**
  49232. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49233. * 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.
  49234. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49235. */
  49236. refractionPlane: Plane;
  49237. /**
  49238. * Define how deep under the surface we should see.
  49239. */
  49240. depth: number;
  49241. /**
  49242. * Creates a refraction texture used by refraction channel of the standard material.
  49243. * It is like a mirror but to see through a material.
  49244. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49245. * @param name Define the texture name
  49246. * @param size Define the size of the underlying texture
  49247. * @param scene Define the scene the refraction belongs to
  49248. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49249. */
  49250. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49251. /**
  49252. * Clone the refraction texture.
  49253. * @returns the cloned texture
  49254. */
  49255. clone(): RefractionTexture;
  49256. /**
  49257. * Serialize the texture to a JSON representation you could use in Parse later on
  49258. * @returns the serialized JSON representation
  49259. */
  49260. serialize(): any;
  49261. }
  49262. }
  49263. declare module BABYLON {
  49264. /**
  49265. * Helper class to push actions to a pool of workers.
  49266. */
  49267. export class WorkerPool implements IDisposable {
  49268. private _workerInfos;
  49269. private _pendingActions;
  49270. /**
  49271. * Constructor
  49272. * @param workers Array of workers to use for actions
  49273. */
  49274. constructor(workers: Array<Worker>);
  49275. /**
  49276. * Terminates all workers and clears any pending actions.
  49277. */
  49278. dispose(): void;
  49279. /**
  49280. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49281. * pended until a worker has completed its action.
  49282. * @param action The action to perform. Call onComplete when the action is complete.
  49283. */
  49284. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49285. private _execute;
  49286. }
  49287. }
  49288. declare module BABYLON {
  49289. /**
  49290. * Configuration for Draco compression
  49291. */
  49292. export interface IDracoCompressionConfiguration {
  49293. /**
  49294. * Configuration for the decoder.
  49295. */
  49296. decoder?: {
  49297. /**
  49298. * The url to the WebAssembly module.
  49299. */
  49300. wasmUrl?: string;
  49301. /**
  49302. * The url to the WebAssembly binary.
  49303. */
  49304. wasmBinaryUrl?: string;
  49305. /**
  49306. * The url to the fallback JavaScript module.
  49307. */
  49308. fallbackUrl?: string;
  49309. };
  49310. }
  49311. /**
  49312. * Draco compression (https://google.github.io/draco/)
  49313. *
  49314. * This class wraps the Draco module.
  49315. *
  49316. * **Encoder**
  49317. *
  49318. * The encoder is not currently implemented.
  49319. *
  49320. * **Decoder**
  49321. *
  49322. * 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.
  49323. *
  49324. * To update the configuration, use the following code:
  49325. * ```javascript
  49326. * DracoCompression.Configuration = {
  49327. * decoder: {
  49328. * wasmUrl: "<url to the WebAssembly library>",
  49329. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49330. * fallbackUrl: "<url to the fallback JavaScript library>",
  49331. * }
  49332. * };
  49333. * ```
  49334. *
  49335. * 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.
  49336. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49337. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49338. *
  49339. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49340. * ```javascript
  49341. * var dracoCompression = new DracoCompression();
  49342. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49343. * [VertexBuffer.PositionKind]: 0
  49344. * });
  49345. * ```
  49346. *
  49347. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49348. */
  49349. export class DracoCompression implements IDisposable {
  49350. private _workerPoolPromise;
  49351. /**
  49352. * The configuration. Defaults to the following urls:
  49353. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49354. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49355. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49356. */
  49357. static Configuration: IDracoCompressionConfiguration;
  49358. /**
  49359. * Returns true if the decoder is available.
  49360. */
  49361. static readonly DecoderAvailable: boolean;
  49362. /**
  49363. * Default number of workers to create when creating the draco compression object.
  49364. */
  49365. static DefaultNumWorkers: number;
  49366. private static GetDefaultNumWorkers;
  49367. /**
  49368. * Constructor
  49369. * @param numWorkers The number of workers for async operations
  49370. */
  49371. constructor(numWorkers?: number);
  49372. /**
  49373. * Stop all async operations and release resources.
  49374. */
  49375. dispose(): void;
  49376. /**
  49377. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49378. * @returns a promise that resolves when ready
  49379. */
  49380. whenReadyAsync(): Promise<void>;
  49381. /**
  49382. * Decode Draco compressed mesh data to vertex data.
  49383. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49384. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49385. * @returns A promise that resolves with the decoded vertex data
  49386. */
  49387. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49388. [kind: string]: number;
  49389. }): Promise<VertexData>;
  49390. /**
  49391. * The worker function that gets converted to a blob url to pass into a worker.
  49392. */
  49393. private static _Worker;
  49394. private _loadDecoderWasmBinaryAsync;
  49395. }
  49396. }
  49397. declare module BABYLON {
  49398. /**
  49399. * Class for building Constructive Solid Geometry
  49400. */
  49401. export class CSG {
  49402. private polygons;
  49403. /**
  49404. * The world matrix
  49405. */
  49406. matrix: Matrix;
  49407. /**
  49408. * Stores the position
  49409. */
  49410. position: Vector3;
  49411. /**
  49412. * Stores the rotation
  49413. */
  49414. rotation: Vector3;
  49415. /**
  49416. * Stores the rotation quaternion
  49417. */
  49418. rotationQuaternion: Nullable<Quaternion>;
  49419. /**
  49420. * Stores the scaling vector
  49421. */
  49422. scaling: Vector3;
  49423. /**
  49424. * Convert the Mesh to CSG
  49425. * @param mesh The Mesh to convert to CSG
  49426. * @returns A new CSG from the Mesh
  49427. */
  49428. static FromMesh(mesh: Mesh): CSG;
  49429. /**
  49430. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49431. * @param polygons Polygons used to construct a CSG solid
  49432. */
  49433. private static FromPolygons;
  49434. /**
  49435. * Clones, or makes a deep copy, of the CSG
  49436. * @returns A new CSG
  49437. */
  49438. clone(): CSG;
  49439. /**
  49440. * Unions this CSG with another CSG
  49441. * @param csg The CSG to union against this CSG
  49442. * @returns The unioned CSG
  49443. */
  49444. union(csg: CSG): CSG;
  49445. /**
  49446. * Unions this CSG with another CSG in place
  49447. * @param csg The CSG to union against this CSG
  49448. */
  49449. unionInPlace(csg: CSG): void;
  49450. /**
  49451. * Subtracts this CSG with another CSG
  49452. * @param csg The CSG to subtract against this CSG
  49453. * @returns A new CSG
  49454. */
  49455. subtract(csg: CSG): CSG;
  49456. /**
  49457. * Subtracts this CSG with another CSG in place
  49458. * @param csg The CSG to subtact against this CSG
  49459. */
  49460. subtractInPlace(csg: CSG): void;
  49461. /**
  49462. * Intersect this CSG with another CSG
  49463. * @param csg The CSG to intersect against this CSG
  49464. * @returns A new CSG
  49465. */
  49466. intersect(csg: CSG): CSG;
  49467. /**
  49468. * Intersects this CSG with another CSG in place
  49469. * @param csg The CSG to intersect against this CSG
  49470. */
  49471. intersectInPlace(csg: CSG): void;
  49472. /**
  49473. * Return a new CSG solid with solid and empty space switched. This solid is
  49474. * not modified.
  49475. * @returns A new CSG solid with solid and empty space switched
  49476. */
  49477. inverse(): CSG;
  49478. /**
  49479. * Inverses the CSG in place
  49480. */
  49481. inverseInPlace(): void;
  49482. /**
  49483. * This is used to keep meshes transformations so they can be restored
  49484. * when we build back a Babylon Mesh
  49485. * NB : All CSG operations are performed in world coordinates
  49486. * @param csg The CSG to copy the transform attributes from
  49487. * @returns This CSG
  49488. */
  49489. copyTransformAttributes(csg: CSG): CSG;
  49490. /**
  49491. * Build Raw mesh from CSG
  49492. * Coordinates here are in world space
  49493. * @param name The name of the mesh geometry
  49494. * @param scene The Scene
  49495. * @param keepSubMeshes Specifies if the submeshes should be kept
  49496. * @returns A new Mesh
  49497. */
  49498. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49499. /**
  49500. * Build Mesh from CSG taking material and transforms into account
  49501. * @param name The name of the Mesh
  49502. * @param material The material of the Mesh
  49503. * @param scene The Scene
  49504. * @param keepSubMeshes Specifies if submeshes should be kept
  49505. * @returns The new Mesh
  49506. */
  49507. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49508. }
  49509. }
  49510. declare module BABYLON {
  49511. /**
  49512. * Class used to create a trail following a mesh
  49513. */
  49514. export class TrailMesh extends Mesh {
  49515. private _generator;
  49516. private _autoStart;
  49517. private _running;
  49518. private _diameter;
  49519. private _length;
  49520. private _sectionPolygonPointsCount;
  49521. private _sectionVectors;
  49522. private _sectionNormalVectors;
  49523. private _beforeRenderObserver;
  49524. /**
  49525. * @constructor
  49526. * @param name The value used by scene.getMeshByName() to do a lookup.
  49527. * @param generator The mesh to generate a trail.
  49528. * @param scene The scene to add this mesh to.
  49529. * @param diameter Diameter of trailing mesh. Default is 1.
  49530. * @param length Length of trailing mesh. Default is 60.
  49531. * @param autoStart Automatically start trailing mesh. Default true.
  49532. */
  49533. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49534. /**
  49535. * "TrailMesh"
  49536. * @returns "TrailMesh"
  49537. */
  49538. getClassName(): string;
  49539. private _createMesh;
  49540. /**
  49541. * Start trailing mesh.
  49542. */
  49543. start(): void;
  49544. /**
  49545. * Stop trailing mesh.
  49546. */
  49547. stop(): void;
  49548. /**
  49549. * Update trailing mesh geometry.
  49550. */
  49551. update(): void;
  49552. /**
  49553. * Returns a new TrailMesh object.
  49554. * @param name is a string, the name given to the new mesh
  49555. * @param newGenerator use new generator object for cloned trail mesh
  49556. * @returns a new mesh
  49557. */
  49558. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49559. /**
  49560. * Serializes this trail mesh
  49561. * @param serializationObject object to write serialization to
  49562. */
  49563. serialize(serializationObject: any): void;
  49564. /**
  49565. * Parses a serialized trail mesh
  49566. * @param parsedMesh the serialized mesh
  49567. * @param scene the scene to create the trail mesh in
  49568. * @returns the created trail mesh
  49569. */
  49570. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49571. }
  49572. }
  49573. declare module BABYLON {
  49574. /**
  49575. * Class containing static functions to help procedurally build meshes
  49576. */
  49577. export class TorusKnotBuilder {
  49578. /**
  49579. * Creates a torus knot mesh
  49580. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49581. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49582. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49583. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49585. * * 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
  49586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49587. * @param name defines the name of the mesh
  49588. * @param options defines the options used to create the mesh
  49589. * @param scene defines the hosting scene
  49590. * @returns the torus knot mesh
  49591. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49592. */
  49593. static CreateTorusKnot(name: string, options: {
  49594. radius?: number;
  49595. tube?: number;
  49596. radialSegments?: number;
  49597. tubularSegments?: number;
  49598. p?: number;
  49599. q?: number;
  49600. updatable?: boolean;
  49601. sideOrientation?: number;
  49602. frontUVs?: Vector4;
  49603. backUVs?: Vector4;
  49604. }, scene: any): Mesh;
  49605. }
  49606. }
  49607. declare module BABYLON {
  49608. /**
  49609. * Polygon
  49610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49611. */
  49612. export class Polygon {
  49613. /**
  49614. * Creates a rectangle
  49615. * @param xmin bottom X coord
  49616. * @param ymin bottom Y coord
  49617. * @param xmax top X coord
  49618. * @param ymax top Y coord
  49619. * @returns points that make the resulting rectation
  49620. */
  49621. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49622. /**
  49623. * Creates a circle
  49624. * @param radius radius of circle
  49625. * @param cx scale in x
  49626. * @param cy scale in y
  49627. * @param numberOfSides number of sides that make up the circle
  49628. * @returns points that make the resulting circle
  49629. */
  49630. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49631. /**
  49632. * Creates a polygon from input string
  49633. * @param input Input polygon data
  49634. * @returns the parsed points
  49635. */
  49636. static Parse(input: string): Vector2[];
  49637. /**
  49638. * Starts building a polygon from x and y coordinates
  49639. * @param x x coordinate
  49640. * @param y y coordinate
  49641. * @returns the started path2
  49642. */
  49643. static StartingAt(x: number, y: number): Path2;
  49644. }
  49645. /**
  49646. * Builds a polygon
  49647. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49648. */
  49649. export class PolygonMeshBuilder {
  49650. private _points;
  49651. private _outlinepoints;
  49652. private _holes;
  49653. private _name;
  49654. private _scene;
  49655. private _epoints;
  49656. private _eholes;
  49657. private _addToepoint;
  49658. /**
  49659. * Babylon reference to the earcut plugin.
  49660. */
  49661. bjsEarcut: any;
  49662. /**
  49663. * Creates a PolygonMeshBuilder
  49664. * @param name name of the builder
  49665. * @param contours Path of the polygon
  49666. * @param scene scene to add to when creating the mesh
  49667. * @param earcutInjection can be used to inject your own earcut reference
  49668. */
  49669. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49670. /**
  49671. * Adds a whole within the polygon
  49672. * @param hole Array of points defining the hole
  49673. * @returns this
  49674. */
  49675. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49676. /**
  49677. * Creates the polygon
  49678. * @param updatable If the mesh should be updatable
  49679. * @param depth The depth of the mesh created
  49680. * @returns the created mesh
  49681. */
  49682. build(updatable?: boolean, depth?: number): Mesh;
  49683. /**
  49684. * Creates the polygon
  49685. * @param depth The depth of the mesh created
  49686. * @returns the created VertexData
  49687. */
  49688. buildVertexData(depth?: number): VertexData;
  49689. /**
  49690. * Adds a side to the polygon
  49691. * @param positions points that make the polygon
  49692. * @param normals normals of the polygon
  49693. * @param uvs uvs of the polygon
  49694. * @param indices indices of the polygon
  49695. * @param bounds bounds of the polygon
  49696. * @param points points of the polygon
  49697. * @param depth depth of the polygon
  49698. * @param flip flip of the polygon
  49699. */
  49700. private addSide;
  49701. }
  49702. }
  49703. declare module BABYLON {
  49704. /**
  49705. * Class containing static functions to help procedurally build meshes
  49706. */
  49707. export class PolygonBuilder {
  49708. /**
  49709. * Creates a polygon mesh
  49710. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49711. * * 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
  49712. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49714. * * 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)
  49715. * * Remember you can only change the shape positions, not their number when updating a polygon
  49716. * @param name defines the name of the mesh
  49717. * @param options defines the options used to create the mesh
  49718. * @param scene defines the hosting scene
  49719. * @param earcutInjection can be used to inject your own earcut reference
  49720. * @returns the polygon mesh
  49721. */
  49722. static CreatePolygon(name: string, options: {
  49723. shape: Vector3[];
  49724. holes?: Vector3[][];
  49725. depth?: number;
  49726. faceUV?: Vector4[];
  49727. faceColors?: Color4[];
  49728. updatable?: boolean;
  49729. sideOrientation?: number;
  49730. frontUVs?: Vector4;
  49731. backUVs?: Vector4;
  49732. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49733. /**
  49734. * Creates an extruded polygon mesh, with depth in the Y direction.
  49735. * * 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)
  49736. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49737. * @param name defines the name of the mesh
  49738. * @param options defines the options used to create the mesh
  49739. * @param scene defines the hosting scene
  49740. * @param earcutInjection can be used to inject your own earcut reference
  49741. * @returns the polygon mesh
  49742. */
  49743. static ExtrudePolygon(name: string, options: {
  49744. shape: Vector3[];
  49745. holes?: Vector3[][];
  49746. depth?: number;
  49747. faceUV?: Vector4[];
  49748. faceColors?: Color4[];
  49749. updatable?: boolean;
  49750. sideOrientation?: number;
  49751. frontUVs?: Vector4;
  49752. backUVs?: Vector4;
  49753. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49754. }
  49755. }
  49756. declare module BABYLON {
  49757. /**
  49758. * Class containing static functions to help procedurally build meshes
  49759. */
  49760. export class LatheBuilder {
  49761. /**
  49762. * Creates lathe mesh.
  49763. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49764. * * 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
  49765. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49766. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49767. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49768. * * 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
  49769. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49770. * * 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
  49771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49772. * * 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
  49773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49775. * @param name defines the name of the mesh
  49776. * @param options defines the options used to create the mesh
  49777. * @param scene defines the hosting scene
  49778. * @returns the lathe mesh
  49779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49780. */
  49781. static CreateLathe(name: string, options: {
  49782. shape: Vector3[];
  49783. radius?: number;
  49784. tessellation?: number;
  49785. clip?: number;
  49786. arc?: number;
  49787. closed?: boolean;
  49788. updatable?: boolean;
  49789. sideOrientation?: number;
  49790. frontUVs?: Vector4;
  49791. backUVs?: Vector4;
  49792. cap?: number;
  49793. invertUV?: boolean;
  49794. }, scene?: Nullable<Scene>): Mesh;
  49795. }
  49796. }
  49797. declare module BABYLON {
  49798. /**
  49799. * Class containing static functions to help procedurally build meshes
  49800. */
  49801. export class TubeBuilder {
  49802. /**
  49803. * Creates a tube mesh.
  49804. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49805. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49806. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49807. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49808. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49809. * * 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)
  49810. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49811. * * 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
  49812. * * 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
  49813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49814. * * 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
  49815. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49817. * @param name defines the name of the mesh
  49818. * @param options defines the options used to create the mesh
  49819. * @param scene defines the hosting scene
  49820. * @returns the tube mesh
  49821. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49822. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49823. */
  49824. static CreateTube(name: string, options: {
  49825. path: Vector3[];
  49826. radius?: number;
  49827. tessellation?: number;
  49828. radiusFunction?: {
  49829. (i: number, distance: number): number;
  49830. };
  49831. cap?: number;
  49832. arc?: number;
  49833. updatable?: boolean;
  49834. sideOrientation?: number;
  49835. frontUVs?: Vector4;
  49836. backUVs?: Vector4;
  49837. instance?: Mesh;
  49838. invertUV?: boolean;
  49839. }, scene?: Nullable<Scene>): Mesh;
  49840. }
  49841. }
  49842. declare module BABYLON {
  49843. /**
  49844. * Class containing static functions to help procedurally build meshes
  49845. */
  49846. export class IcoSphereBuilder {
  49847. /**
  49848. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49849. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49850. * * 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`)
  49851. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49852. * * 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
  49853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49854. * * 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
  49855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49856. * @param name defines the name of the mesh
  49857. * @param options defines the options used to create the mesh
  49858. * @param scene defines the hosting scene
  49859. * @returns the icosahedron mesh
  49860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49861. */
  49862. static CreateIcoSphere(name: string, options: {
  49863. radius?: number;
  49864. radiusX?: number;
  49865. radiusY?: number;
  49866. radiusZ?: number;
  49867. flat?: boolean;
  49868. subdivisions?: number;
  49869. sideOrientation?: number;
  49870. frontUVs?: Vector4;
  49871. backUVs?: Vector4;
  49872. updatable?: boolean;
  49873. }, scene?: Nullable<Scene>): Mesh;
  49874. }
  49875. }
  49876. declare module BABYLON {
  49877. /**
  49878. * Class containing static functions to help procedurally build meshes
  49879. */
  49880. export class DecalBuilder {
  49881. /**
  49882. * Creates a decal mesh.
  49883. * 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
  49884. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49885. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49886. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49887. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49888. * @param name defines the name of the mesh
  49889. * @param sourceMesh defines the mesh where the decal must be applied
  49890. * @param options defines the options used to create the mesh
  49891. * @param scene defines the hosting scene
  49892. * @returns the decal mesh
  49893. * @see https://doc.babylonjs.com/how_to/decals
  49894. */
  49895. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49896. position?: Vector3;
  49897. normal?: Vector3;
  49898. size?: Vector3;
  49899. angle?: number;
  49900. }): Mesh;
  49901. }
  49902. }
  49903. declare module BABYLON {
  49904. /**
  49905. * Class containing static functions to help procedurally build meshes
  49906. */
  49907. export class MeshBuilder {
  49908. /**
  49909. * Creates a box mesh
  49910. * * The parameter `size` sets the size (float) of each box side (default 1)
  49911. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49912. * * 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)
  49913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49915. * * 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
  49916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49918. * @param name defines the name of the mesh
  49919. * @param options defines the options used to create the mesh
  49920. * @param scene defines the hosting scene
  49921. * @returns the box mesh
  49922. */
  49923. static CreateBox(name: string, options: {
  49924. size?: number;
  49925. width?: number;
  49926. height?: number;
  49927. depth?: number;
  49928. faceUV?: Vector4[];
  49929. faceColors?: Color4[];
  49930. sideOrientation?: number;
  49931. frontUVs?: Vector4;
  49932. backUVs?: Vector4;
  49933. updatable?: boolean;
  49934. }, scene?: Nullable<Scene>): Mesh;
  49935. /**
  49936. * Creates a sphere mesh
  49937. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49938. * * 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`)
  49939. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49940. * * 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
  49941. * * 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)
  49942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49943. * * 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
  49944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49945. * @param name defines the name of the mesh
  49946. * @param options defines the options used to create the mesh
  49947. * @param scene defines the hosting scene
  49948. * @returns the sphere mesh
  49949. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49950. */
  49951. static CreateSphere(name: string, options: {
  49952. segments?: number;
  49953. diameter?: number;
  49954. diameterX?: number;
  49955. diameterY?: number;
  49956. diameterZ?: number;
  49957. arc?: number;
  49958. slice?: number;
  49959. sideOrientation?: number;
  49960. frontUVs?: Vector4;
  49961. backUVs?: Vector4;
  49962. updatable?: boolean;
  49963. }, scene?: Nullable<Scene>): Mesh;
  49964. /**
  49965. * Creates a plane polygonal mesh. By default, this is a disc
  49966. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49967. * * 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
  49968. * * 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
  49969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49970. * * 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
  49971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49972. * @param name defines the name of the mesh
  49973. * @param options defines the options used to create the mesh
  49974. * @param scene defines the hosting scene
  49975. * @returns the plane polygonal mesh
  49976. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49977. */
  49978. static CreateDisc(name: string, options: {
  49979. radius?: number;
  49980. tessellation?: number;
  49981. arc?: number;
  49982. updatable?: boolean;
  49983. sideOrientation?: number;
  49984. frontUVs?: Vector4;
  49985. backUVs?: Vector4;
  49986. }, scene?: Nullable<Scene>): Mesh;
  49987. /**
  49988. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49989. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49990. * * 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`)
  49991. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49992. * * 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
  49993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49994. * * 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
  49995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49996. * @param name defines the name of the mesh
  49997. * @param options defines the options used to create the mesh
  49998. * @param scene defines the hosting scene
  49999. * @returns the icosahedron mesh
  50000. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50001. */
  50002. static CreateIcoSphere(name: string, options: {
  50003. radius?: number;
  50004. radiusX?: number;
  50005. radiusY?: number;
  50006. radiusZ?: number;
  50007. flat?: boolean;
  50008. subdivisions?: number;
  50009. sideOrientation?: number;
  50010. frontUVs?: Vector4;
  50011. backUVs?: Vector4;
  50012. updatable?: boolean;
  50013. }, scene?: Nullable<Scene>): Mesh;
  50014. /**
  50015. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50016. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50017. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50018. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50019. * * 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
  50020. * * 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
  50021. * * 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
  50022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50023. * * 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
  50024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50025. * * 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
  50026. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50027. * * 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
  50028. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50030. * @param name defines the name of the mesh
  50031. * @param options defines the options used to create the mesh
  50032. * @param scene defines the hosting scene
  50033. * @returns the ribbon mesh
  50034. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50035. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50036. */
  50037. static CreateRibbon(name: string, options: {
  50038. pathArray: Vector3[][];
  50039. closeArray?: boolean;
  50040. closePath?: boolean;
  50041. offset?: number;
  50042. updatable?: boolean;
  50043. sideOrientation?: number;
  50044. frontUVs?: Vector4;
  50045. backUVs?: Vector4;
  50046. instance?: Mesh;
  50047. invertUV?: boolean;
  50048. uvs?: Vector2[];
  50049. colors?: Color4[];
  50050. }, scene?: Nullable<Scene>): Mesh;
  50051. /**
  50052. * Creates a cylinder or a cone mesh
  50053. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50054. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50055. * * 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.
  50056. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50057. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50058. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50059. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50060. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50061. * * 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).
  50062. * * 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
  50063. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50064. * * 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
  50065. * * 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.
  50066. * * If `enclose` is false, a ring surface is one element.
  50067. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50068. * * 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
  50069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50070. * * 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
  50071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50072. * @param name defines the name of the mesh
  50073. * @param options defines the options used to create the mesh
  50074. * @param scene defines the hosting scene
  50075. * @returns the cylinder mesh
  50076. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50077. */
  50078. static CreateCylinder(name: string, options: {
  50079. height?: number;
  50080. diameterTop?: number;
  50081. diameterBottom?: number;
  50082. diameter?: number;
  50083. tessellation?: number;
  50084. subdivisions?: number;
  50085. arc?: number;
  50086. faceColors?: Color4[];
  50087. faceUV?: Vector4[];
  50088. updatable?: boolean;
  50089. hasRings?: boolean;
  50090. enclose?: boolean;
  50091. sideOrientation?: number;
  50092. frontUVs?: Vector4;
  50093. backUVs?: Vector4;
  50094. }, scene?: Nullable<Scene>): Mesh;
  50095. /**
  50096. * Creates a torus mesh
  50097. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50098. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50099. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50101. * * 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
  50102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50103. * @param name defines the name of the mesh
  50104. * @param options defines the options used to create the mesh
  50105. * @param scene defines the hosting scene
  50106. * @returns the torus mesh
  50107. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50108. */
  50109. static CreateTorus(name: string, options: {
  50110. diameter?: number;
  50111. thickness?: number;
  50112. tessellation?: number;
  50113. updatable?: boolean;
  50114. sideOrientation?: number;
  50115. frontUVs?: Vector4;
  50116. backUVs?: Vector4;
  50117. }, scene?: Nullable<Scene>): Mesh;
  50118. /**
  50119. * Creates a torus knot mesh
  50120. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50121. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50122. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50123. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50125. * * 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
  50126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50127. * @param name defines the name of the mesh
  50128. * @param options defines the options used to create the mesh
  50129. * @param scene defines the hosting scene
  50130. * @returns the torus knot mesh
  50131. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50132. */
  50133. static CreateTorusKnot(name: string, options: {
  50134. radius?: number;
  50135. tube?: number;
  50136. radialSegments?: number;
  50137. tubularSegments?: number;
  50138. p?: number;
  50139. q?: number;
  50140. updatable?: boolean;
  50141. sideOrientation?: number;
  50142. frontUVs?: Vector4;
  50143. backUVs?: Vector4;
  50144. }, scene?: Nullable<Scene>): Mesh;
  50145. /**
  50146. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50147. * * 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
  50148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50149. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50150. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50151. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50152. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50153. * * 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
  50154. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50157. * @param name defines the name of the new line system
  50158. * @param options defines the options used to create the line system
  50159. * @param scene defines the hosting scene
  50160. * @returns a new line system mesh
  50161. */
  50162. static CreateLineSystem(name: string, options: {
  50163. lines: Vector3[][];
  50164. updatable?: boolean;
  50165. instance?: Nullable<LinesMesh>;
  50166. colors?: Nullable<Color4[][]>;
  50167. useVertexAlpha?: boolean;
  50168. }, scene: Nullable<Scene>): LinesMesh;
  50169. /**
  50170. * Creates a line mesh
  50171. * 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
  50172. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50173. * * The parameter `points` is an array successive Vector3
  50174. * * 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
  50175. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50176. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50177. * * When updating an instance, remember that only point positions can change, not the number of points
  50178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50180. * @param name defines the name of the new line system
  50181. * @param options defines the options used to create the line system
  50182. * @param scene defines the hosting scene
  50183. * @returns a new line mesh
  50184. */
  50185. static CreateLines(name: string, options: {
  50186. points: Vector3[];
  50187. updatable?: boolean;
  50188. instance?: Nullable<LinesMesh>;
  50189. colors?: Color4[];
  50190. useVertexAlpha?: boolean;
  50191. }, scene?: Nullable<Scene>): LinesMesh;
  50192. /**
  50193. * Creates a dashed line mesh
  50194. * * 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
  50195. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50196. * * The parameter `points` is an array successive Vector3
  50197. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50198. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50199. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50200. * * 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
  50201. * * When updating an instance, remember that only point positions can change, not the number of points
  50202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50203. * @param name defines the name of the mesh
  50204. * @param options defines the options used to create the mesh
  50205. * @param scene defines the hosting scene
  50206. * @returns the dashed line mesh
  50207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50208. */
  50209. static CreateDashedLines(name: string, options: {
  50210. points: Vector3[];
  50211. dashSize?: number;
  50212. gapSize?: number;
  50213. dashNb?: number;
  50214. updatable?: boolean;
  50215. instance?: LinesMesh;
  50216. }, scene?: Nullable<Scene>): LinesMesh;
  50217. /**
  50218. * 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.
  50219. * * 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.
  50220. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50221. * * 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.
  50222. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50223. * * 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
  50224. * * 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
  50225. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50227. * * 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
  50228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50230. * @param name defines the name of the mesh
  50231. * @param options defines the options used to create the mesh
  50232. * @param scene defines the hosting scene
  50233. * @returns the extruded shape mesh
  50234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50236. */
  50237. static ExtrudeShape(name: string, options: {
  50238. shape: Vector3[];
  50239. path: Vector3[];
  50240. scale?: number;
  50241. rotation?: number;
  50242. cap?: number;
  50243. updatable?: boolean;
  50244. sideOrientation?: number;
  50245. frontUVs?: Vector4;
  50246. backUVs?: Vector4;
  50247. instance?: Mesh;
  50248. invertUV?: boolean;
  50249. }, scene?: Nullable<Scene>): Mesh;
  50250. /**
  50251. * Creates an custom extruded shape mesh.
  50252. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50253. * * 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.
  50254. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50255. * * 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
  50256. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50257. * * 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
  50258. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50259. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50260. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50261. * * 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
  50262. * * 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
  50263. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50268. * @param name defines the name of the mesh
  50269. * @param options defines the options used to create the mesh
  50270. * @param scene defines the hosting scene
  50271. * @returns the custom extruded shape mesh
  50272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50275. */
  50276. static ExtrudeShapeCustom(name: string, options: {
  50277. shape: Vector3[];
  50278. path: Vector3[];
  50279. scaleFunction?: any;
  50280. rotationFunction?: any;
  50281. ribbonCloseArray?: boolean;
  50282. ribbonClosePath?: boolean;
  50283. cap?: number;
  50284. updatable?: boolean;
  50285. sideOrientation?: number;
  50286. frontUVs?: Vector4;
  50287. backUVs?: Vector4;
  50288. instance?: Mesh;
  50289. invertUV?: boolean;
  50290. }, scene?: Nullable<Scene>): Mesh;
  50291. /**
  50292. * Creates lathe mesh.
  50293. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50294. * * 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
  50295. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50296. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50297. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50298. * * 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
  50299. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50300. * * 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
  50301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50302. * * 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
  50303. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50305. * @param name defines the name of the mesh
  50306. * @param options defines the options used to create the mesh
  50307. * @param scene defines the hosting scene
  50308. * @returns the lathe mesh
  50309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50310. */
  50311. static CreateLathe(name: string, options: {
  50312. shape: Vector3[];
  50313. radius?: number;
  50314. tessellation?: number;
  50315. clip?: number;
  50316. arc?: number;
  50317. closed?: boolean;
  50318. updatable?: boolean;
  50319. sideOrientation?: number;
  50320. frontUVs?: Vector4;
  50321. backUVs?: Vector4;
  50322. cap?: number;
  50323. invertUV?: boolean;
  50324. }, scene?: Nullable<Scene>): Mesh;
  50325. /**
  50326. * Creates a plane mesh
  50327. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50328. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50329. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50331. * * 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
  50332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50333. * @param name defines the name of the mesh
  50334. * @param options defines the options used to create the mesh
  50335. * @param scene defines the hosting scene
  50336. * @returns the plane mesh
  50337. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50338. */
  50339. static CreatePlane(name: string, options: {
  50340. size?: number;
  50341. width?: number;
  50342. height?: number;
  50343. sideOrientation?: number;
  50344. frontUVs?: Vector4;
  50345. backUVs?: Vector4;
  50346. updatable?: boolean;
  50347. sourcePlane?: Plane;
  50348. }, scene?: Nullable<Scene>): Mesh;
  50349. /**
  50350. * Creates a ground mesh
  50351. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50352. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50354. * @param name defines the name of the mesh
  50355. * @param options defines the options used to create the mesh
  50356. * @param scene defines the hosting scene
  50357. * @returns the ground mesh
  50358. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50359. */
  50360. static CreateGround(name: string, options: {
  50361. width?: number;
  50362. height?: number;
  50363. subdivisions?: number;
  50364. subdivisionsX?: number;
  50365. subdivisionsY?: number;
  50366. updatable?: boolean;
  50367. }, scene?: Nullable<Scene>): Mesh;
  50368. /**
  50369. * Creates a tiled ground mesh
  50370. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50371. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50372. * * 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
  50373. * * 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
  50374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50375. * @param name defines the name of the mesh
  50376. * @param options defines the options used to create the mesh
  50377. * @param scene defines the hosting scene
  50378. * @returns the tiled ground mesh
  50379. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50380. */
  50381. static CreateTiledGround(name: string, options: {
  50382. xmin: number;
  50383. zmin: number;
  50384. xmax: number;
  50385. zmax: number;
  50386. subdivisions?: {
  50387. w: number;
  50388. h: number;
  50389. };
  50390. precision?: {
  50391. w: number;
  50392. h: number;
  50393. };
  50394. updatable?: boolean;
  50395. }, scene?: Nullable<Scene>): Mesh;
  50396. /**
  50397. * Creates a ground mesh from a height map
  50398. * * The parameter `url` sets the URL of the height map image resource.
  50399. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50400. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50401. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50402. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50403. * * 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.
  50404. * * 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).
  50405. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50407. * @param name defines the name of the mesh
  50408. * @param url defines the url to the height map
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the ground mesh
  50412. * @see https://doc.babylonjs.com/babylon101/height_map
  50413. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50414. */
  50415. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50416. width?: number;
  50417. height?: number;
  50418. subdivisions?: number;
  50419. minHeight?: number;
  50420. maxHeight?: number;
  50421. colorFilter?: Color3;
  50422. alphaFilter?: number;
  50423. updatable?: boolean;
  50424. onReady?: (mesh: GroundMesh) => void;
  50425. }, scene?: Nullable<Scene>): GroundMesh;
  50426. /**
  50427. * Creates a polygon mesh
  50428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50429. * * 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
  50430. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50432. * * 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)
  50433. * * Remember you can only change the shape positions, not their number when updating a polygon
  50434. * @param name defines the name of the mesh
  50435. * @param options defines the options used to create the mesh
  50436. * @param scene defines the hosting scene
  50437. * @param earcutInjection can be used to inject your own earcut reference
  50438. * @returns the polygon mesh
  50439. */
  50440. static CreatePolygon(name: string, options: {
  50441. shape: Vector3[];
  50442. holes?: Vector3[][];
  50443. depth?: number;
  50444. faceUV?: Vector4[];
  50445. faceColors?: Color4[];
  50446. updatable?: boolean;
  50447. sideOrientation?: number;
  50448. frontUVs?: Vector4;
  50449. backUVs?: Vector4;
  50450. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50451. /**
  50452. * Creates an extruded polygon mesh, with depth in the Y direction.
  50453. * * 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)
  50454. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50455. * @param name defines the name of the mesh
  50456. * @param options defines the options used to create the mesh
  50457. * @param scene defines the hosting scene
  50458. * @param earcutInjection can be used to inject your own earcut reference
  50459. * @returns the polygon mesh
  50460. */
  50461. static ExtrudePolygon(name: string, options: {
  50462. shape: Vector3[];
  50463. holes?: Vector3[][];
  50464. depth?: number;
  50465. faceUV?: Vector4[];
  50466. faceColors?: Color4[];
  50467. updatable?: boolean;
  50468. sideOrientation?: number;
  50469. frontUVs?: Vector4;
  50470. backUVs?: Vector4;
  50471. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50472. /**
  50473. * Creates a tube mesh.
  50474. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50475. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50476. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50477. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50478. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50479. * * 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)
  50480. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50481. * * 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
  50482. * * 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
  50483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50484. * * 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
  50485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50487. * @param name defines the name of the mesh
  50488. * @param options defines the options used to create the mesh
  50489. * @param scene defines the hosting scene
  50490. * @returns the tube mesh
  50491. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50492. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50493. */
  50494. static CreateTube(name: string, options: {
  50495. path: Vector3[];
  50496. radius?: number;
  50497. tessellation?: number;
  50498. radiusFunction?: {
  50499. (i: number, distance: number): number;
  50500. };
  50501. cap?: number;
  50502. arc?: number;
  50503. updatable?: boolean;
  50504. sideOrientation?: number;
  50505. frontUVs?: Vector4;
  50506. backUVs?: Vector4;
  50507. instance?: Mesh;
  50508. invertUV?: boolean;
  50509. }, scene?: Nullable<Scene>): Mesh;
  50510. /**
  50511. * Creates a polyhedron mesh
  50512. * * 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
  50513. * * The parameter `size` (positive float, default 1) sets the polygon size
  50514. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50515. * * 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`
  50516. * * 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
  50517. * * 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)`)
  50518. * * 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
  50519. * * 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
  50520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50521. * * 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
  50522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50523. * @param name defines the name of the mesh
  50524. * @param options defines the options used to create the mesh
  50525. * @param scene defines the hosting scene
  50526. * @returns the polyhedron mesh
  50527. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50528. */
  50529. static CreatePolyhedron(name: string, options: {
  50530. type?: number;
  50531. size?: number;
  50532. sizeX?: number;
  50533. sizeY?: number;
  50534. sizeZ?: number;
  50535. custom?: any;
  50536. faceUV?: Vector4[];
  50537. faceColors?: Color4[];
  50538. flat?: boolean;
  50539. updatable?: boolean;
  50540. sideOrientation?: number;
  50541. frontUVs?: Vector4;
  50542. backUVs?: Vector4;
  50543. }, scene?: Nullable<Scene>): Mesh;
  50544. /**
  50545. * Creates a decal mesh.
  50546. * 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
  50547. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50548. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50549. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50550. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50551. * @param name defines the name of the mesh
  50552. * @param sourceMesh defines the mesh where the decal must be applied
  50553. * @param options defines the options used to create the mesh
  50554. * @param scene defines the hosting scene
  50555. * @returns the decal mesh
  50556. * @see https://doc.babylonjs.com/how_to/decals
  50557. */
  50558. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50559. position?: Vector3;
  50560. normal?: Vector3;
  50561. size?: Vector3;
  50562. angle?: number;
  50563. }): Mesh;
  50564. }
  50565. }
  50566. declare module BABYLON {
  50567. /**
  50568. * A simplifier interface for future simplification implementations
  50569. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50570. */
  50571. export interface ISimplifier {
  50572. /**
  50573. * Simplification of a given mesh according to the given settings.
  50574. * Since this requires computation, it is assumed that the function runs async.
  50575. * @param settings The settings of the simplification, including quality and distance
  50576. * @param successCallback A callback that will be called after the mesh was simplified.
  50577. * @param errorCallback in case of an error, this callback will be called. optional.
  50578. */
  50579. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50580. }
  50581. /**
  50582. * Expected simplification settings.
  50583. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50584. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50585. */
  50586. export interface ISimplificationSettings {
  50587. /**
  50588. * Gets or sets the expected quality
  50589. */
  50590. quality: number;
  50591. /**
  50592. * Gets or sets the distance when this optimized version should be used
  50593. */
  50594. distance: number;
  50595. /**
  50596. * Gets an already optimized mesh
  50597. */
  50598. optimizeMesh?: boolean;
  50599. }
  50600. /**
  50601. * Class used to specify simplification options
  50602. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50603. */
  50604. export class SimplificationSettings implements ISimplificationSettings {
  50605. /** expected quality */
  50606. quality: number;
  50607. /** distance when this optimized version should be used */
  50608. distance: number;
  50609. /** already optimized mesh */
  50610. optimizeMesh?: boolean | undefined;
  50611. /**
  50612. * Creates a SimplificationSettings
  50613. * @param quality expected quality
  50614. * @param distance distance when this optimized version should be used
  50615. * @param optimizeMesh already optimized mesh
  50616. */
  50617. constructor(
  50618. /** expected quality */
  50619. quality: number,
  50620. /** distance when this optimized version should be used */
  50621. distance: number,
  50622. /** already optimized mesh */
  50623. optimizeMesh?: boolean | undefined);
  50624. }
  50625. /**
  50626. * Interface used to define a simplification task
  50627. */
  50628. export interface ISimplificationTask {
  50629. /**
  50630. * Array of settings
  50631. */
  50632. settings: Array<ISimplificationSettings>;
  50633. /**
  50634. * Simplification type
  50635. */
  50636. simplificationType: SimplificationType;
  50637. /**
  50638. * Mesh to simplify
  50639. */
  50640. mesh: Mesh;
  50641. /**
  50642. * Callback called on success
  50643. */
  50644. successCallback?: () => void;
  50645. /**
  50646. * Defines if parallel processing can be used
  50647. */
  50648. parallelProcessing: boolean;
  50649. }
  50650. /**
  50651. * Queue used to order the simplification tasks
  50652. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50653. */
  50654. export class SimplificationQueue {
  50655. private _simplificationArray;
  50656. /**
  50657. * Gets a boolean indicating that the process is still running
  50658. */
  50659. running: boolean;
  50660. /**
  50661. * Creates a new queue
  50662. */
  50663. constructor();
  50664. /**
  50665. * Adds a new simplification task
  50666. * @param task defines a task to add
  50667. */
  50668. addTask(task: ISimplificationTask): void;
  50669. /**
  50670. * Execute next task
  50671. */
  50672. executeNext(): void;
  50673. /**
  50674. * Execute a simplification task
  50675. * @param task defines the task to run
  50676. */
  50677. runSimplification(task: ISimplificationTask): void;
  50678. private getSimplifier;
  50679. }
  50680. /**
  50681. * The implemented types of simplification
  50682. * At the moment only Quadratic Error Decimation is implemented
  50683. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50684. */
  50685. export enum SimplificationType {
  50686. /** Quadratic error decimation */
  50687. QUADRATIC = 0
  50688. }
  50689. }
  50690. declare module BABYLON {
  50691. interface Scene {
  50692. /** @hidden (Backing field) */
  50693. _simplificationQueue: SimplificationQueue;
  50694. /**
  50695. * Gets or sets the simplification queue attached to the scene
  50696. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50697. */
  50698. simplificationQueue: SimplificationQueue;
  50699. }
  50700. interface Mesh {
  50701. /**
  50702. * Simplify the mesh according to the given array of settings.
  50703. * Function will return immediately and will simplify async
  50704. * @param settings a collection of simplification settings
  50705. * @param parallelProcessing should all levels calculate parallel or one after the other
  50706. * @param simplificationType the type of simplification to run
  50707. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50708. * @returns the current mesh
  50709. */
  50710. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50711. }
  50712. /**
  50713. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50714. * created in a scene
  50715. */
  50716. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50717. /**
  50718. * The component name helpfull to identify the component in the list of scene components.
  50719. */
  50720. readonly name: string;
  50721. /**
  50722. * The scene the component belongs to.
  50723. */
  50724. scene: Scene;
  50725. /**
  50726. * Creates a new instance of the component for the given scene
  50727. * @param scene Defines the scene to register the component in
  50728. */
  50729. constructor(scene: Scene);
  50730. /**
  50731. * Registers the component in a given scene
  50732. */
  50733. register(): void;
  50734. /**
  50735. * Rebuilds the elements related to this component in case of
  50736. * context lost for instance.
  50737. */
  50738. rebuild(): void;
  50739. /**
  50740. * Disposes the component and the associated ressources
  50741. */
  50742. dispose(): void;
  50743. private _beforeCameraUpdate;
  50744. }
  50745. }
  50746. declare module BABYLON {
  50747. /**
  50748. * Class used to enable access to IndexedDB
  50749. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50750. */
  50751. export class Database implements IOfflineProvider {
  50752. private _callbackManifestChecked;
  50753. private _currentSceneUrl;
  50754. private _db;
  50755. private _enableSceneOffline;
  50756. private _enableTexturesOffline;
  50757. private _manifestVersionFound;
  50758. private _mustUpdateRessources;
  50759. private _hasReachedQuota;
  50760. private _isSupported;
  50761. private _idbFactory;
  50762. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50763. private static IsUASupportingBlobStorage;
  50764. /**
  50765. * Gets a boolean indicating if Database storate is enabled (off by default)
  50766. */
  50767. static IDBStorageEnabled: boolean;
  50768. /**
  50769. * Gets a boolean indicating if scene must be saved in the database
  50770. */
  50771. readonly enableSceneOffline: boolean;
  50772. /**
  50773. * Gets a boolean indicating if textures must be saved in the database
  50774. */
  50775. readonly enableTexturesOffline: boolean;
  50776. /**
  50777. * Creates a new Database
  50778. * @param urlToScene defines the url to load the scene
  50779. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50780. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50781. */
  50782. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50783. private static _ParseURL;
  50784. private static _ReturnFullUrlLocation;
  50785. private _checkManifestFile;
  50786. /**
  50787. * Open the database and make it available
  50788. * @param successCallback defines the callback to call on success
  50789. * @param errorCallback defines the callback to call on error
  50790. */
  50791. open(successCallback: () => void, errorCallback: () => void): void;
  50792. /**
  50793. * Loads an image from the database
  50794. * @param url defines the url to load from
  50795. * @param image defines the target DOM image
  50796. */
  50797. loadImage(url: string, image: HTMLImageElement): void;
  50798. private _loadImageFromDBAsync;
  50799. private _saveImageIntoDBAsync;
  50800. private _checkVersionFromDB;
  50801. private _loadVersionFromDBAsync;
  50802. private _saveVersionIntoDBAsync;
  50803. /**
  50804. * Loads a file from database
  50805. * @param url defines the URL to load from
  50806. * @param sceneLoaded defines a callback to call on success
  50807. * @param progressCallBack defines a callback to call when progress changed
  50808. * @param errorCallback defines a callback to call on error
  50809. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50810. */
  50811. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50812. private _loadFileAsync;
  50813. private _saveFileAsync;
  50814. /**
  50815. * Validates if xhr data is correct
  50816. * @param xhr defines the request to validate
  50817. * @param dataType defines the expected data type
  50818. * @returns true if data is correct
  50819. */
  50820. private static _ValidateXHRData;
  50821. }
  50822. }
  50823. declare module BABYLON {
  50824. /** @hidden */
  50825. export var gpuUpdateParticlesPixelShader: {
  50826. name: string;
  50827. shader: string;
  50828. };
  50829. }
  50830. declare module BABYLON {
  50831. /** @hidden */
  50832. export var gpuUpdateParticlesVertexShader: {
  50833. name: string;
  50834. shader: string;
  50835. };
  50836. }
  50837. declare module BABYLON {
  50838. /** @hidden */
  50839. export var clipPlaneFragmentDeclaration2: {
  50840. name: string;
  50841. shader: string;
  50842. };
  50843. }
  50844. declare module BABYLON {
  50845. /** @hidden */
  50846. export var gpuRenderParticlesPixelShader: {
  50847. name: string;
  50848. shader: string;
  50849. };
  50850. }
  50851. declare module BABYLON {
  50852. /** @hidden */
  50853. export var clipPlaneVertexDeclaration2: {
  50854. name: string;
  50855. shader: string;
  50856. };
  50857. }
  50858. declare module BABYLON {
  50859. /** @hidden */
  50860. export var gpuRenderParticlesVertexShader: {
  50861. name: string;
  50862. shader: string;
  50863. };
  50864. }
  50865. declare module BABYLON {
  50866. /**
  50867. * This represents a GPU particle system in Babylon
  50868. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50869. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50870. */
  50871. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50872. /**
  50873. * The layer mask we are rendering the particles through.
  50874. */
  50875. layerMask: number;
  50876. private _capacity;
  50877. private _activeCount;
  50878. private _currentActiveCount;
  50879. private _accumulatedCount;
  50880. private _renderEffect;
  50881. private _updateEffect;
  50882. private _buffer0;
  50883. private _buffer1;
  50884. private _spriteBuffer;
  50885. private _updateVAO;
  50886. private _renderVAO;
  50887. private _targetIndex;
  50888. private _sourceBuffer;
  50889. private _targetBuffer;
  50890. private _engine;
  50891. private _currentRenderId;
  50892. private _started;
  50893. private _stopped;
  50894. private _timeDelta;
  50895. private _randomTexture;
  50896. private _randomTexture2;
  50897. private _attributesStrideSize;
  50898. private _updateEffectOptions;
  50899. private _randomTextureSize;
  50900. private _actualFrame;
  50901. private readonly _rawTextureWidth;
  50902. /**
  50903. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50904. */
  50905. static readonly IsSupported: boolean;
  50906. /**
  50907. * An event triggered when the system is disposed.
  50908. */
  50909. onDisposeObservable: Observable<GPUParticleSystem>;
  50910. /**
  50911. * Gets the maximum number of particles active at the same time.
  50912. * @returns The max number of active particles.
  50913. */
  50914. getCapacity(): number;
  50915. /**
  50916. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50917. * to override the particles.
  50918. */
  50919. forceDepthWrite: boolean;
  50920. /**
  50921. * Gets or set the number of active particles
  50922. */
  50923. activeParticleCount: number;
  50924. private _preWarmDone;
  50925. /**
  50926. * Is this system ready to be used/rendered
  50927. * @return true if the system is ready
  50928. */
  50929. isReady(): boolean;
  50930. /**
  50931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50932. * @returns True if it has been started, otherwise false.
  50933. */
  50934. isStarted(): boolean;
  50935. /**
  50936. * Starts the particle system and begins to emit
  50937. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50938. */
  50939. start(delay?: number): void;
  50940. /**
  50941. * Stops the particle system.
  50942. */
  50943. stop(): void;
  50944. /**
  50945. * Remove all active particles
  50946. */
  50947. reset(): void;
  50948. /**
  50949. * Returns the string "GPUParticleSystem"
  50950. * @returns a string containing the class name
  50951. */
  50952. getClassName(): string;
  50953. private _colorGradientsTexture;
  50954. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50955. /**
  50956. * Adds a new color gradient
  50957. * @param gradient defines the gradient to use (between 0 and 1)
  50958. * @param color1 defines the color to affect to the specified gradient
  50959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50960. * @returns the current particle system
  50961. */
  50962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50963. /**
  50964. * Remove a specific color gradient
  50965. * @param gradient defines the gradient to remove
  50966. * @returns the current particle system
  50967. */
  50968. removeColorGradient(gradient: number): GPUParticleSystem;
  50969. private _angularSpeedGradientsTexture;
  50970. private _sizeGradientsTexture;
  50971. private _velocityGradientsTexture;
  50972. private _limitVelocityGradientsTexture;
  50973. private _dragGradientsTexture;
  50974. private _addFactorGradient;
  50975. /**
  50976. * Adds a new size gradient
  50977. * @param gradient defines the gradient to use (between 0 and 1)
  50978. * @param factor defines the size factor to affect to the specified gradient
  50979. * @returns the current particle system
  50980. */
  50981. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50982. /**
  50983. * Remove a specific size gradient
  50984. * @param gradient defines the gradient to remove
  50985. * @returns the current particle system
  50986. */
  50987. removeSizeGradient(gradient: number): GPUParticleSystem;
  50988. /**
  50989. * Adds a new angular speed gradient
  50990. * @param gradient defines the gradient to use (between 0 and 1)
  50991. * @param factor defines the angular speed to affect to the specified gradient
  50992. * @returns the current particle system
  50993. */
  50994. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50995. /**
  50996. * Remove a specific angular speed gradient
  50997. * @param gradient defines the gradient to remove
  50998. * @returns the current particle system
  50999. */
  51000. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51001. /**
  51002. * Adds a new velocity gradient
  51003. * @param gradient defines the gradient to use (between 0 and 1)
  51004. * @param factor defines the velocity to affect to the specified gradient
  51005. * @returns the current particle system
  51006. */
  51007. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51008. /**
  51009. * Remove a specific velocity gradient
  51010. * @param gradient defines the gradient to remove
  51011. * @returns the current particle system
  51012. */
  51013. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51014. /**
  51015. * Adds a new limit velocity gradient
  51016. * @param gradient defines the gradient to use (between 0 and 1)
  51017. * @param factor defines the limit velocity value to affect to the specified gradient
  51018. * @returns the current particle system
  51019. */
  51020. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51021. /**
  51022. * Remove a specific limit velocity gradient
  51023. * @param gradient defines the gradient to remove
  51024. * @returns the current particle system
  51025. */
  51026. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51027. /**
  51028. * Adds a new drag gradient
  51029. * @param gradient defines the gradient to use (between 0 and 1)
  51030. * @param factor defines the drag value to affect to the specified gradient
  51031. * @returns the current particle system
  51032. */
  51033. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51034. /**
  51035. * Remove a specific drag gradient
  51036. * @param gradient defines the gradient to remove
  51037. * @returns the current particle system
  51038. */
  51039. removeDragGradient(gradient: number): GPUParticleSystem;
  51040. /**
  51041. * Not supported by GPUParticleSystem
  51042. * @param gradient defines the gradient to use (between 0 and 1)
  51043. * @param factor defines the emit rate value to affect to the specified gradient
  51044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51045. * @returns the current particle system
  51046. */
  51047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51048. /**
  51049. * Not supported by GPUParticleSystem
  51050. * @param gradient defines the gradient to remove
  51051. * @returns the current particle system
  51052. */
  51053. removeEmitRateGradient(gradient: number): IParticleSystem;
  51054. /**
  51055. * Not supported by GPUParticleSystem
  51056. * @param gradient defines the gradient to use (between 0 and 1)
  51057. * @param factor defines the start size value to affect to the specified gradient
  51058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51059. * @returns the current particle system
  51060. */
  51061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51062. /**
  51063. * Not supported by GPUParticleSystem
  51064. * @param gradient defines the gradient to remove
  51065. * @returns the current particle system
  51066. */
  51067. removeStartSizeGradient(gradient: number): IParticleSystem;
  51068. /**
  51069. * Not supported by GPUParticleSystem
  51070. * @param gradient defines the gradient to use (between 0 and 1)
  51071. * @param min defines the color remap minimal range
  51072. * @param max defines the color remap maximal range
  51073. * @returns the current particle system
  51074. */
  51075. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51076. /**
  51077. * Not supported by GPUParticleSystem
  51078. * @param gradient defines the gradient to remove
  51079. * @returns the current particle system
  51080. */
  51081. removeColorRemapGradient(): IParticleSystem;
  51082. /**
  51083. * Not supported by GPUParticleSystem
  51084. * @param gradient defines the gradient to use (between 0 and 1)
  51085. * @param min defines the alpha remap minimal range
  51086. * @param max defines the alpha remap maximal range
  51087. * @returns the current particle system
  51088. */
  51089. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51090. /**
  51091. * Not supported by GPUParticleSystem
  51092. * @param gradient defines the gradient to remove
  51093. * @returns the current particle system
  51094. */
  51095. removeAlphaRemapGradient(): IParticleSystem;
  51096. /**
  51097. * Not supported by GPUParticleSystem
  51098. * @param gradient defines the gradient to use (between 0 and 1)
  51099. * @param color defines the color to affect to the specified gradient
  51100. * @returns the current particle system
  51101. */
  51102. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51103. /**
  51104. * Not supported by GPUParticleSystem
  51105. * @param gradient defines the gradient to remove
  51106. * @returns the current particle system
  51107. */
  51108. removeRampGradient(): IParticleSystem;
  51109. /**
  51110. * Not supported by GPUParticleSystem
  51111. * @returns the list of ramp gradients
  51112. */
  51113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51114. /**
  51115. * Not supported by GPUParticleSystem
  51116. * Gets or sets a boolean indicating that ramp gradients must be used
  51117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51118. */
  51119. useRampGradients: boolean;
  51120. /**
  51121. * Not supported by GPUParticleSystem
  51122. * @param gradient defines the gradient to use (between 0 and 1)
  51123. * @param factor defines the life time factor to affect to the specified gradient
  51124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51125. * @returns the current particle system
  51126. */
  51127. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51128. /**
  51129. * Not supported by GPUParticleSystem
  51130. * @param gradient defines the gradient to remove
  51131. * @returns the current particle system
  51132. */
  51133. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51134. /**
  51135. * Instantiates a GPU particle system.
  51136. * 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.
  51137. * @param name The name of the particle system
  51138. * @param options The options used to create the system
  51139. * @param scene The scene the particle system belongs to
  51140. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51141. */
  51142. constructor(name: string, options: Partial<{
  51143. capacity: number;
  51144. randomTextureSize: number;
  51145. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51146. protected _reset(): void;
  51147. private _createUpdateVAO;
  51148. private _createRenderVAO;
  51149. private _initialize;
  51150. /** @hidden */
  51151. _recreateUpdateEffect(): void;
  51152. /** @hidden */
  51153. _recreateRenderEffect(): void;
  51154. /**
  51155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51156. * @param preWarm defines if we are in the pre-warmimg phase
  51157. */
  51158. animate(preWarm?: boolean): void;
  51159. private _createFactorGradientTexture;
  51160. private _createSizeGradientTexture;
  51161. private _createAngularSpeedGradientTexture;
  51162. private _createVelocityGradientTexture;
  51163. private _createLimitVelocityGradientTexture;
  51164. private _createDragGradientTexture;
  51165. private _createColorGradientTexture;
  51166. /**
  51167. * Renders the particle system in its current state
  51168. * @param preWarm defines if the system should only update the particles but not render them
  51169. * @returns the current number of particles
  51170. */
  51171. render(preWarm?: boolean): number;
  51172. /**
  51173. * Rebuilds the particle system
  51174. */
  51175. rebuild(): void;
  51176. private _releaseBuffers;
  51177. private _releaseVAOs;
  51178. /**
  51179. * Disposes the particle system and free the associated resources
  51180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51181. */
  51182. dispose(disposeTexture?: boolean): void;
  51183. /**
  51184. * Clones the particle system.
  51185. * @param name The name of the cloned object
  51186. * @param newEmitter The new emitter to use
  51187. * @returns the cloned particle system
  51188. */
  51189. clone(name: string, newEmitter: any): GPUParticleSystem;
  51190. /**
  51191. * Serializes the particle system to a JSON object.
  51192. * @returns the JSON object
  51193. */
  51194. serialize(): any;
  51195. /**
  51196. * Parses a JSON object to create a GPU particle system.
  51197. * @param parsedParticleSystem The JSON object to parse
  51198. * @param scene The scene to create the particle system in
  51199. * @param rootUrl The root url to use to load external dependencies like texture
  51200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51201. * @returns the parsed GPU particle system
  51202. */
  51203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51204. }
  51205. }
  51206. declare module BABYLON {
  51207. /**
  51208. * Represents a set of particle systems working together to create a specific effect
  51209. */
  51210. export class ParticleSystemSet implements IDisposable {
  51211. private _emitterCreationOptions;
  51212. private _emitterNode;
  51213. /**
  51214. * Gets the particle system list
  51215. */
  51216. systems: IParticleSystem[];
  51217. /**
  51218. * Gets the emitter node used with this set
  51219. */
  51220. readonly emitterNode: Nullable<TransformNode>;
  51221. /**
  51222. * Creates a new emitter mesh as a sphere
  51223. * @param options defines the options used to create the sphere
  51224. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51225. * @param scene defines the hosting scene
  51226. */
  51227. setEmitterAsSphere(options: {
  51228. diameter: number;
  51229. segments: number;
  51230. color: Color3;
  51231. }, renderingGroupId: number, scene: Scene): void;
  51232. /**
  51233. * Starts all particle systems of the set
  51234. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51235. */
  51236. start(emitter?: AbstractMesh): void;
  51237. /**
  51238. * Release all associated resources
  51239. */
  51240. dispose(): void;
  51241. /**
  51242. * Serialize the set into a JSON compatible object
  51243. * @returns a JSON compatible representation of the set
  51244. */
  51245. serialize(): any;
  51246. /**
  51247. * Parse a new ParticleSystemSet from a serialized source
  51248. * @param data defines a JSON compatible representation of the set
  51249. * @param scene defines the hosting scene
  51250. * @param gpu defines if we want GPU particles or CPU particles
  51251. * @returns a new ParticleSystemSet
  51252. */
  51253. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51254. }
  51255. }
  51256. declare module BABYLON {
  51257. /**
  51258. * This class is made for on one-liner static method to help creating particle system set.
  51259. */
  51260. export class ParticleHelper {
  51261. /**
  51262. * Gets or sets base Assets URL
  51263. */
  51264. static BaseAssetsUrl: string;
  51265. /**
  51266. * Create a default particle system that you can tweak
  51267. * @param emitter defines the emitter to use
  51268. * @param capacity defines the system capacity (default is 500 particles)
  51269. * @param scene defines the hosting scene
  51270. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51271. * @returns the new Particle system
  51272. */
  51273. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51274. /**
  51275. * This is the main static method (one-liner) of this helper to create different particle systems
  51276. * @param type This string represents the type to the particle system to create
  51277. * @param scene The scene where the particle system should live
  51278. * @param gpu If the system will use gpu
  51279. * @returns the ParticleSystemSet created
  51280. */
  51281. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51282. /**
  51283. * Static function used to export a particle system to a ParticleSystemSet variable.
  51284. * Please note that the emitter shape is not exported
  51285. * @param systems defines the particle systems to export
  51286. * @returns the created particle system set
  51287. */
  51288. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51289. }
  51290. }
  51291. declare module BABYLON {
  51292. interface Engine {
  51293. /**
  51294. * Create an effect to use with particle systems.
  51295. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51296. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51297. * @param uniformsNames defines a list of attribute names
  51298. * @param samplers defines an array of string used to represent textures
  51299. * @param defines defines the string containing the defines to use to compile the shaders
  51300. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51301. * @param onCompiled defines a function to call when the effect creation is successful
  51302. * @param onError defines a function to call when the effect creation has failed
  51303. * @returns the new Effect
  51304. */
  51305. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51306. }
  51307. interface Mesh {
  51308. /**
  51309. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51310. * @returns an array of IParticleSystem
  51311. */
  51312. getEmittedParticleSystems(): IParticleSystem[];
  51313. /**
  51314. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51315. * @returns an array of IParticleSystem
  51316. */
  51317. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51318. }
  51319. /**
  51320. * @hidden
  51321. */
  51322. export var _IDoNeedToBeInTheBuild: number;
  51323. }
  51324. declare module BABYLON {
  51325. interface Scene {
  51326. /** @hidden (Backing field) */
  51327. _physicsEngine: Nullable<IPhysicsEngine>;
  51328. /**
  51329. * Gets the current physics engine
  51330. * @returns a IPhysicsEngine or null if none attached
  51331. */
  51332. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51333. /**
  51334. * Enables physics to the current scene
  51335. * @param gravity defines the scene's gravity for the physics engine
  51336. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51337. * @return a boolean indicating if the physics engine was initialized
  51338. */
  51339. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51340. /**
  51341. * Disables and disposes the physics engine associated with the scene
  51342. */
  51343. disablePhysicsEngine(): void;
  51344. /**
  51345. * Gets a boolean indicating if there is an active physics engine
  51346. * @returns a boolean indicating if there is an active physics engine
  51347. */
  51348. isPhysicsEnabled(): boolean;
  51349. /**
  51350. * Deletes a physics compound impostor
  51351. * @param compound defines the compound to delete
  51352. */
  51353. deleteCompoundImpostor(compound: any): void;
  51354. /**
  51355. * An event triggered when physic simulation is about to be run
  51356. */
  51357. onBeforePhysicsObservable: Observable<Scene>;
  51358. /**
  51359. * An event triggered when physic simulation has been done
  51360. */
  51361. onAfterPhysicsObservable: Observable<Scene>;
  51362. }
  51363. interface AbstractMesh {
  51364. /** @hidden */
  51365. _physicsImpostor: Nullable<PhysicsImpostor>;
  51366. /**
  51367. * Gets or sets impostor used for physic simulation
  51368. * @see http://doc.babylonjs.com/features/physics_engine
  51369. */
  51370. physicsImpostor: Nullable<PhysicsImpostor>;
  51371. /**
  51372. * Gets the current physics impostor
  51373. * @see http://doc.babylonjs.com/features/physics_engine
  51374. * @returns a physics impostor or null
  51375. */
  51376. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51377. /** Apply a physic impulse to the mesh
  51378. * @param force defines the force to apply
  51379. * @param contactPoint defines where to apply the force
  51380. * @returns the current mesh
  51381. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51382. */
  51383. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51384. /**
  51385. * Creates a physic joint between two meshes
  51386. * @param otherMesh defines the other mesh to use
  51387. * @param pivot1 defines the pivot to use on this mesh
  51388. * @param pivot2 defines the pivot to use on the other mesh
  51389. * @param options defines additional options (can be plugin dependent)
  51390. * @returns the current mesh
  51391. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51392. */
  51393. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51394. /** @hidden */
  51395. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51396. }
  51397. /**
  51398. * Defines the physics engine scene component responsible to manage a physics engine
  51399. */
  51400. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51401. /**
  51402. * The component name helpful to identify the component in the list of scene components.
  51403. */
  51404. readonly name: string;
  51405. /**
  51406. * The scene the component belongs to.
  51407. */
  51408. scene: Scene;
  51409. /**
  51410. * Creates a new instance of the component for the given scene
  51411. * @param scene Defines the scene to register the component in
  51412. */
  51413. constructor(scene: Scene);
  51414. /**
  51415. * Registers the component in a given scene
  51416. */
  51417. register(): void;
  51418. /**
  51419. * Rebuilds the elements related to this component in case of
  51420. * context lost for instance.
  51421. */
  51422. rebuild(): void;
  51423. /**
  51424. * Disposes the component and the associated ressources
  51425. */
  51426. dispose(): void;
  51427. }
  51428. }
  51429. declare module BABYLON {
  51430. /**
  51431. * A helper for physics simulations
  51432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51433. */
  51434. export class PhysicsHelper {
  51435. private _scene;
  51436. private _physicsEngine;
  51437. /**
  51438. * Initializes the Physics helper
  51439. * @param scene Babylon.js scene
  51440. */
  51441. constructor(scene: Scene);
  51442. /**
  51443. * Applies a radial explosion impulse
  51444. * @param origin the origin of the explosion
  51445. * @param radiusOrEventOptions the radius or the options of radial explosion
  51446. * @param strength the explosion strength
  51447. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51448. * @returns A physics radial explosion event, or null
  51449. */
  51450. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51451. /**
  51452. * Applies a radial explosion force
  51453. * @param origin the origin of the explosion
  51454. * @param radiusOrEventOptions the radius or the options of radial explosion
  51455. * @param strength the explosion strength
  51456. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51457. * @returns A physics radial explosion event, or null
  51458. */
  51459. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51460. /**
  51461. * Creates a gravitational field
  51462. * @param origin the origin of the explosion
  51463. * @param radiusOrEventOptions the radius or the options of radial explosion
  51464. * @param strength the explosion strength
  51465. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51466. * @returns A physics gravitational field event, or null
  51467. */
  51468. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51469. /**
  51470. * Creates a physics updraft event
  51471. * @param origin the origin of the updraft
  51472. * @param radiusOrEventOptions the radius or the options of the updraft
  51473. * @param strength the strength of the updraft
  51474. * @param height the height of the updraft
  51475. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51476. * @returns A physics updraft event, or null
  51477. */
  51478. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51479. /**
  51480. * Creates a physics vortex event
  51481. * @param origin the of the vortex
  51482. * @param radiusOrEventOptions the radius or the options of the vortex
  51483. * @param strength the strength of the vortex
  51484. * @param height the height of the vortex
  51485. * @returns a Physics vortex event, or null
  51486. * A physics vortex event or null
  51487. */
  51488. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51489. }
  51490. /**
  51491. * Represents a physics radial explosion event
  51492. */
  51493. class PhysicsRadialExplosionEvent {
  51494. private _scene;
  51495. private _options;
  51496. private _sphere;
  51497. private _dataFetched;
  51498. /**
  51499. * Initializes a radial explosioin event
  51500. * @param _scene BabylonJS scene
  51501. * @param _options The options for the vortex event
  51502. */
  51503. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51504. /**
  51505. * Returns the data related to the radial explosion event (sphere).
  51506. * @returns The radial explosion event data
  51507. */
  51508. getData(): PhysicsRadialExplosionEventData;
  51509. /**
  51510. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51511. * @param impostor A physics imposter
  51512. * @param origin the origin of the explosion
  51513. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51514. */
  51515. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51516. /**
  51517. * Triggers affecterd impostors callbacks
  51518. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51519. */
  51520. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51521. /**
  51522. * Disposes the sphere.
  51523. * @param force Specifies if the sphere should be disposed by force
  51524. */
  51525. dispose(force?: boolean): void;
  51526. /*** Helpers ***/
  51527. private _prepareSphere;
  51528. private _intersectsWithSphere;
  51529. }
  51530. /**
  51531. * Represents a gravitational field event
  51532. */
  51533. class PhysicsGravitationalFieldEvent {
  51534. private _physicsHelper;
  51535. private _scene;
  51536. private _origin;
  51537. private _options;
  51538. private _tickCallback;
  51539. private _sphere;
  51540. private _dataFetched;
  51541. /**
  51542. * Initializes the physics gravitational field event
  51543. * @param _physicsHelper A physics helper
  51544. * @param _scene BabylonJS scene
  51545. * @param _origin The origin position of the gravitational field event
  51546. * @param _options The options for the vortex event
  51547. */
  51548. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51549. /**
  51550. * Returns the data related to the gravitational field event (sphere).
  51551. * @returns A gravitational field event
  51552. */
  51553. getData(): PhysicsGravitationalFieldEventData;
  51554. /**
  51555. * Enables the gravitational field.
  51556. */
  51557. enable(): void;
  51558. /**
  51559. * Disables the gravitational field.
  51560. */
  51561. disable(): void;
  51562. /**
  51563. * Disposes the sphere.
  51564. * @param force The force to dispose from the gravitational field event
  51565. */
  51566. dispose(force?: boolean): void;
  51567. private _tick;
  51568. }
  51569. /**
  51570. * Represents a physics updraft event
  51571. */
  51572. class PhysicsUpdraftEvent {
  51573. private _scene;
  51574. private _origin;
  51575. private _options;
  51576. private _physicsEngine;
  51577. private _originTop;
  51578. private _originDirection;
  51579. private _tickCallback;
  51580. private _cylinder;
  51581. private _cylinderPosition;
  51582. private _dataFetched;
  51583. /**
  51584. * Initializes the physics updraft event
  51585. * @param _scene BabylonJS scene
  51586. * @param _origin The origin position of the updraft
  51587. * @param _options The options for the updraft event
  51588. */
  51589. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51590. /**
  51591. * Returns the data related to the updraft event (cylinder).
  51592. * @returns A physics updraft event
  51593. */
  51594. getData(): PhysicsUpdraftEventData;
  51595. /**
  51596. * Enables the updraft.
  51597. */
  51598. enable(): void;
  51599. /**
  51600. * Disables the updraft.
  51601. */
  51602. disable(): void;
  51603. /**
  51604. * Disposes the cylinder.
  51605. * @param force Specifies if the updraft should be disposed by force
  51606. */
  51607. dispose(force?: boolean): void;
  51608. private getImpostorHitData;
  51609. private _tick;
  51610. /*** Helpers ***/
  51611. private _prepareCylinder;
  51612. private _intersectsWithCylinder;
  51613. }
  51614. /**
  51615. * Represents a physics vortex event
  51616. */
  51617. class PhysicsVortexEvent {
  51618. private _scene;
  51619. private _origin;
  51620. private _options;
  51621. private _physicsEngine;
  51622. private _originTop;
  51623. private _tickCallback;
  51624. private _cylinder;
  51625. private _cylinderPosition;
  51626. private _dataFetched;
  51627. /**
  51628. * Initializes the physics vortex event
  51629. * @param _scene The BabylonJS scene
  51630. * @param _origin The origin position of the vortex
  51631. * @param _options The options for the vortex event
  51632. */
  51633. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51634. /**
  51635. * Returns the data related to the vortex event (cylinder).
  51636. * @returns The physics vortex event data
  51637. */
  51638. getData(): PhysicsVortexEventData;
  51639. /**
  51640. * Enables the vortex.
  51641. */
  51642. enable(): void;
  51643. /**
  51644. * Disables the cortex.
  51645. */
  51646. disable(): void;
  51647. /**
  51648. * Disposes the sphere.
  51649. * @param force
  51650. */
  51651. dispose(force?: boolean): void;
  51652. private getImpostorHitData;
  51653. private _tick;
  51654. /*** Helpers ***/
  51655. private _prepareCylinder;
  51656. private _intersectsWithCylinder;
  51657. }
  51658. /**
  51659. * Options fot the radial explosion event
  51660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51661. */
  51662. export class PhysicsRadialExplosionEventOptions {
  51663. /**
  51664. * The radius of the sphere for the radial explosion.
  51665. */
  51666. radius: number;
  51667. /**
  51668. * The strenth of the explosion.
  51669. */
  51670. strength: number;
  51671. /**
  51672. * The strenght of the force in correspondence to the distance of the affected object
  51673. */
  51674. falloff: PhysicsRadialImpulseFalloff;
  51675. /**
  51676. * Sphere options for the radial explosion.
  51677. */
  51678. sphere: {
  51679. segments: number;
  51680. diameter: number;
  51681. };
  51682. /**
  51683. * Sphere options for the radial explosion.
  51684. */
  51685. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51686. }
  51687. /**
  51688. * Options fot the updraft event
  51689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51690. */
  51691. export class PhysicsUpdraftEventOptions {
  51692. /**
  51693. * The radius of the cylinder for the vortex
  51694. */
  51695. radius: number;
  51696. /**
  51697. * The strenth of the updraft.
  51698. */
  51699. strength: number;
  51700. /**
  51701. * The height of the cylinder for the updraft.
  51702. */
  51703. height: number;
  51704. /**
  51705. * The mode for the the updraft.
  51706. */
  51707. updraftMode: PhysicsUpdraftMode;
  51708. }
  51709. /**
  51710. * Options fot the vortex event
  51711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51712. */
  51713. export class PhysicsVortexEventOptions {
  51714. /**
  51715. * The radius of the cylinder for the vortex
  51716. */
  51717. radius: number;
  51718. /**
  51719. * The strenth of the vortex.
  51720. */
  51721. strength: number;
  51722. /**
  51723. * The height of the cylinder for the vortex.
  51724. */
  51725. height: number;
  51726. /**
  51727. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51728. */
  51729. centripetalForceThreshold: number;
  51730. /**
  51731. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51732. */
  51733. centripetalForceMultiplier: number;
  51734. /**
  51735. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51736. */
  51737. centrifugalForceMultiplier: number;
  51738. /**
  51739. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51740. */
  51741. updraftForceMultiplier: number;
  51742. }
  51743. /**
  51744. * The strenght of the force in correspondence to the distance of the affected object
  51745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51746. */
  51747. export enum PhysicsRadialImpulseFalloff {
  51748. /** Defines that impulse is constant in strength across it's whole radius */
  51749. Constant = 0,
  51750. /** Defines that impulse gets weaker if it's further from the origin */
  51751. Linear = 1
  51752. }
  51753. /**
  51754. * The strength of the force in correspondence to the distance of the affected object
  51755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51756. */
  51757. export enum PhysicsUpdraftMode {
  51758. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51759. Center = 0,
  51760. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51761. Perpendicular = 1
  51762. }
  51763. /**
  51764. * Interface for a physics hit data
  51765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51766. */
  51767. export interface PhysicsHitData {
  51768. /**
  51769. * The force applied at the contact point
  51770. */
  51771. force: Vector3;
  51772. /**
  51773. * The contact point
  51774. */
  51775. contactPoint: Vector3;
  51776. /**
  51777. * The distance from the origin to the contact point
  51778. */
  51779. distanceFromOrigin: number;
  51780. }
  51781. /**
  51782. * Interface for radial explosion event data
  51783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51784. */
  51785. export interface PhysicsRadialExplosionEventData {
  51786. /**
  51787. * A sphere used for the radial explosion event
  51788. */
  51789. sphere: Mesh;
  51790. }
  51791. /**
  51792. * Interface for gravitational field event data
  51793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51794. */
  51795. export interface PhysicsGravitationalFieldEventData {
  51796. /**
  51797. * A sphere mesh used for the gravitational field event
  51798. */
  51799. sphere: Mesh;
  51800. }
  51801. /**
  51802. * Interface for updraft event data
  51803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51804. */
  51805. export interface PhysicsUpdraftEventData {
  51806. /**
  51807. * A cylinder used for the updraft event
  51808. */
  51809. cylinder: Mesh;
  51810. }
  51811. /**
  51812. * Interface for vortex event data
  51813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51814. */
  51815. export interface PhysicsVortexEventData {
  51816. /**
  51817. * A cylinder used for the vortex event
  51818. */
  51819. cylinder: Mesh;
  51820. }
  51821. /**
  51822. * Interface for an affected physics impostor
  51823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51824. */
  51825. export interface PhysicsAffectedImpostorWithData {
  51826. /**
  51827. * The impostor affected by the effect
  51828. */
  51829. impostor: PhysicsImpostor;
  51830. /**
  51831. * The data about the hit/horce from the explosion
  51832. */
  51833. hitData: PhysicsHitData;
  51834. }
  51835. }
  51836. declare module BABYLON {
  51837. /** @hidden */
  51838. export var blackAndWhitePixelShader: {
  51839. name: string;
  51840. shader: string;
  51841. };
  51842. }
  51843. declare module BABYLON {
  51844. /**
  51845. * Post process used to render in black and white
  51846. */
  51847. export class BlackAndWhitePostProcess extends PostProcess {
  51848. /**
  51849. * Linear about to convert he result to black and white (default: 1)
  51850. */
  51851. degree: number;
  51852. /**
  51853. * Creates a black and white post process
  51854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51855. * @param name The name of the effect.
  51856. * @param options The required width/height ratio to downsize to before computing the render pass.
  51857. * @param camera The camera to apply the render pass to.
  51858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51859. * @param engine The engine which the post process will be applied. (default: current engine)
  51860. * @param reusable If the post process can be reused on the same frame. (default: false)
  51861. */
  51862. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51863. }
  51864. }
  51865. declare module BABYLON {
  51866. /**
  51867. * This represents a set of one or more post processes in Babylon.
  51868. * A post process can be used to apply a shader to a texture after it is rendered.
  51869. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51870. */
  51871. export class PostProcessRenderEffect {
  51872. private _postProcesses;
  51873. private _getPostProcesses;
  51874. private _singleInstance;
  51875. private _cameras;
  51876. private _indicesForCamera;
  51877. /**
  51878. * Name of the effect
  51879. * @hidden
  51880. */
  51881. _name: string;
  51882. /**
  51883. * Instantiates a post process render effect.
  51884. * A post process can be used to apply a shader to a texture after it is rendered.
  51885. * @param engine The engine the effect is tied to
  51886. * @param name The name of the effect
  51887. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51888. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51889. */
  51890. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51891. /**
  51892. * Checks if all the post processes in the effect are supported.
  51893. */
  51894. readonly isSupported: boolean;
  51895. /**
  51896. * Updates the current state of the effect
  51897. * @hidden
  51898. */
  51899. _update(): void;
  51900. /**
  51901. * Attaches the effect on cameras
  51902. * @param cameras The camera to attach to.
  51903. * @hidden
  51904. */
  51905. _attachCameras(cameras: Camera): void;
  51906. /**
  51907. * Attaches the effect on cameras
  51908. * @param cameras The camera to attach to.
  51909. * @hidden
  51910. */
  51911. _attachCameras(cameras: Camera[]): void;
  51912. /**
  51913. * Detatches the effect on cameras
  51914. * @param cameras The camera to detatch from.
  51915. * @hidden
  51916. */
  51917. _detachCameras(cameras: Camera): void;
  51918. /**
  51919. * Detatches the effect on cameras
  51920. * @param cameras The camera to detatch from.
  51921. * @hidden
  51922. */
  51923. _detachCameras(cameras: Camera[]): void;
  51924. /**
  51925. * Enables the effect on given cameras
  51926. * @param cameras The camera to enable.
  51927. * @hidden
  51928. */
  51929. _enable(cameras: Camera): void;
  51930. /**
  51931. * Enables the effect on given cameras
  51932. * @param cameras The camera to enable.
  51933. * @hidden
  51934. */
  51935. _enable(cameras: Nullable<Camera[]>): void;
  51936. /**
  51937. * Disables the effect on the given cameras
  51938. * @param cameras The camera to disable.
  51939. * @hidden
  51940. */
  51941. _disable(cameras: Camera): void;
  51942. /**
  51943. * Disables the effect on the given cameras
  51944. * @param cameras The camera to disable.
  51945. * @hidden
  51946. */
  51947. _disable(cameras: Nullable<Camera[]>): void;
  51948. /**
  51949. * Gets a list of the post processes contained in the effect.
  51950. * @param camera The camera to get the post processes on.
  51951. * @returns The list of the post processes in the effect.
  51952. */
  51953. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /** @hidden */
  51958. export var extractHighlightsPixelShader: {
  51959. name: string;
  51960. shader: string;
  51961. };
  51962. }
  51963. declare module BABYLON {
  51964. /**
  51965. * 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.
  51966. */
  51967. export class ExtractHighlightsPostProcess extends PostProcess {
  51968. /**
  51969. * The luminance threshold, pixels below this value will be set to black.
  51970. */
  51971. threshold: number;
  51972. /** @hidden */
  51973. _exposure: number;
  51974. /**
  51975. * Post process which has the input texture to be used when performing highlight extraction
  51976. * @hidden
  51977. */
  51978. _inputPostProcess: Nullable<PostProcess>;
  51979. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51980. }
  51981. }
  51982. declare module BABYLON {
  51983. /** @hidden */
  51984. export var bloomMergePixelShader: {
  51985. name: string;
  51986. shader: string;
  51987. };
  51988. }
  51989. declare module BABYLON {
  51990. /**
  51991. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51992. */
  51993. export class BloomMergePostProcess extends PostProcess {
  51994. /** Weight of the bloom to be added to the original input. */
  51995. weight: number;
  51996. /**
  51997. * Creates a new instance of @see BloomMergePostProcess
  51998. * @param name The name of the effect.
  51999. * @param originalFromInput Post process which's input will be used for the merge.
  52000. * @param blurred Blurred highlights post process which's output will be used.
  52001. * @param weight Weight of the bloom to be added to the original input.
  52002. * @param options The required width/height ratio to downsize to before computing the render pass.
  52003. * @param camera The camera to apply the render pass to.
  52004. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52005. * @param engine The engine which the post process will be applied. (default: current engine)
  52006. * @param reusable If the post process can be reused on the same frame. (default: false)
  52007. * @param textureType Type of textures used when performing the post process. (default: 0)
  52008. * @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)
  52009. */
  52010. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52011. /** Weight of the bloom to be added to the original input. */
  52012. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52013. }
  52014. }
  52015. declare module BABYLON {
  52016. /**
  52017. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52018. */
  52019. export class BloomEffect extends PostProcessRenderEffect {
  52020. private bloomScale;
  52021. /**
  52022. * @hidden Internal
  52023. */
  52024. _effects: Array<PostProcess>;
  52025. /**
  52026. * @hidden Internal
  52027. */
  52028. _downscale: ExtractHighlightsPostProcess;
  52029. private _blurX;
  52030. private _blurY;
  52031. private _merge;
  52032. /**
  52033. * The luminance threshold to find bright areas of the image to bloom.
  52034. */
  52035. threshold: number;
  52036. /**
  52037. * The strength of the bloom.
  52038. */
  52039. weight: number;
  52040. /**
  52041. * Specifies the size of the bloom blur kernel, relative to the final output size
  52042. */
  52043. kernel: number;
  52044. /**
  52045. * Creates a new instance of @see BloomEffect
  52046. * @param scene The scene the effect belongs to.
  52047. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52048. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52049. * @param bloomWeight The the strength of bloom.
  52050. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52051. * @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)
  52052. */
  52053. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52054. /**
  52055. * Disposes each of the internal effects for a given camera.
  52056. * @param camera The camera to dispose the effect on.
  52057. */
  52058. disposeEffects(camera: Camera): void;
  52059. /**
  52060. * @hidden Internal
  52061. */
  52062. _updateEffects(): void;
  52063. /**
  52064. * Internal
  52065. * @returns if all the contained post processes are ready.
  52066. * @hidden
  52067. */
  52068. _isReady(): boolean;
  52069. }
  52070. }
  52071. declare module BABYLON {
  52072. /** @hidden */
  52073. export var chromaticAberrationPixelShader: {
  52074. name: string;
  52075. shader: string;
  52076. };
  52077. }
  52078. declare module BABYLON {
  52079. /**
  52080. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52081. */
  52082. export class ChromaticAberrationPostProcess extends PostProcess {
  52083. /**
  52084. * The amount of seperation of rgb channels (default: 30)
  52085. */
  52086. aberrationAmount: number;
  52087. /**
  52088. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52089. */
  52090. radialIntensity: number;
  52091. /**
  52092. * 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))
  52093. */
  52094. direction: Vector2;
  52095. /**
  52096. * 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))
  52097. */
  52098. centerPosition: Vector2;
  52099. /**
  52100. * Creates a new instance ChromaticAberrationPostProcess
  52101. * @param name The name of the effect.
  52102. * @param screenWidth The width of the screen to apply the effect on.
  52103. * @param screenHeight The height of the screen to apply the effect on.
  52104. * @param options The required width/height ratio to downsize to before computing the render pass.
  52105. * @param camera The camera to apply the render pass to.
  52106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52107. * @param engine The engine which the post process will be applied. (default: current engine)
  52108. * @param reusable If the post process can be reused on the same frame. (default: false)
  52109. * @param textureType Type of textures used when performing the post process. (default: 0)
  52110. * @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)
  52111. */
  52112. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52113. }
  52114. }
  52115. declare module BABYLON {
  52116. /** @hidden */
  52117. export var circleOfConfusionPixelShader: {
  52118. name: string;
  52119. shader: string;
  52120. };
  52121. }
  52122. declare module BABYLON {
  52123. /**
  52124. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52125. */
  52126. export class CircleOfConfusionPostProcess extends PostProcess {
  52127. /**
  52128. * 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.
  52129. */
  52130. lensSize: number;
  52131. /**
  52132. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52133. */
  52134. fStop: number;
  52135. /**
  52136. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52137. */
  52138. focusDistance: number;
  52139. /**
  52140. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52141. */
  52142. focalLength: number;
  52143. private _depthTexture;
  52144. /**
  52145. * Creates a new instance CircleOfConfusionPostProcess
  52146. * @param name The name of the effect.
  52147. * @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.
  52148. * @param options The required width/height ratio to downsize to before computing the render pass.
  52149. * @param camera The camera to apply the render pass to.
  52150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52151. * @param engine The engine which the post process will be applied. (default: current engine)
  52152. * @param reusable If the post process can be reused on the same frame. (default: false)
  52153. * @param textureType Type of textures used when performing the post process. (default: 0)
  52154. * @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)
  52155. */
  52156. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52157. /**
  52158. * 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.
  52159. */
  52160. depthTexture: RenderTargetTexture;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /** @hidden */
  52165. export var colorCorrectionPixelShader: {
  52166. name: string;
  52167. shader: string;
  52168. };
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. *
  52173. * This post-process allows the modification of rendered colors by using
  52174. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52175. *
  52176. * The object needs to be provided an url to a texture containing the color
  52177. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52178. * Use an image editing software to tweak the LUT to match your needs.
  52179. *
  52180. * For an example of a color LUT, see here:
  52181. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52182. * For explanations on color grading, see here:
  52183. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52184. *
  52185. */
  52186. export class ColorCorrectionPostProcess extends PostProcess {
  52187. private _colorTableTexture;
  52188. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52189. }
  52190. }
  52191. declare module BABYLON {
  52192. /** @hidden */
  52193. export var convolutionPixelShader: {
  52194. name: string;
  52195. shader: string;
  52196. };
  52197. }
  52198. declare module BABYLON {
  52199. /**
  52200. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52201. * input texture to perform effects such as edge detection or sharpening
  52202. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52203. */
  52204. export class ConvolutionPostProcess extends PostProcess {
  52205. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52206. kernel: number[];
  52207. /**
  52208. * Creates a new instance ConvolutionPostProcess
  52209. * @param name The name of the effect.
  52210. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52211. * @param options The required width/height ratio to downsize to before computing the render pass.
  52212. * @param camera The camera to apply the render pass to.
  52213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52214. * @param engine The engine which the post process will be applied. (default: current engine)
  52215. * @param reusable If the post process can be reused on the same frame. (default: false)
  52216. * @param textureType Type of textures used when performing the post process. (default: 0)
  52217. */
  52218. constructor(name: string,
  52219. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52220. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52221. /**
  52222. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52223. */
  52224. static EdgeDetect0Kernel: number[];
  52225. /**
  52226. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52227. */
  52228. static EdgeDetect1Kernel: number[];
  52229. /**
  52230. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52231. */
  52232. static EdgeDetect2Kernel: number[];
  52233. /**
  52234. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52235. */
  52236. static SharpenKernel: number[];
  52237. /**
  52238. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52239. */
  52240. static EmbossKernel: number[];
  52241. /**
  52242. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52243. */
  52244. static GaussianKernel: number[];
  52245. }
  52246. }
  52247. declare module BABYLON {
  52248. /**
  52249. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52250. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52251. * based on samples that have a large difference in distance than the center pixel.
  52252. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52253. */
  52254. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52255. direction: Vector2;
  52256. /**
  52257. * Creates a new instance CircleOfConfusionPostProcess
  52258. * @param name The name of the effect.
  52259. * @param scene The scene the effect belongs to.
  52260. * @param direction The direction the blur should be applied.
  52261. * @param kernel The size of the kernel used to blur.
  52262. * @param options The required width/height ratio to downsize to before computing the render pass.
  52263. * @param camera The camera to apply the render pass to.
  52264. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52265. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52267. * @param engine The engine which the post process will be applied. (default: current engine)
  52268. * @param reusable If the post process can be reused on the same frame. (default: false)
  52269. * @param textureType Type of textures used when performing the post process. (default: 0)
  52270. * @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)
  52271. */
  52272. 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);
  52273. }
  52274. }
  52275. declare module BABYLON {
  52276. /** @hidden */
  52277. export var depthOfFieldMergePixelShader: {
  52278. name: string;
  52279. shader: string;
  52280. };
  52281. }
  52282. declare module BABYLON {
  52283. /**
  52284. * Options to be set when merging outputs from the default pipeline.
  52285. */
  52286. export class DepthOfFieldMergePostProcessOptions {
  52287. /**
  52288. * The original image to merge on top of
  52289. */
  52290. originalFromInput: PostProcess;
  52291. /**
  52292. * Parameters to perform the merge of the depth of field effect
  52293. */
  52294. depthOfField?: {
  52295. circleOfConfusion: PostProcess;
  52296. blurSteps: Array<PostProcess>;
  52297. };
  52298. /**
  52299. * Parameters to perform the merge of bloom effect
  52300. */
  52301. bloom?: {
  52302. blurred: PostProcess;
  52303. weight: number;
  52304. };
  52305. }
  52306. /**
  52307. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52308. */
  52309. export class DepthOfFieldMergePostProcess extends PostProcess {
  52310. private blurSteps;
  52311. /**
  52312. * Creates a new instance of DepthOfFieldMergePostProcess
  52313. * @param name The name of the effect.
  52314. * @param originalFromInput Post process which's input will be used for the merge.
  52315. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52316. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52317. * @param options The required width/height ratio to downsize to before computing the render pass.
  52318. * @param camera The camera to apply the render pass to.
  52319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52320. * @param engine The engine which the post process will be applied. (default: current engine)
  52321. * @param reusable If the post process can be reused on the same frame. (default: false)
  52322. * @param textureType Type of textures used when performing the post process. (default: 0)
  52323. * @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)
  52324. */
  52325. 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);
  52326. /**
  52327. * Updates the effect with the current post process compile time values and recompiles the shader.
  52328. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52329. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52330. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52331. * @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
  52332. * @param onCompiled Called when the shader has been compiled.
  52333. * @param onError Called if there is an error when compiling a shader.
  52334. */
  52335. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Specifies the level of max blur that should be applied when using the depth of field effect
  52341. */
  52342. export enum DepthOfFieldEffectBlurLevel {
  52343. /**
  52344. * Subtle blur
  52345. */
  52346. Low = 0,
  52347. /**
  52348. * Medium blur
  52349. */
  52350. Medium = 1,
  52351. /**
  52352. * Large blur
  52353. */
  52354. High = 2
  52355. }
  52356. /**
  52357. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52358. */
  52359. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52360. private _circleOfConfusion;
  52361. /**
  52362. * @hidden Internal, blurs from high to low
  52363. */
  52364. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52365. private _depthOfFieldBlurY;
  52366. private _dofMerge;
  52367. /**
  52368. * @hidden Internal post processes in depth of field effect
  52369. */
  52370. _effects: Array<PostProcess>;
  52371. /**
  52372. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52373. */
  52374. focalLength: number;
  52375. /**
  52376. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52377. */
  52378. fStop: number;
  52379. /**
  52380. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52381. */
  52382. focusDistance: number;
  52383. /**
  52384. * 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.
  52385. */
  52386. lensSize: number;
  52387. /**
  52388. * Creates a new instance DepthOfFieldEffect
  52389. * @param scene The scene the effect belongs to.
  52390. * @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.
  52391. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52392. * @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)
  52393. */
  52394. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52395. /**
  52396. * 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.
  52397. */
  52398. depthTexture: RenderTargetTexture;
  52399. /**
  52400. * Disposes each of the internal effects for a given camera.
  52401. * @param camera The camera to dispose the effect on.
  52402. */
  52403. disposeEffects(camera: Camera): void;
  52404. /**
  52405. * @hidden Internal
  52406. */
  52407. _updateEffects(): void;
  52408. /**
  52409. * Internal
  52410. * @returns if all the contained post processes are ready.
  52411. * @hidden
  52412. */
  52413. _isReady(): boolean;
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /** @hidden */
  52418. export var displayPassPixelShader: {
  52419. name: string;
  52420. shader: string;
  52421. };
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * DisplayPassPostProcess which produces an output the same as it's input
  52426. */
  52427. export class DisplayPassPostProcess extends PostProcess {
  52428. /**
  52429. * Creates the DisplayPassPostProcess
  52430. * @param name The name of the effect.
  52431. * @param options The required width/height ratio to downsize to before computing the render pass.
  52432. * @param camera The camera to apply the render pass to.
  52433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52434. * @param engine The engine which the post process will be applied. (default: current engine)
  52435. * @param reusable If the post process can be reused on the same frame. (default: false)
  52436. */
  52437. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52438. }
  52439. }
  52440. declare module BABYLON {
  52441. /** @hidden */
  52442. export var filterPixelShader: {
  52443. name: string;
  52444. shader: string;
  52445. };
  52446. }
  52447. declare module BABYLON {
  52448. /**
  52449. * Applies a kernel filter to the image
  52450. */
  52451. export class FilterPostProcess extends PostProcess {
  52452. /** The matrix to be applied to the image */
  52453. kernelMatrix: Matrix;
  52454. /**
  52455. *
  52456. * @param name The name of the effect.
  52457. * @param kernelMatrix The matrix to be applied to the image
  52458. * @param options The required width/height ratio to downsize to before computing the render pass.
  52459. * @param camera The camera to apply the render pass to.
  52460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52461. * @param engine The engine which the post process will be applied. (default: current engine)
  52462. * @param reusable If the post process can be reused on the same frame. (default: false)
  52463. */
  52464. constructor(name: string,
  52465. /** The matrix to be applied to the image */
  52466. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52467. }
  52468. }
  52469. declare module BABYLON {
  52470. /** @hidden */
  52471. export var fxaaPixelShader: {
  52472. name: string;
  52473. shader: string;
  52474. };
  52475. }
  52476. declare module BABYLON {
  52477. /** @hidden */
  52478. export var fxaaVertexShader: {
  52479. name: string;
  52480. shader: string;
  52481. };
  52482. }
  52483. declare module BABYLON {
  52484. /**
  52485. * Fxaa post process
  52486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52487. */
  52488. export class FxaaPostProcess extends PostProcess {
  52489. /** @hidden */
  52490. texelWidth: number;
  52491. /** @hidden */
  52492. texelHeight: number;
  52493. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52494. private _getDefines;
  52495. }
  52496. }
  52497. declare module BABYLON {
  52498. /** @hidden */
  52499. export var grainPixelShader: {
  52500. name: string;
  52501. shader: string;
  52502. };
  52503. }
  52504. declare module BABYLON {
  52505. /**
  52506. * The GrainPostProcess adds noise to the image at mid luminance levels
  52507. */
  52508. export class GrainPostProcess extends PostProcess {
  52509. /**
  52510. * The intensity of the grain added (default: 30)
  52511. */
  52512. intensity: number;
  52513. /**
  52514. * If the grain should be randomized on every frame
  52515. */
  52516. animated: boolean;
  52517. /**
  52518. * Creates a new instance of @see GrainPostProcess
  52519. * @param name The name of the effect.
  52520. * @param options The required width/height ratio to downsize to before computing the render pass.
  52521. * @param camera The camera to apply the render pass to.
  52522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52523. * @param engine The engine which the post process will be applied. (default: current engine)
  52524. * @param reusable If the post process can be reused on the same frame. (default: false)
  52525. * @param textureType Type of textures used when performing the post process. (default: 0)
  52526. * @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)
  52527. */
  52528. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. /** @hidden */
  52533. export var highlightsPixelShader: {
  52534. name: string;
  52535. shader: string;
  52536. };
  52537. }
  52538. declare module BABYLON {
  52539. /**
  52540. * Extracts highlights from the image
  52541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52542. */
  52543. export class HighlightsPostProcess extends PostProcess {
  52544. /**
  52545. * Extracts highlights from the image
  52546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52547. * @param name The name of the effect.
  52548. * @param options The required width/height ratio to downsize to before computing the render pass.
  52549. * @param camera The camera to apply the render pass to.
  52550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52551. * @param engine The engine which the post process will be applied. (default: current engine)
  52552. * @param reusable If the post process can be reused on the same frame. (default: false)
  52553. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52554. */
  52555. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52556. }
  52557. }
  52558. declare module BABYLON {
  52559. /** @hidden */
  52560. export var mrtFragmentDeclaration: {
  52561. name: string;
  52562. shader: string;
  52563. };
  52564. }
  52565. declare module BABYLON {
  52566. /** @hidden */
  52567. export var geometryPixelShader: {
  52568. name: string;
  52569. shader: string;
  52570. };
  52571. }
  52572. declare module BABYLON {
  52573. /** @hidden */
  52574. export var geometryVertexShader: {
  52575. name: string;
  52576. shader: string;
  52577. };
  52578. }
  52579. declare module BABYLON {
  52580. /**
  52581. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52582. */
  52583. export class GeometryBufferRenderer {
  52584. /**
  52585. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52586. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52587. */
  52588. static readonly POSITION_TEXTURE_TYPE: number;
  52589. /**
  52590. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52591. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52592. */
  52593. static readonly VELOCITY_TEXTURE_TYPE: number;
  52594. /**
  52595. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52596. * in order to compute objects velocities when enableVelocity is set to "true"
  52597. * @hidden
  52598. */
  52599. _previousTransformationMatrices: {
  52600. [index: number]: Matrix;
  52601. };
  52602. private _scene;
  52603. private _multiRenderTarget;
  52604. private _ratio;
  52605. private _enablePosition;
  52606. private _enableVelocity;
  52607. private _positionIndex;
  52608. private _velocityIndex;
  52609. protected _effect: Effect;
  52610. protected _cachedDefines: string;
  52611. /**
  52612. * Set the render list (meshes to be rendered) used in the G buffer.
  52613. */
  52614. renderList: Mesh[];
  52615. /**
  52616. * Gets wether or not G buffer are supported by the running hardware.
  52617. * This requires draw buffer supports
  52618. */
  52619. readonly isSupported: boolean;
  52620. /**
  52621. * Returns the index of the given texture type in the G-Buffer textures array
  52622. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52623. * @returns the index of the given texture type in the G-Buffer textures array
  52624. */
  52625. getTextureIndex(textureType: number): number;
  52626. /**
  52627. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52628. */
  52629. /**
  52630. * Sets whether or not objects positions are enabled for the G buffer.
  52631. */
  52632. enablePosition: boolean;
  52633. /**
  52634. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52635. */
  52636. /**
  52637. * Sets wether or not objects velocities are enabled for the G buffer.
  52638. */
  52639. enableVelocity: boolean;
  52640. /**
  52641. * Gets the scene associated with the buffer.
  52642. */
  52643. readonly scene: Scene;
  52644. /**
  52645. * Gets the ratio used by the buffer during its creation.
  52646. * How big is the buffer related to the main canvas.
  52647. */
  52648. readonly ratio: number;
  52649. /** @hidden */
  52650. static _SceneComponentInitialization: (scene: Scene) => void;
  52651. /**
  52652. * Creates a new G Buffer for the scene
  52653. * @param scene The scene the buffer belongs to
  52654. * @param ratio How big is the buffer related to the main canvas.
  52655. */
  52656. constructor(scene: Scene, ratio?: number);
  52657. /**
  52658. * Checks wether everything is ready to render a submesh to the G buffer.
  52659. * @param subMesh the submesh to check readiness for
  52660. * @param useInstances is the mesh drawn using instance or not
  52661. * @returns true if ready otherwise false
  52662. */
  52663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52664. /**
  52665. * Gets the current underlying G Buffer.
  52666. * @returns the buffer
  52667. */
  52668. getGBuffer(): MultiRenderTarget;
  52669. /**
  52670. * Gets the number of samples used to render the buffer (anti aliasing).
  52671. */
  52672. /**
  52673. * Sets the number of samples used to render the buffer (anti aliasing).
  52674. */
  52675. samples: number;
  52676. /**
  52677. * Disposes the renderer and frees up associated resources.
  52678. */
  52679. dispose(): void;
  52680. protected _createRenderTargets(): void;
  52681. }
  52682. }
  52683. declare module BABYLON {
  52684. interface Scene {
  52685. /** @hidden (Backing field) */
  52686. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52687. /**
  52688. * Gets or Sets the current geometry buffer associated to the scene.
  52689. */
  52690. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52691. /**
  52692. * Enables a GeometryBufferRender and associates it with the scene
  52693. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52694. * @returns the GeometryBufferRenderer
  52695. */
  52696. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52697. /**
  52698. * Disables the GeometryBufferRender associated with the scene
  52699. */
  52700. disableGeometryBufferRenderer(): void;
  52701. }
  52702. /**
  52703. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52704. * in several rendering techniques.
  52705. */
  52706. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52707. /**
  52708. * The component name helpful to identify the component in the list of scene components.
  52709. */
  52710. readonly name: string;
  52711. /**
  52712. * The scene the component belongs to.
  52713. */
  52714. scene: Scene;
  52715. /**
  52716. * Creates a new instance of the component for the given scene
  52717. * @param scene Defines the scene to register the component in
  52718. */
  52719. constructor(scene: Scene);
  52720. /**
  52721. * Registers the component in a given scene
  52722. */
  52723. register(): void;
  52724. /**
  52725. * Rebuilds the elements related to this component in case of
  52726. * context lost for instance.
  52727. */
  52728. rebuild(): void;
  52729. /**
  52730. * Disposes the component and the associated ressources
  52731. */
  52732. dispose(): void;
  52733. private _gatherRenderTargets;
  52734. }
  52735. }
  52736. declare module BABYLON {
  52737. /** @hidden */
  52738. export var motionBlurPixelShader: {
  52739. name: string;
  52740. shader: string;
  52741. };
  52742. }
  52743. declare module BABYLON {
  52744. /**
  52745. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52746. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52747. * As an example, all you have to do is to create the post-process:
  52748. * var mb = new BABYLON.MotionBlurPostProcess(
  52749. * 'mb', // The name of the effect.
  52750. * scene, // The scene containing the objects to blur according to their velocity.
  52751. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52752. * camera // The camera to apply the render pass to.
  52753. * );
  52754. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52755. */
  52756. export class MotionBlurPostProcess extends PostProcess {
  52757. /**
  52758. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52759. */
  52760. motionStrength: number;
  52761. /**
  52762. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52763. */
  52764. /**
  52765. * Sets the number of iterations to be used for motion blur quality
  52766. */
  52767. motionBlurSamples: number;
  52768. private _motionBlurSamples;
  52769. private _geometryBufferRenderer;
  52770. /**
  52771. * Creates a new instance MotionBlurPostProcess
  52772. * @param name The name of the effect.
  52773. * @param scene The scene containing the objects to blur according to their velocity.
  52774. * @param options The required width/height ratio to downsize to before computing the render pass.
  52775. * @param camera The camera to apply the render pass to.
  52776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52777. * @param engine The engine which the post process will be applied. (default: current engine)
  52778. * @param reusable If the post process can be reused on the same frame. (default: false)
  52779. * @param textureType Type of textures used when performing the post process. (default: 0)
  52780. * @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)
  52781. */
  52782. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52783. /**
  52784. * Disposes the post process.
  52785. * @param camera The camera to dispose the post process on.
  52786. */
  52787. dispose(camera?: Camera): void;
  52788. }
  52789. }
  52790. declare module BABYLON {
  52791. /** @hidden */
  52792. export var refractionPixelShader: {
  52793. name: string;
  52794. shader: string;
  52795. };
  52796. }
  52797. declare module BABYLON {
  52798. /**
  52799. * Post process which applies a refractin texture
  52800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52801. */
  52802. export class RefractionPostProcess extends PostProcess {
  52803. /** the base color of the refraction (used to taint the rendering) */
  52804. color: Color3;
  52805. /** simulated refraction depth */
  52806. depth: number;
  52807. /** the coefficient of the base color (0 to remove base color tainting) */
  52808. colorLevel: number;
  52809. private _refTexture;
  52810. private _ownRefractionTexture;
  52811. /**
  52812. * Gets or sets the refraction texture
  52813. * Please note that you are responsible for disposing the texture if you set it manually
  52814. */
  52815. refractionTexture: Texture;
  52816. /**
  52817. * Initializes the RefractionPostProcess
  52818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52819. * @param name The name of the effect.
  52820. * @param refractionTextureUrl Url of the refraction texture to use
  52821. * @param color the base color of the refraction (used to taint the rendering)
  52822. * @param depth simulated refraction depth
  52823. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52824. * @param camera The camera to apply the render pass to.
  52825. * @param options The required width/height ratio to downsize to before computing the render pass.
  52826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52827. * @param engine The engine which the post process will be applied. (default: current engine)
  52828. * @param reusable If the post process can be reused on the same frame. (default: false)
  52829. */
  52830. constructor(name: string, refractionTextureUrl: string,
  52831. /** the base color of the refraction (used to taint the rendering) */
  52832. color: Color3,
  52833. /** simulated refraction depth */
  52834. depth: number,
  52835. /** the coefficient of the base color (0 to remove base color tainting) */
  52836. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52837. /**
  52838. * Disposes of the post process
  52839. * @param camera Camera to dispose post process on
  52840. */
  52841. dispose(camera: Camera): void;
  52842. }
  52843. }
  52844. declare module BABYLON {
  52845. /** @hidden */
  52846. export var sharpenPixelShader: {
  52847. name: string;
  52848. shader: string;
  52849. };
  52850. }
  52851. declare module BABYLON {
  52852. /**
  52853. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52854. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52855. */
  52856. export class SharpenPostProcess extends PostProcess {
  52857. /**
  52858. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52859. */
  52860. colorAmount: number;
  52861. /**
  52862. * How much sharpness should be applied (default: 0.3)
  52863. */
  52864. edgeAmount: number;
  52865. /**
  52866. * Creates a new instance ConvolutionPostProcess
  52867. * @param name The name of the effect.
  52868. * @param options The required width/height ratio to downsize to before computing the render pass.
  52869. * @param camera The camera to apply the render pass to.
  52870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52871. * @param engine The engine which the post process will be applied. (default: current engine)
  52872. * @param reusable If the post process can be reused on the same frame. (default: false)
  52873. * @param textureType Type of textures used when performing the post process. (default: 0)
  52874. * @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)
  52875. */
  52876. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52877. }
  52878. }
  52879. declare module BABYLON {
  52880. /**
  52881. * PostProcessRenderPipeline
  52882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52883. */
  52884. export class PostProcessRenderPipeline {
  52885. private engine;
  52886. private _renderEffects;
  52887. private _renderEffectsForIsolatedPass;
  52888. /**
  52889. * List of inspectable custom properties (used by the Inspector)
  52890. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52891. */
  52892. inspectableCustomProperties: IInspectable[];
  52893. /**
  52894. * @hidden
  52895. */
  52896. protected _cameras: Camera[];
  52897. /** @hidden */
  52898. _name: string;
  52899. /**
  52900. * Gets pipeline name
  52901. */
  52902. readonly name: string;
  52903. /**
  52904. * Initializes a PostProcessRenderPipeline
  52905. * @param engine engine to add the pipeline to
  52906. * @param name name of the pipeline
  52907. */
  52908. constructor(engine: Engine, name: string);
  52909. /**
  52910. * Gets the class name
  52911. * @returns "PostProcessRenderPipeline"
  52912. */
  52913. getClassName(): string;
  52914. /**
  52915. * If all the render effects in the pipeline are supported
  52916. */
  52917. readonly isSupported: boolean;
  52918. /**
  52919. * Adds an effect to the pipeline
  52920. * @param renderEffect the effect to add
  52921. */
  52922. addEffect(renderEffect: PostProcessRenderEffect): void;
  52923. /** @hidden */
  52924. _rebuild(): void;
  52925. /** @hidden */
  52926. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52927. /** @hidden */
  52928. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52929. /** @hidden */
  52930. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52931. /** @hidden */
  52932. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52933. /** @hidden */
  52934. _attachCameras(cameras: Camera, unique: boolean): void;
  52935. /** @hidden */
  52936. _attachCameras(cameras: Camera[], unique: boolean): void;
  52937. /** @hidden */
  52938. _detachCameras(cameras: Camera): void;
  52939. /** @hidden */
  52940. _detachCameras(cameras: Nullable<Camera[]>): void;
  52941. /** @hidden */
  52942. _update(): void;
  52943. /** @hidden */
  52944. _reset(): void;
  52945. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52946. /**
  52947. * Disposes of the pipeline
  52948. */
  52949. dispose(): void;
  52950. }
  52951. }
  52952. declare module BABYLON {
  52953. /**
  52954. * PostProcessRenderPipelineManager class
  52955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52956. */
  52957. export class PostProcessRenderPipelineManager {
  52958. private _renderPipelines;
  52959. /**
  52960. * Initializes a PostProcessRenderPipelineManager
  52961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52962. */
  52963. constructor();
  52964. /**
  52965. * Gets the list of supported render pipelines
  52966. */
  52967. readonly supportedPipelines: PostProcessRenderPipeline[];
  52968. /**
  52969. * Adds a pipeline to the manager
  52970. * @param renderPipeline The pipeline to add
  52971. */
  52972. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52973. /**
  52974. * Attaches a camera to the pipeline
  52975. * @param renderPipelineName The name of the pipeline to attach to
  52976. * @param cameras the camera to attach
  52977. * @param unique if the camera can be attached multiple times to the pipeline
  52978. */
  52979. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52980. /**
  52981. * Detaches a camera from the pipeline
  52982. * @param renderPipelineName The name of the pipeline to detach from
  52983. * @param cameras the camera to detach
  52984. */
  52985. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52986. /**
  52987. * Enables an effect by name on a pipeline
  52988. * @param renderPipelineName the name of the pipeline to enable the effect in
  52989. * @param renderEffectName the name of the effect to enable
  52990. * @param cameras the cameras that the effect should be enabled on
  52991. */
  52992. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52993. /**
  52994. * Disables an effect by name on a pipeline
  52995. * @param renderPipelineName the name of the pipeline to disable the effect in
  52996. * @param renderEffectName the name of the effect to disable
  52997. * @param cameras the cameras that the effect should be disabled on
  52998. */
  52999. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53000. /**
  53001. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53002. */
  53003. update(): void;
  53004. /** @hidden */
  53005. _rebuild(): void;
  53006. /**
  53007. * Disposes of the manager and pipelines
  53008. */
  53009. dispose(): void;
  53010. }
  53011. }
  53012. declare module BABYLON {
  53013. interface Scene {
  53014. /** @hidden (Backing field) */
  53015. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53016. /**
  53017. * Gets the postprocess render pipeline manager
  53018. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53019. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53020. */
  53021. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53022. }
  53023. /**
  53024. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53025. */
  53026. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53027. /**
  53028. * The component name helpfull to identify the component in the list of scene components.
  53029. */
  53030. readonly name: string;
  53031. /**
  53032. * The scene the component belongs to.
  53033. */
  53034. scene: Scene;
  53035. /**
  53036. * Creates a new instance of the component for the given scene
  53037. * @param scene Defines the scene to register the component in
  53038. */
  53039. constructor(scene: Scene);
  53040. /**
  53041. * Registers the component in a given scene
  53042. */
  53043. register(): void;
  53044. /**
  53045. * Rebuilds the elements related to this component in case of
  53046. * context lost for instance.
  53047. */
  53048. rebuild(): void;
  53049. /**
  53050. * Disposes the component and the associated ressources
  53051. */
  53052. dispose(): void;
  53053. private _gatherRenderTargets;
  53054. }
  53055. }
  53056. declare module BABYLON {
  53057. /**
  53058. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53059. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53060. */
  53061. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53062. private _scene;
  53063. private _camerasToBeAttached;
  53064. /**
  53065. * ID of the sharpen post process,
  53066. */
  53067. private readonly SharpenPostProcessId;
  53068. /**
  53069. * @ignore
  53070. * ID of the image processing post process;
  53071. */
  53072. readonly ImageProcessingPostProcessId: string;
  53073. /**
  53074. * @ignore
  53075. * ID of the Fast Approximate Anti-Aliasing post process;
  53076. */
  53077. readonly FxaaPostProcessId: string;
  53078. /**
  53079. * ID of the chromatic aberration post process,
  53080. */
  53081. private readonly ChromaticAberrationPostProcessId;
  53082. /**
  53083. * ID of the grain post process
  53084. */
  53085. private readonly GrainPostProcessId;
  53086. /**
  53087. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53088. */
  53089. sharpen: SharpenPostProcess;
  53090. private _sharpenEffect;
  53091. private bloom;
  53092. /**
  53093. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53094. */
  53095. depthOfField: DepthOfFieldEffect;
  53096. /**
  53097. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53098. */
  53099. fxaa: FxaaPostProcess;
  53100. /**
  53101. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53102. */
  53103. imageProcessing: ImageProcessingPostProcess;
  53104. /**
  53105. * Chromatic aberration post process which will shift rgb colors in the image
  53106. */
  53107. chromaticAberration: ChromaticAberrationPostProcess;
  53108. private _chromaticAberrationEffect;
  53109. /**
  53110. * Grain post process which add noise to the image
  53111. */
  53112. grain: GrainPostProcess;
  53113. private _grainEffect;
  53114. /**
  53115. * Glow post process which adds a glow to emissive areas of the image
  53116. */
  53117. private _glowLayer;
  53118. /**
  53119. * Animations which can be used to tweak settings over a period of time
  53120. */
  53121. animations: Animation[];
  53122. private _imageProcessingConfigurationObserver;
  53123. private _sharpenEnabled;
  53124. private _bloomEnabled;
  53125. private _depthOfFieldEnabled;
  53126. private _depthOfFieldBlurLevel;
  53127. private _fxaaEnabled;
  53128. private _imageProcessingEnabled;
  53129. private _defaultPipelineTextureType;
  53130. private _bloomScale;
  53131. private _chromaticAberrationEnabled;
  53132. private _grainEnabled;
  53133. private _buildAllowed;
  53134. /**
  53135. * Gets active scene
  53136. */
  53137. readonly scene: Scene;
  53138. /**
  53139. * Enable or disable the sharpen process from the pipeline
  53140. */
  53141. sharpenEnabled: boolean;
  53142. private _resizeObserver;
  53143. private _hardwareScaleLevel;
  53144. private _bloomKernel;
  53145. /**
  53146. * Specifies the size of the bloom blur kernel, relative to the final output size
  53147. */
  53148. bloomKernel: number;
  53149. /**
  53150. * Specifies the weight of the bloom in the final rendering
  53151. */
  53152. private _bloomWeight;
  53153. /**
  53154. * Specifies the luma threshold for the area that will be blurred by the bloom
  53155. */
  53156. private _bloomThreshold;
  53157. private _hdr;
  53158. /**
  53159. * The strength of the bloom.
  53160. */
  53161. bloomWeight: number;
  53162. /**
  53163. * The strength of the bloom.
  53164. */
  53165. bloomThreshold: number;
  53166. /**
  53167. * The scale of the bloom, lower value will provide better performance.
  53168. */
  53169. bloomScale: number;
  53170. /**
  53171. * Enable or disable the bloom from the pipeline
  53172. */
  53173. bloomEnabled: boolean;
  53174. private _rebuildBloom;
  53175. /**
  53176. * If the depth of field is enabled.
  53177. */
  53178. depthOfFieldEnabled: boolean;
  53179. /**
  53180. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53181. */
  53182. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53183. /**
  53184. * If the anti aliasing is enabled.
  53185. */
  53186. fxaaEnabled: boolean;
  53187. private _samples;
  53188. /**
  53189. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53190. */
  53191. samples: number;
  53192. /**
  53193. * If image processing is enabled.
  53194. */
  53195. imageProcessingEnabled: boolean;
  53196. /**
  53197. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53198. */
  53199. glowLayerEnabled: boolean;
  53200. /**
  53201. * Enable or disable the chromaticAberration process from the pipeline
  53202. */
  53203. chromaticAberrationEnabled: boolean;
  53204. /**
  53205. * Enable or disable the grain process from the pipeline
  53206. */
  53207. grainEnabled: boolean;
  53208. /**
  53209. * @constructor
  53210. * @param name - The rendering pipeline name (default: "")
  53211. * @param hdr - If high dynamic range textures should be used (default: true)
  53212. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53213. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53214. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53215. */
  53216. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53217. /**
  53218. * Get the class name
  53219. * @returns "DefaultRenderingPipeline"
  53220. */
  53221. getClassName(): string;
  53222. /**
  53223. * Force the compilation of the entire pipeline.
  53224. */
  53225. prepare(): void;
  53226. private _hasCleared;
  53227. private _prevPostProcess;
  53228. private _prevPrevPostProcess;
  53229. private _setAutoClearAndTextureSharing;
  53230. private _depthOfFieldSceneObserver;
  53231. private _buildPipeline;
  53232. private _disposePostProcesses;
  53233. /**
  53234. * Adds a camera to the pipeline
  53235. * @param camera the camera to be added
  53236. */
  53237. addCamera(camera: Camera): void;
  53238. /**
  53239. * Removes a camera from the pipeline
  53240. * @param camera the camera to remove
  53241. */
  53242. removeCamera(camera: Camera): void;
  53243. /**
  53244. * Dispose of the pipeline and stop all post processes
  53245. */
  53246. dispose(): void;
  53247. /**
  53248. * Serialize the rendering pipeline (Used when exporting)
  53249. * @returns the serialized object
  53250. */
  53251. serialize(): any;
  53252. /**
  53253. * Parse the serialized pipeline
  53254. * @param source Source pipeline.
  53255. * @param scene The scene to load the pipeline to.
  53256. * @param rootUrl The URL of the serialized pipeline.
  53257. * @returns An instantiated pipeline from the serialized object.
  53258. */
  53259. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53260. }
  53261. }
  53262. declare module BABYLON {
  53263. /** @hidden */
  53264. export var lensHighlightsPixelShader: {
  53265. name: string;
  53266. shader: string;
  53267. };
  53268. }
  53269. declare module BABYLON {
  53270. /** @hidden */
  53271. export var depthOfFieldPixelShader: {
  53272. name: string;
  53273. shader: string;
  53274. };
  53275. }
  53276. declare module BABYLON {
  53277. /**
  53278. * BABYLON.JS Chromatic Aberration GLSL Shader
  53279. * Author: Olivier Guyot
  53280. * Separates very slightly R, G and B colors on the edges of the screen
  53281. * Inspired by Francois Tarlier & Martins Upitis
  53282. */
  53283. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53284. /**
  53285. * @ignore
  53286. * The chromatic aberration PostProcess id in the pipeline
  53287. */
  53288. LensChromaticAberrationEffect: string;
  53289. /**
  53290. * @ignore
  53291. * The highlights enhancing PostProcess id in the pipeline
  53292. */
  53293. HighlightsEnhancingEffect: string;
  53294. /**
  53295. * @ignore
  53296. * The depth-of-field PostProcess id in the pipeline
  53297. */
  53298. LensDepthOfFieldEffect: string;
  53299. private _scene;
  53300. private _depthTexture;
  53301. private _grainTexture;
  53302. private _chromaticAberrationPostProcess;
  53303. private _highlightsPostProcess;
  53304. private _depthOfFieldPostProcess;
  53305. private _edgeBlur;
  53306. private _grainAmount;
  53307. private _chromaticAberration;
  53308. private _distortion;
  53309. private _highlightsGain;
  53310. private _highlightsThreshold;
  53311. private _dofDistance;
  53312. private _dofAperture;
  53313. private _dofDarken;
  53314. private _dofPentagon;
  53315. private _blurNoise;
  53316. /**
  53317. * @constructor
  53318. *
  53319. * Effect parameters are as follow:
  53320. * {
  53321. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53322. * edge_blur: number; // from 0 to x (1 for realism)
  53323. * distortion: number; // from 0 to x (1 for realism)
  53324. * grain_amount: number; // from 0 to 1
  53325. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53326. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53327. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53328. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53329. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53330. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53331. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53332. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53333. * }
  53334. * Note: if an effect parameter is unset, effect is disabled
  53335. *
  53336. * @param name The rendering pipeline name
  53337. * @param parameters - An object containing all parameters (see above)
  53338. * @param scene The scene linked to this pipeline
  53339. * @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)
  53340. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53341. */
  53342. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53343. /**
  53344. * Get the class name
  53345. * @returns "LensRenderingPipeline"
  53346. */
  53347. getClassName(): string;
  53348. /**
  53349. * Gets associated scene
  53350. */
  53351. readonly scene: Scene;
  53352. /**
  53353. * Gets or sets the edge blur
  53354. */
  53355. edgeBlur: number;
  53356. /**
  53357. * Gets or sets the grain amount
  53358. */
  53359. grainAmount: number;
  53360. /**
  53361. * Gets or sets the chromatic aberration amount
  53362. */
  53363. chromaticAberration: number;
  53364. /**
  53365. * Gets or sets the depth of field aperture
  53366. */
  53367. dofAperture: number;
  53368. /**
  53369. * Gets or sets the edge distortion
  53370. */
  53371. edgeDistortion: number;
  53372. /**
  53373. * Gets or sets the depth of field distortion
  53374. */
  53375. dofDistortion: number;
  53376. /**
  53377. * Gets or sets the darken out of focus amount
  53378. */
  53379. darkenOutOfFocus: number;
  53380. /**
  53381. * Gets or sets a boolean indicating if blur noise is enabled
  53382. */
  53383. blurNoise: boolean;
  53384. /**
  53385. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53386. */
  53387. pentagonBokeh: boolean;
  53388. /**
  53389. * Gets or sets the highlight grain amount
  53390. */
  53391. highlightsGain: number;
  53392. /**
  53393. * Gets or sets the highlight threshold
  53394. */
  53395. highlightsThreshold: number;
  53396. /**
  53397. * Sets the amount of blur at the edges
  53398. * @param amount blur amount
  53399. */
  53400. setEdgeBlur(amount: number): void;
  53401. /**
  53402. * Sets edge blur to 0
  53403. */
  53404. disableEdgeBlur(): void;
  53405. /**
  53406. * Sets the amout of grain
  53407. * @param amount Amount of grain
  53408. */
  53409. setGrainAmount(amount: number): void;
  53410. /**
  53411. * Set grain amount to 0
  53412. */
  53413. disableGrain(): void;
  53414. /**
  53415. * Sets the chromatic aberration amount
  53416. * @param amount amount of chromatic aberration
  53417. */
  53418. setChromaticAberration(amount: number): void;
  53419. /**
  53420. * Sets chromatic aberration amount to 0
  53421. */
  53422. disableChromaticAberration(): void;
  53423. /**
  53424. * Sets the EdgeDistortion amount
  53425. * @param amount amount of EdgeDistortion
  53426. */
  53427. setEdgeDistortion(amount: number): void;
  53428. /**
  53429. * Sets edge distortion to 0
  53430. */
  53431. disableEdgeDistortion(): void;
  53432. /**
  53433. * Sets the FocusDistance amount
  53434. * @param amount amount of FocusDistance
  53435. */
  53436. setFocusDistance(amount: number): void;
  53437. /**
  53438. * Disables depth of field
  53439. */
  53440. disableDepthOfField(): void;
  53441. /**
  53442. * Sets the Aperture amount
  53443. * @param amount amount of Aperture
  53444. */
  53445. setAperture(amount: number): void;
  53446. /**
  53447. * Sets the DarkenOutOfFocus amount
  53448. * @param amount amount of DarkenOutOfFocus
  53449. */
  53450. setDarkenOutOfFocus(amount: number): void;
  53451. private _pentagonBokehIsEnabled;
  53452. /**
  53453. * Creates a pentagon bokeh effect
  53454. */
  53455. enablePentagonBokeh(): void;
  53456. /**
  53457. * Disables the pentagon bokeh effect
  53458. */
  53459. disablePentagonBokeh(): void;
  53460. /**
  53461. * Enables noise blur
  53462. */
  53463. enableNoiseBlur(): void;
  53464. /**
  53465. * Disables noise blur
  53466. */
  53467. disableNoiseBlur(): void;
  53468. /**
  53469. * Sets the HighlightsGain amount
  53470. * @param amount amount of HighlightsGain
  53471. */
  53472. setHighlightsGain(amount: number): void;
  53473. /**
  53474. * Sets the HighlightsThreshold amount
  53475. * @param amount amount of HighlightsThreshold
  53476. */
  53477. setHighlightsThreshold(amount: number): void;
  53478. /**
  53479. * Disables highlights
  53480. */
  53481. disableHighlights(): void;
  53482. /**
  53483. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53484. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53485. */
  53486. dispose(disableDepthRender?: boolean): void;
  53487. private _createChromaticAberrationPostProcess;
  53488. private _createHighlightsPostProcess;
  53489. private _createDepthOfFieldPostProcess;
  53490. private _createGrainTexture;
  53491. }
  53492. }
  53493. declare module BABYLON {
  53494. /** @hidden */
  53495. export var ssao2PixelShader: {
  53496. name: string;
  53497. shader: string;
  53498. };
  53499. }
  53500. declare module BABYLON {
  53501. /** @hidden */
  53502. export var ssaoCombinePixelShader: {
  53503. name: string;
  53504. shader: string;
  53505. };
  53506. }
  53507. declare module BABYLON {
  53508. /**
  53509. * Render pipeline to produce ssao effect
  53510. */
  53511. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53512. /**
  53513. * @ignore
  53514. * The PassPostProcess id in the pipeline that contains the original scene color
  53515. */
  53516. SSAOOriginalSceneColorEffect: string;
  53517. /**
  53518. * @ignore
  53519. * The SSAO PostProcess id in the pipeline
  53520. */
  53521. SSAORenderEffect: string;
  53522. /**
  53523. * @ignore
  53524. * The horizontal blur PostProcess id in the pipeline
  53525. */
  53526. SSAOBlurHRenderEffect: string;
  53527. /**
  53528. * @ignore
  53529. * The vertical blur PostProcess id in the pipeline
  53530. */
  53531. SSAOBlurVRenderEffect: string;
  53532. /**
  53533. * @ignore
  53534. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53535. */
  53536. SSAOCombineRenderEffect: string;
  53537. /**
  53538. * The output strength of the SSAO post-process. Default value is 1.0.
  53539. */
  53540. totalStrength: number;
  53541. /**
  53542. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53543. */
  53544. maxZ: number;
  53545. /**
  53546. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53547. */
  53548. minZAspect: number;
  53549. private _samples;
  53550. /**
  53551. * Number of samples used for the SSAO calculations. Default value is 8
  53552. */
  53553. samples: number;
  53554. private _textureSamples;
  53555. /**
  53556. * Number of samples to use for antialiasing
  53557. */
  53558. textureSamples: number;
  53559. /**
  53560. * Ratio object used for SSAO ratio and blur ratio
  53561. */
  53562. private _ratio;
  53563. /**
  53564. * Dynamically generated sphere sampler.
  53565. */
  53566. private _sampleSphere;
  53567. /**
  53568. * Blur filter offsets
  53569. */
  53570. private _samplerOffsets;
  53571. private _expensiveBlur;
  53572. /**
  53573. * If bilateral blur should be used
  53574. */
  53575. expensiveBlur: boolean;
  53576. /**
  53577. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53578. */
  53579. radius: number;
  53580. /**
  53581. * The base color of the SSAO post-process
  53582. * The final result is "base + ssao" between [0, 1]
  53583. */
  53584. base: number;
  53585. /**
  53586. * Support test.
  53587. */
  53588. static readonly IsSupported: boolean;
  53589. private _scene;
  53590. private _depthTexture;
  53591. private _normalTexture;
  53592. private _randomTexture;
  53593. private _originalColorPostProcess;
  53594. private _ssaoPostProcess;
  53595. private _blurHPostProcess;
  53596. private _blurVPostProcess;
  53597. private _ssaoCombinePostProcess;
  53598. private _firstUpdate;
  53599. /**
  53600. * Gets active scene
  53601. */
  53602. readonly scene: Scene;
  53603. /**
  53604. * @constructor
  53605. * @param name The rendering pipeline name
  53606. * @param scene The scene linked to this pipeline
  53607. * @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 }
  53608. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53609. */
  53610. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53611. /**
  53612. * Get the class name
  53613. * @returns "SSAO2RenderingPipeline"
  53614. */
  53615. getClassName(): string;
  53616. /**
  53617. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53618. */
  53619. dispose(disableGeometryBufferRenderer?: boolean): void;
  53620. private _createBlurPostProcess;
  53621. /** @hidden */
  53622. _rebuild(): void;
  53623. private _bits;
  53624. private _radicalInverse_VdC;
  53625. private _hammersley;
  53626. private _hemisphereSample_uniform;
  53627. private _generateHemisphere;
  53628. private _createSSAOPostProcess;
  53629. private _createSSAOCombinePostProcess;
  53630. private _createRandomTexture;
  53631. /**
  53632. * Serialize the rendering pipeline (Used when exporting)
  53633. * @returns the serialized object
  53634. */
  53635. serialize(): any;
  53636. /**
  53637. * Parse the serialized pipeline
  53638. * @param source Source pipeline.
  53639. * @param scene The scene to load the pipeline to.
  53640. * @param rootUrl The URL of the serialized pipeline.
  53641. * @returns An instantiated pipeline from the serialized object.
  53642. */
  53643. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53644. }
  53645. }
  53646. declare module BABYLON {
  53647. /** @hidden */
  53648. export var ssaoPixelShader: {
  53649. name: string;
  53650. shader: string;
  53651. };
  53652. }
  53653. declare module BABYLON {
  53654. /**
  53655. * Render pipeline to produce ssao effect
  53656. */
  53657. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53658. /**
  53659. * @ignore
  53660. * The PassPostProcess id in the pipeline that contains the original scene color
  53661. */
  53662. SSAOOriginalSceneColorEffect: string;
  53663. /**
  53664. * @ignore
  53665. * The SSAO PostProcess id in the pipeline
  53666. */
  53667. SSAORenderEffect: string;
  53668. /**
  53669. * @ignore
  53670. * The horizontal blur PostProcess id in the pipeline
  53671. */
  53672. SSAOBlurHRenderEffect: string;
  53673. /**
  53674. * @ignore
  53675. * The vertical blur PostProcess id in the pipeline
  53676. */
  53677. SSAOBlurVRenderEffect: string;
  53678. /**
  53679. * @ignore
  53680. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53681. */
  53682. SSAOCombineRenderEffect: string;
  53683. /**
  53684. * The output strength of the SSAO post-process. Default value is 1.0.
  53685. */
  53686. totalStrength: number;
  53687. /**
  53688. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53689. */
  53690. radius: number;
  53691. /**
  53692. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53693. * Must not be equal to fallOff and superior to fallOff.
  53694. * Default value is 0.0075
  53695. */
  53696. area: number;
  53697. /**
  53698. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53699. * Must not be equal to area and inferior to area.
  53700. * Default value is 0.000001
  53701. */
  53702. fallOff: number;
  53703. /**
  53704. * The base color of the SSAO post-process
  53705. * The final result is "base + ssao" between [0, 1]
  53706. */
  53707. base: number;
  53708. private _scene;
  53709. private _depthTexture;
  53710. private _randomTexture;
  53711. private _originalColorPostProcess;
  53712. private _ssaoPostProcess;
  53713. private _blurHPostProcess;
  53714. private _blurVPostProcess;
  53715. private _ssaoCombinePostProcess;
  53716. private _firstUpdate;
  53717. /**
  53718. * Gets active scene
  53719. */
  53720. readonly scene: Scene;
  53721. /**
  53722. * @constructor
  53723. * @param name - The rendering pipeline name
  53724. * @param scene - The scene linked to this pipeline
  53725. * @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 }
  53726. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53727. */
  53728. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53729. /**
  53730. * Get the class name
  53731. * @returns "SSAORenderingPipeline"
  53732. */
  53733. getClassName(): string;
  53734. /**
  53735. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53736. */
  53737. dispose(disableDepthRender?: boolean): void;
  53738. private _createBlurPostProcess;
  53739. /** @hidden */
  53740. _rebuild(): void;
  53741. private _createSSAOPostProcess;
  53742. private _createSSAOCombinePostProcess;
  53743. private _createRandomTexture;
  53744. }
  53745. }
  53746. declare module BABYLON {
  53747. /** @hidden */
  53748. export var standardPixelShader: {
  53749. name: string;
  53750. shader: string;
  53751. };
  53752. }
  53753. declare module BABYLON {
  53754. /**
  53755. * Standard rendering pipeline
  53756. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53757. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53758. */
  53759. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53760. /**
  53761. * Public members
  53762. */
  53763. /**
  53764. * Post-process which contains the original scene color before the pipeline applies all the effects
  53765. */
  53766. originalPostProcess: Nullable<PostProcess>;
  53767. /**
  53768. * Post-process used to down scale an image x4
  53769. */
  53770. downSampleX4PostProcess: Nullable<PostProcess>;
  53771. /**
  53772. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53773. */
  53774. brightPassPostProcess: Nullable<PostProcess>;
  53775. /**
  53776. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53777. */
  53778. blurHPostProcesses: PostProcess[];
  53779. /**
  53780. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53781. */
  53782. blurVPostProcesses: PostProcess[];
  53783. /**
  53784. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53785. */
  53786. textureAdderPostProcess: Nullable<PostProcess>;
  53787. /**
  53788. * Post-process used to create volumetric lighting effect
  53789. */
  53790. volumetricLightPostProcess: Nullable<PostProcess>;
  53791. /**
  53792. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53793. */
  53794. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53795. /**
  53796. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53797. */
  53798. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53799. /**
  53800. * Post-process used to merge the volumetric light effect and the real scene color
  53801. */
  53802. volumetricLightMergePostProces: Nullable<PostProcess>;
  53803. /**
  53804. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53805. */
  53806. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53807. /**
  53808. * Base post-process used to calculate the average luminance of the final image for HDR
  53809. */
  53810. luminancePostProcess: Nullable<PostProcess>;
  53811. /**
  53812. * Post-processes used to create down sample post-processes in order to get
  53813. * the average luminance of the final image for HDR
  53814. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53815. */
  53816. luminanceDownSamplePostProcesses: PostProcess[];
  53817. /**
  53818. * Post-process used to create a HDR effect (light adaptation)
  53819. */
  53820. hdrPostProcess: Nullable<PostProcess>;
  53821. /**
  53822. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53823. */
  53824. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53825. /**
  53826. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53827. */
  53828. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53829. /**
  53830. * Post-process used to merge the final HDR post-process and the real scene color
  53831. */
  53832. hdrFinalPostProcess: Nullable<PostProcess>;
  53833. /**
  53834. * Post-process used to create a lens flare effect
  53835. */
  53836. lensFlarePostProcess: Nullable<PostProcess>;
  53837. /**
  53838. * Post-process that merges the result of the lens flare post-process and the real scene color
  53839. */
  53840. lensFlareComposePostProcess: Nullable<PostProcess>;
  53841. /**
  53842. * Post-process used to create a motion blur effect
  53843. */
  53844. motionBlurPostProcess: Nullable<PostProcess>;
  53845. /**
  53846. * Post-process used to create a depth of field effect
  53847. */
  53848. depthOfFieldPostProcess: Nullable<PostProcess>;
  53849. /**
  53850. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53851. */
  53852. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53853. /**
  53854. * Represents the brightness threshold in order to configure the illuminated surfaces
  53855. */
  53856. brightThreshold: number;
  53857. /**
  53858. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53859. */
  53860. blurWidth: number;
  53861. /**
  53862. * Sets if the blur for highlighted surfaces must be only horizontal
  53863. */
  53864. horizontalBlur: boolean;
  53865. /**
  53866. * Gets the overall exposure used by the pipeline
  53867. */
  53868. /**
  53869. * Sets the overall exposure used by the pipeline
  53870. */
  53871. exposure: number;
  53872. /**
  53873. * Texture used typically to simulate "dirty" on camera lens
  53874. */
  53875. lensTexture: Nullable<Texture>;
  53876. /**
  53877. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53878. */
  53879. volumetricLightCoefficient: number;
  53880. /**
  53881. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53882. */
  53883. volumetricLightPower: number;
  53884. /**
  53885. * Used the set the blur intensity to smooth the volumetric lights
  53886. */
  53887. volumetricLightBlurScale: number;
  53888. /**
  53889. * Light (spot or directional) used to generate the volumetric lights rays
  53890. * The source light must have a shadow generate so the pipeline can get its
  53891. * depth map
  53892. */
  53893. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53894. /**
  53895. * For eye adaptation, represents the minimum luminance the eye can see
  53896. */
  53897. hdrMinimumLuminance: number;
  53898. /**
  53899. * For eye adaptation, represents the decrease luminance speed
  53900. */
  53901. hdrDecreaseRate: number;
  53902. /**
  53903. * For eye adaptation, represents the increase luminance speed
  53904. */
  53905. hdrIncreaseRate: number;
  53906. /**
  53907. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53908. */
  53909. /**
  53910. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53911. */
  53912. hdrAutoExposure: boolean;
  53913. /**
  53914. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53915. */
  53916. lensColorTexture: Nullable<Texture>;
  53917. /**
  53918. * The overall strengh for the lens flare effect
  53919. */
  53920. lensFlareStrength: number;
  53921. /**
  53922. * Dispersion coefficient for lens flare ghosts
  53923. */
  53924. lensFlareGhostDispersal: number;
  53925. /**
  53926. * Main lens flare halo width
  53927. */
  53928. lensFlareHaloWidth: number;
  53929. /**
  53930. * Based on the lens distortion effect, defines how much the lens flare result
  53931. * is distorted
  53932. */
  53933. lensFlareDistortionStrength: number;
  53934. /**
  53935. * Lens star texture must be used to simulate rays on the flares and is available
  53936. * in the documentation
  53937. */
  53938. lensStarTexture: Nullable<Texture>;
  53939. /**
  53940. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53941. * flare effect by taking account of the dirt texture
  53942. */
  53943. lensFlareDirtTexture: Nullable<Texture>;
  53944. /**
  53945. * Represents the focal length for the depth of field effect
  53946. */
  53947. depthOfFieldDistance: number;
  53948. /**
  53949. * Represents the blur intensity for the blurred part of the depth of field effect
  53950. */
  53951. depthOfFieldBlurWidth: number;
  53952. /**
  53953. * For motion blur, defines how much the image is blurred by the movement
  53954. */
  53955. motionStrength: number;
  53956. /**
  53957. * List of animations for the pipeline (IAnimatable implementation)
  53958. */
  53959. animations: Animation[];
  53960. /**
  53961. * Private members
  53962. */
  53963. private _scene;
  53964. private _currentDepthOfFieldSource;
  53965. private _basePostProcess;
  53966. private _fixedExposure;
  53967. private _currentExposure;
  53968. private _hdrAutoExposure;
  53969. private _hdrCurrentLuminance;
  53970. private _floatTextureType;
  53971. private _ratio;
  53972. private _bloomEnabled;
  53973. private _depthOfFieldEnabled;
  53974. private _vlsEnabled;
  53975. private _lensFlareEnabled;
  53976. private _hdrEnabled;
  53977. private _motionBlurEnabled;
  53978. private _fxaaEnabled;
  53979. private _motionBlurSamples;
  53980. private _volumetricLightStepsCount;
  53981. private _samples;
  53982. /**
  53983. * @ignore
  53984. * Specifies if the bloom pipeline is enabled
  53985. */
  53986. BloomEnabled: boolean;
  53987. /**
  53988. * @ignore
  53989. * Specifies if the depth of field pipeline is enabed
  53990. */
  53991. DepthOfFieldEnabled: boolean;
  53992. /**
  53993. * @ignore
  53994. * Specifies if the lens flare pipeline is enabed
  53995. */
  53996. LensFlareEnabled: boolean;
  53997. /**
  53998. * @ignore
  53999. * Specifies if the HDR pipeline is enabled
  54000. */
  54001. HDREnabled: boolean;
  54002. /**
  54003. * @ignore
  54004. * Specifies if the volumetric lights scattering effect is enabled
  54005. */
  54006. VLSEnabled: boolean;
  54007. /**
  54008. * @ignore
  54009. * Specifies if the motion blur effect is enabled
  54010. */
  54011. MotionBlurEnabled: boolean;
  54012. /**
  54013. * Specifies if anti-aliasing is enabled
  54014. */
  54015. fxaaEnabled: boolean;
  54016. /**
  54017. * Specifies the number of steps used to calculate the volumetric lights
  54018. * Typically in interval [50, 200]
  54019. */
  54020. volumetricLightStepsCount: number;
  54021. /**
  54022. * Specifies the number of samples used for the motion blur effect
  54023. * Typically in interval [16, 64]
  54024. */
  54025. motionBlurSamples: number;
  54026. /**
  54027. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54028. */
  54029. samples: number;
  54030. /**
  54031. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54032. * @constructor
  54033. * @param name The rendering pipeline name
  54034. * @param scene The scene linked to this pipeline
  54035. * @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)
  54036. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54037. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54038. */
  54039. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54040. private _buildPipeline;
  54041. private _createDownSampleX4PostProcess;
  54042. private _createBrightPassPostProcess;
  54043. private _createBlurPostProcesses;
  54044. private _createTextureAdderPostProcess;
  54045. private _createVolumetricLightPostProcess;
  54046. private _createLuminancePostProcesses;
  54047. private _createHdrPostProcess;
  54048. private _createLensFlarePostProcess;
  54049. private _createDepthOfFieldPostProcess;
  54050. private _createMotionBlurPostProcess;
  54051. private _getDepthTexture;
  54052. private _disposePostProcesses;
  54053. /**
  54054. * Dispose of the pipeline and stop all post processes
  54055. */
  54056. dispose(): void;
  54057. /**
  54058. * Serialize the rendering pipeline (Used when exporting)
  54059. * @returns the serialized object
  54060. */
  54061. serialize(): any;
  54062. /**
  54063. * Parse the serialized pipeline
  54064. * @param source Source pipeline.
  54065. * @param scene The scene to load the pipeline to.
  54066. * @param rootUrl The URL of the serialized pipeline.
  54067. * @returns An instantiated pipeline from the serialized object.
  54068. */
  54069. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54070. /**
  54071. * Luminance steps
  54072. */
  54073. static LuminanceSteps: number;
  54074. }
  54075. }
  54076. declare module BABYLON {
  54077. /** @hidden */
  54078. export var tonemapPixelShader: {
  54079. name: string;
  54080. shader: string;
  54081. };
  54082. }
  54083. declare module BABYLON {
  54084. /** Defines operator used for tonemapping */
  54085. export enum TonemappingOperator {
  54086. /** Hable */
  54087. Hable = 0,
  54088. /** Reinhard */
  54089. Reinhard = 1,
  54090. /** HejiDawson */
  54091. HejiDawson = 2,
  54092. /** Photographic */
  54093. Photographic = 3
  54094. }
  54095. /**
  54096. * Defines a post process to apply tone mapping
  54097. */
  54098. export class TonemapPostProcess extends PostProcess {
  54099. private _operator;
  54100. /** Defines the required exposure adjustement */
  54101. exposureAdjustment: number;
  54102. /**
  54103. * Creates a new TonemapPostProcess
  54104. * @param name defines the name of the postprocess
  54105. * @param _operator defines the operator to use
  54106. * @param exposureAdjustment defines the required exposure adjustement
  54107. * @param camera defines the camera to use (can be null)
  54108. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54109. * @param engine defines the hosting engine (can be ignore if camera is set)
  54110. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54111. */
  54112. constructor(name: string, _operator: TonemappingOperator,
  54113. /** Defines the required exposure adjustement */
  54114. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /** @hidden */
  54119. export var depthVertexShader: {
  54120. name: string;
  54121. shader: string;
  54122. };
  54123. }
  54124. declare module BABYLON {
  54125. /** @hidden */
  54126. export var volumetricLightScatteringPixelShader: {
  54127. name: string;
  54128. shader: string;
  54129. };
  54130. }
  54131. declare module BABYLON {
  54132. /** @hidden */
  54133. export var volumetricLightScatteringPassPixelShader: {
  54134. name: string;
  54135. shader: string;
  54136. };
  54137. }
  54138. declare module BABYLON {
  54139. /**
  54140. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54141. */
  54142. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54143. private _volumetricLightScatteringPass;
  54144. private _volumetricLightScatteringRTT;
  54145. private _viewPort;
  54146. private _screenCoordinates;
  54147. private _cachedDefines;
  54148. /**
  54149. * If not undefined, the mesh position is computed from the attached node position
  54150. */
  54151. attachedNode: {
  54152. position: Vector3;
  54153. };
  54154. /**
  54155. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54156. */
  54157. customMeshPosition: Vector3;
  54158. /**
  54159. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54160. */
  54161. useCustomMeshPosition: boolean;
  54162. /**
  54163. * If the post-process should inverse the light scattering direction
  54164. */
  54165. invert: boolean;
  54166. /**
  54167. * The internal mesh used by the post-process
  54168. */
  54169. mesh: Mesh;
  54170. /**
  54171. * @hidden
  54172. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54173. */
  54174. useDiffuseColor: boolean;
  54175. /**
  54176. * Array containing the excluded meshes not rendered in the internal pass
  54177. */
  54178. excludedMeshes: AbstractMesh[];
  54179. /**
  54180. * Controls the overall intensity of the post-process
  54181. */
  54182. exposure: number;
  54183. /**
  54184. * Dissipates each sample's contribution in range [0, 1]
  54185. */
  54186. decay: number;
  54187. /**
  54188. * Controls the overall intensity of each sample
  54189. */
  54190. weight: number;
  54191. /**
  54192. * Controls the density of each sample
  54193. */
  54194. density: number;
  54195. /**
  54196. * @constructor
  54197. * @param name The post-process name
  54198. * @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)
  54199. * @param camera The camera that the post-process will be attached to
  54200. * @param mesh The mesh used to create the light scattering
  54201. * @param samples The post-process quality, default 100
  54202. * @param samplingModeThe post-process filtering mode
  54203. * @param engine The babylon engine
  54204. * @param reusable If the post-process is reusable
  54205. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54206. */
  54207. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54208. /**
  54209. * Returns the string "VolumetricLightScatteringPostProcess"
  54210. * @returns "VolumetricLightScatteringPostProcess"
  54211. */
  54212. getClassName(): string;
  54213. private _isReady;
  54214. /**
  54215. * Sets the new light position for light scattering effect
  54216. * @param position The new custom light position
  54217. */
  54218. setCustomMeshPosition(position: Vector3): void;
  54219. /**
  54220. * Returns the light position for light scattering effect
  54221. * @return Vector3 The custom light position
  54222. */
  54223. getCustomMeshPosition(): Vector3;
  54224. /**
  54225. * Disposes the internal assets and detaches the post-process from the camera
  54226. */
  54227. dispose(camera: Camera): void;
  54228. /**
  54229. * Returns the render target texture used by the post-process
  54230. * @return the render target texture used by the post-process
  54231. */
  54232. getPass(): RenderTargetTexture;
  54233. private _meshExcluded;
  54234. private _createPass;
  54235. private _updateMeshScreenCoordinates;
  54236. /**
  54237. * Creates a default mesh for the Volumeric Light Scattering post-process
  54238. * @param name The mesh name
  54239. * @param scene The scene where to create the mesh
  54240. * @return the default mesh
  54241. */
  54242. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54243. }
  54244. }
  54245. declare module BABYLON {
  54246. interface Scene {
  54247. /** @hidden (Backing field) */
  54248. _boundingBoxRenderer: BoundingBoxRenderer;
  54249. /** @hidden (Backing field) */
  54250. _forceShowBoundingBoxes: boolean;
  54251. /**
  54252. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54253. */
  54254. forceShowBoundingBoxes: boolean;
  54255. /**
  54256. * Gets the bounding box renderer associated with the scene
  54257. * @returns a BoundingBoxRenderer
  54258. */
  54259. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54260. }
  54261. interface AbstractMesh {
  54262. /** @hidden (Backing field) */
  54263. _showBoundingBox: boolean;
  54264. /**
  54265. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54266. */
  54267. showBoundingBox: boolean;
  54268. }
  54269. /**
  54270. * Component responsible of rendering the bounding box of the meshes in a scene.
  54271. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54272. */
  54273. export class BoundingBoxRenderer implements ISceneComponent {
  54274. /**
  54275. * The component name helpfull to identify the component in the list of scene components.
  54276. */
  54277. readonly name: string;
  54278. /**
  54279. * The scene the component belongs to.
  54280. */
  54281. scene: Scene;
  54282. /**
  54283. * Color of the bounding box lines placed in front of an object
  54284. */
  54285. frontColor: Color3;
  54286. /**
  54287. * Color of the bounding box lines placed behind an object
  54288. */
  54289. backColor: Color3;
  54290. /**
  54291. * Defines if the renderer should show the back lines or not
  54292. */
  54293. showBackLines: boolean;
  54294. /**
  54295. * @hidden
  54296. */
  54297. renderList: SmartArray<BoundingBox>;
  54298. private _colorShader;
  54299. private _vertexBuffers;
  54300. private _indexBuffer;
  54301. /**
  54302. * Instantiates a new bounding box renderer in a scene.
  54303. * @param scene the scene the renderer renders in
  54304. */
  54305. constructor(scene: Scene);
  54306. /**
  54307. * Registers the component in a given scene
  54308. */
  54309. register(): void;
  54310. private _evaluateSubMesh;
  54311. private _activeMesh;
  54312. private _prepareRessources;
  54313. private _createIndexBuffer;
  54314. /**
  54315. * Rebuilds the elements related to this component in case of
  54316. * context lost for instance.
  54317. */
  54318. rebuild(): void;
  54319. /**
  54320. * @hidden
  54321. */
  54322. reset(): void;
  54323. /**
  54324. * Render the bounding boxes of a specific rendering group
  54325. * @param renderingGroupId defines the rendering group to render
  54326. */
  54327. render(renderingGroupId: number): void;
  54328. /**
  54329. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54330. * @param mesh Define the mesh to render the occlusion bounding box for
  54331. */
  54332. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54333. /**
  54334. * Dispose and release the resources attached to this renderer.
  54335. */
  54336. dispose(): void;
  54337. }
  54338. }
  54339. declare module BABYLON {
  54340. /** @hidden */
  54341. export var depthPixelShader: {
  54342. name: string;
  54343. shader: string;
  54344. };
  54345. }
  54346. declare module BABYLON {
  54347. /**
  54348. * This represents a depth renderer in Babylon.
  54349. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54350. */
  54351. export class DepthRenderer {
  54352. private _scene;
  54353. private _depthMap;
  54354. private _effect;
  54355. private _cachedDefines;
  54356. private _camera;
  54357. /**
  54358. * Specifiess that the depth renderer will only be used within
  54359. * the camera it is created for.
  54360. * This can help forcing its rendering during the camera processing.
  54361. */
  54362. useOnlyInActiveCamera: boolean;
  54363. /** @hidden */
  54364. static _SceneComponentInitialization: (scene: Scene) => void;
  54365. /**
  54366. * Instantiates a depth renderer
  54367. * @param scene The scene the renderer belongs to
  54368. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54369. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54370. */
  54371. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54372. /**
  54373. * Creates the depth rendering effect and checks if the effect is ready.
  54374. * @param subMesh The submesh to be used to render the depth map of
  54375. * @param useInstances If multiple world instances should be used
  54376. * @returns if the depth renderer is ready to render the depth map
  54377. */
  54378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54379. /**
  54380. * Gets the texture which the depth map will be written to.
  54381. * @returns The depth map texture
  54382. */
  54383. getDepthMap(): RenderTargetTexture;
  54384. /**
  54385. * Disposes of the depth renderer.
  54386. */
  54387. dispose(): void;
  54388. }
  54389. }
  54390. declare module BABYLON {
  54391. interface Scene {
  54392. /** @hidden (Backing field) */
  54393. _depthRenderer: {
  54394. [id: string]: DepthRenderer;
  54395. };
  54396. /**
  54397. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54398. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54399. * @returns the created depth renderer
  54400. */
  54401. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54402. /**
  54403. * Disables a depth renderer for a given camera
  54404. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54405. */
  54406. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54407. }
  54408. /**
  54409. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54410. * in several rendering techniques.
  54411. */
  54412. export class DepthRendererSceneComponent implements ISceneComponent {
  54413. /**
  54414. * The component name helpfull to identify the component in the list of scene components.
  54415. */
  54416. readonly name: string;
  54417. /**
  54418. * The scene the component belongs to.
  54419. */
  54420. scene: Scene;
  54421. /**
  54422. * Creates a new instance of the component for the given scene
  54423. * @param scene Defines the scene to register the component in
  54424. */
  54425. constructor(scene: Scene);
  54426. /**
  54427. * Registers the component in a given scene
  54428. */
  54429. register(): void;
  54430. /**
  54431. * Rebuilds the elements related to this component in case of
  54432. * context lost for instance.
  54433. */
  54434. rebuild(): void;
  54435. /**
  54436. * Disposes the component and the associated ressources
  54437. */
  54438. dispose(): void;
  54439. private _gatherRenderTargets;
  54440. private _gatherActiveCameraRenderTargets;
  54441. }
  54442. }
  54443. declare module BABYLON {
  54444. /** @hidden */
  54445. export var outlinePixelShader: {
  54446. name: string;
  54447. shader: string;
  54448. };
  54449. }
  54450. declare module BABYLON {
  54451. /** @hidden */
  54452. export var outlineVertexShader: {
  54453. name: string;
  54454. shader: string;
  54455. };
  54456. }
  54457. declare module BABYLON {
  54458. interface Scene {
  54459. /** @hidden */
  54460. _outlineRenderer: OutlineRenderer;
  54461. /**
  54462. * Gets the outline renderer associated with the scene
  54463. * @returns a OutlineRenderer
  54464. */
  54465. getOutlineRenderer(): OutlineRenderer;
  54466. }
  54467. interface AbstractMesh {
  54468. /** @hidden (Backing field) */
  54469. _renderOutline: boolean;
  54470. /**
  54471. * Gets or sets a boolean indicating if the outline must be rendered as well
  54472. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54473. */
  54474. renderOutline: boolean;
  54475. /** @hidden (Backing field) */
  54476. _renderOverlay: boolean;
  54477. /**
  54478. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54479. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54480. */
  54481. renderOverlay: boolean;
  54482. }
  54483. /**
  54484. * This class is responsible to draw bothe outline/overlay of meshes.
  54485. * It should not be used directly but through the available method on mesh.
  54486. */
  54487. export class OutlineRenderer implements ISceneComponent {
  54488. /**
  54489. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54490. */
  54491. private static _StencilReference;
  54492. /**
  54493. * The name of the component. Each component must have a unique name.
  54494. */
  54495. name: string;
  54496. /**
  54497. * The scene the component belongs to.
  54498. */
  54499. scene: Scene;
  54500. /**
  54501. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54502. */
  54503. zOffset: number;
  54504. private _engine;
  54505. private _effect;
  54506. private _cachedDefines;
  54507. private _savedDepthWrite;
  54508. /**
  54509. * Instantiates a new outline renderer. (There could be only one per scene).
  54510. * @param scene Defines the scene it belongs to
  54511. */
  54512. constructor(scene: Scene);
  54513. /**
  54514. * Register the component to one instance of a scene.
  54515. */
  54516. register(): void;
  54517. /**
  54518. * Rebuilds the elements related to this component in case of
  54519. * context lost for instance.
  54520. */
  54521. rebuild(): void;
  54522. /**
  54523. * Disposes the component and the associated ressources.
  54524. */
  54525. dispose(): void;
  54526. /**
  54527. * Renders the outline in the canvas.
  54528. * @param subMesh Defines the sumesh to render
  54529. * @param batch Defines the batch of meshes in case of instances
  54530. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54531. */
  54532. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54533. /**
  54534. * Returns whether or not the outline renderer is ready for a given submesh.
  54535. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54536. * @param subMesh Defines the submesh to check readyness for
  54537. * @param useInstances Defines wheter wee are trying to render instances or not
  54538. * @returns true if ready otherwise false
  54539. */
  54540. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54541. private _beforeRenderingMesh;
  54542. private _afterRenderingMesh;
  54543. }
  54544. }
  54545. declare module BABYLON {
  54546. /**
  54547. * Defines the list of states available for a task inside a AssetsManager
  54548. */
  54549. export enum AssetTaskState {
  54550. /**
  54551. * Initialization
  54552. */
  54553. INIT = 0,
  54554. /**
  54555. * Running
  54556. */
  54557. RUNNING = 1,
  54558. /**
  54559. * Done
  54560. */
  54561. DONE = 2,
  54562. /**
  54563. * Error
  54564. */
  54565. ERROR = 3
  54566. }
  54567. /**
  54568. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54569. */
  54570. export abstract class AbstractAssetTask {
  54571. /**
  54572. * Task name
  54573. */ name: string;
  54574. /**
  54575. * Callback called when the task is successful
  54576. */
  54577. onSuccess: (task: any) => void;
  54578. /**
  54579. * Callback called when the task is not successful
  54580. */
  54581. onError: (task: any, message?: string, exception?: any) => void;
  54582. /**
  54583. * Creates a new AssetsManager
  54584. * @param name defines the name of the task
  54585. */
  54586. constructor(
  54587. /**
  54588. * Task name
  54589. */ name: string);
  54590. private _isCompleted;
  54591. private _taskState;
  54592. private _errorObject;
  54593. /**
  54594. * Get if the task is completed
  54595. */
  54596. readonly isCompleted: boolean;
  54597. /**
  54598. * Gets the current state of the task
  54599. */
  54600. readonly taskState: AssetTaskState;
  54601. /**
  54602. * Gets the current error object (if task is in error)
  54603. */
  54604. readonly errorObject: {
  54605. message?: string;
  54606. exception?: any;
  54607. };
  54608. /**
  54609. * Internal only
  54610. * @hidden
  54611. */
  54612. _setErrorObject(message?: string, exception?: any): void;
  54613. /**
  54614. * Execute the current task
  54615. * @param scene defines the scene where you want your assets to be loaded
  54616. * @param onSuccess is a callback called when the task is successfully executed
  54617. * @param onError is a callback called if an error occurs
  54618. */
  54619. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54620. /**
  54621. * Execute the current task
  54622. * @param scene defines the scene where you want your assets to be loaded
  54623. * @param onSuccess is a callback called when the task is successfully executed
  54624. * @param onError is a callback called if an error occurs
  54625. */
  54626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54627. /**
  54628. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54629. * This can be used with failed tasks that have the reason for failure fixed.
  54630. */
  54631. reset(): void;
  54632. private onErrorCallback;
  54633. private onDoneCallback;
  54634. }
  54635. /**
  54636. * Define the interface used by progress events raised during assets loading
  54637. */
  54638. export interface IAssetsProgressEvent {
  54639. /**
  54640. * Defines the number of remaining tasks to process
  54641. */
  54642. remainingCount: number;
  54643. /**
  54644. * Defines the total number of tasks
  54645. */
  54646. totalCount: number;
  54647. /**
  54648. * Defines the task that was just processed
  54649. */
  54650. task: AbstractAssetTask;
  54651. }
  54652. /**
  54653. * Class used to share progress information about assets loading
  54654. */
  54655. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54656. /**
  54657. * Defines the number of remaining tasks to process
  54658. */
  54659. remainingCount: number;
  54660. /**
  54661. * Defines the total number of tasks
  54662. */
  54663. totalCount: number;
  54664. /**
  54665. * Defines the task that was just processed
  54666. */
  54667. task: AbstractAssetTask;
  54668. /**
  54669. * Creates a AssetsProgressEvent
  54670. * @param remainingCount defines the number of remaining tasks to process
  54671. * @param totalCount defines the total number of tasks
  54672. * @param task defines the task that was just processed
  54673. */
  54674. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54675. }
  54676. /**
  54677. * Define a task used by AssetsManager to load meshes
  54678. */
  54679. export class MeshAssetTask extends AbstractAssetTask {
  54680. /**
  54681. * Defines the name of the task
  54682. */
  54683. name: string;
  54684. /**
  54685. * Defines the list of mesh's names you want to load
  54686. */
  54687. meshesNames: any;
  54688. /**
  54689. * Defines the root url to use as a base to load your meshes and associated resources
  54690. */
  54691. rootUrl: string;
  54692. /**
  54693. * Defines the filename of the scene to load from
  54694. */
  54695. sceneFilename: string;
  54696. /**
  54697. * Gets the list of loaded meshes
  54698. */
  54699. loadedMeshes: Array<AbstractMesh>;
  54700. /**
  54701. * Gets the list of loaded particle systems
  54702. */
  54703. loadedParticleSystems: Array<IParticleSystem>;
  54704. /**
  54705. * Gets the list of loaded skeletons
  54706. */
  54707. loadedSkeletons: Array<Skeleton>;
  54708. /**
  54709. * Gets the list of loaded animation groups
  54710. */
  54711. loadedAnimationGroups: Array<AnimationGroup>;
  54712. /**
  54713. * Callback called when the task is successful
  54714. */
  54715. onSuccess: (task: MeshAssetTask) => void;
  54716. /**
  54717. * Callback called when the task is successful
  54718. */
  54719. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54720. /**
  54721. * Creates a new MeshAssetTask
  54722. * @param name defines the name of the task
  54723. * @param meshesNames defines the list of mesh's names you want to load
  54724. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54725. * @param sceneFilename defines the filename of the scene to load from
  54726. */
  54727. constructor(
  54728. /**
  54729. * Defines the name of the task
  54730. */
  54731. name: string,
  54732. /**
  54733. * Defines the list of mesh's names you want to load
  54734. */
  54735. meshesNames: any,
  54736. /**
  54737. * Defines the root url to use as a base to load your meshes and associated resources
  54738. */
  54739. rootUrl: string,
  54740. /**
  54741. * Defines the filename of the scene to load from
  54742. */
  54743. sceneFilename: string);
  54744. /**
  54745. * Execute the current task
  54746. * @param scene defines the scene where you want your assets to be loaded
  54747. * @param onSuccess is a callback called when the task is successfully executed
  54748. * @param onError is a callback called if an error occurs
  54749. */
  54750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54751. }
  54752. /**
  54753. * Define a task used by AssetsManager to load text content
  54754. */
  54755. export class TextFileAssetTask extends AbstractAssetTask {
  54756. /**
  54757. * Defines the name of the task
  54758. */
  54759. name: string;
  54760. /**
  54761. * Defines the location of the file to load
  54762. */
  54763. url: string;
  54764. /**
  54765. * Gets the loaded text string
  54766. */
  54767. text: string;
  54768. /**
  54769. * Callback called when the task is successful
  54770. */
  54771. onSuccess: (task: TextFileAssetTask) => void;
  54772. /**
  54773. * Callback called when the task is successful
  54774. */
  54775. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54776. /**
  54777. * Creates a new TextFileAssetTask object
  54778. * @param name defines the name of the task
  54779. * @param url defines the location of the file to load
  54780. */
  54781. constructor(
  54782. /**
  54783. * Defines the name of the task
  54784. */
  54785. name: string,
  54786. /**
  54787. * Defines the location of the file to load
  54788. */
  54789. url: string);
  54790. /**
  54791. * Execute the current task
  54792. * @param scene defines the scene where you want your assets to be loaded
  54793. * @param onSuccess is a callback called when the task is successfully executed
  54794. * @param onError is a callback called if an error occurs
  54795. */
  54796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54797. }
  54798. /**
  54799. * Define a task used by AssetsManager to load binary data
  54800. */
  54801. export class BinaryFileAssetTask extends AbstractAssetTask {
  54802. /**
  54803. * Defines the name of the task
  54804. */
  54805. name: string;
  54806. /**
  54807. * Defines the location of the file to load
  54808. */
  54809. url: string;
  54810. /**
  54811. * Gets the lodaded data (as an array buffer)
  54812. */
  54813. data: ArrayBuffer;
  54814. /**
  54815. * Callback called when the task is successful
  54816. */
  54817. onSuccess: (task: BinaryFileAssetTask) => void;
  54818. /**
  54819. * Callback called when the task is successful
  54820. */
  54821. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54822. /**
  54823. * Creates a new BinaryFileAssetTask object
  54824. * @param name defines the name of the new task
  54825. * @param url defines the location of the file to load
  54826. */
  54827. constructor(
  54828. /**
  54829. * Defines the name of the task
  54830. */
  54831. name: string,
  54832. /**
  54833. * Defines the location of the file to load
  54834. */
  54835. url: string);
  54836. /**
  54837. * Execute the current task
  54838. * @param scene defines the scene where you want your assets to be loaded
  54839. * @param onSuccess is a callback called when the task is successfully executed
  54840. * @param onError is a callback called if an error occurs
  54841. */
  54842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54843. }
  54844. /**
  54845. * Define a task used by AssetsManager to load images
  54846. */
  54847. export class ImageAssetTask extends AbstractAssetTask {
  54848. /**
  54849. * Defines the name of the task
  54850. */
  54851. name: string;
  54852. /**
  54853. * Defines the location of the image to load
  54854. */
  54855. url: string;
  54856. /**
  54857. * Gets the loaded images
  54858. */
  54859. image: HTMLImageElement;
  54860. /**
  54861. * Callback called when the task is successful
  54862. */
  54863. onSuccess: (task: ImageAssetTask) => void;
  54864. /**
  54865. * Callback called when the task is successful
  54866. */
  54867. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54868. /**
  54869. * Creates a new ImageAssetTask
  54870. * @param name defines the name of the task
  54871. * @param url defines the location of the image to load
  54872. */
  54873. constructor(
  54874. /**
  54875. * Defines the name of the task
  54876. */
  54877. name: string,
  54878. /**
  54879. * Defines the location of the image to load
  54880. */
  54881. url: string);
  54882. /**
  54883. * Execute the current task
  54884. * @param scene defines the scene where you want your assets to be loaded
  54885. * @param onSuccess is a callback called when the task is successfully executed
  54886. * @param onError is a callback called if an error occurs
  54887. */
  54888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54889. }
  54890. /**
  54891. * Defines the interface used by texture loading tasks
  54892. */
  54893. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54894. /**
  54895. * Gets the loaded texture
  54896. */
  54897. texture: TEX;
  54898. }
  54899. /**
  54900. * Define a task used by AssetsManager to load 2D textures
  54901. */
  54902. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54903. /**
  54904. * Defines the name of the task
  54905. */
  54906. name: string;
  54907. /**
  54908. * Defines the location of the file to load
  54909. */
  54910. url: string;
  54911. /**
  54912. * Defines if mipmap should not be generated (default is false)
  54913. */
  54914. noMipmap?: boolean | undefined;
  54915. /**
  54916. * Defines if texture must be inverted on Y axis (default is false)
  54917. */
  54918. invertY?: boolean | undefined;
  54919. /**
  54920. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54921. */
  54922. samplingMode: number;
  54923. /**
  54924. * Gets the loaded texture
  54925. */
  54926. texture: Texture;
  54927. /**
  54928. * Callback called when the task is successful
  54929. */
  54930. onSuccess: (task: TextureAssetTask) => void;
  54931. /**
  54932. * Callback called when the task is successful
  54933. */
  54934. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54935. /**
  54936. * Creates a new TextureAssetTask object
  54937. * @param name defines the name of the task
  54938. * @param url defines the location of the file to load
  54939. * @param noMipmap defines if mipmap should not be generated (default is false)
  54940. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54941. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54942. */
  54943. constructor(
  54944. /**
  54945. * Defines the name of the task
  54946. */
  54947. name: string,
  54948. /**
  54949. * Defines the location of the file to load
  54950. */
  54951. url: string,
  54952. /**
  54953. * Defines if mipmap should not be generated (default is false)
  54954. */
  54955. noMipmap?: boolean | undefined,
  54956. /**
  54957. * Defines if texture must be inverted on Y axis (default is false)
  54958. */
  54959. invertY?: boolean | undefined,
  54960. /**
  54961. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54962. */
  54963. samplingMode?: number);
  54964. /**
  54965. * Execute the current task
  54966. * @param scene defines the scene where you want your assets to be loaded
  54967. * @param onSuccess is a callback called when the task is successfully executed
  54968. * @param onError is a callback called if an error occurs
  54969. */
  54970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54971. }
  54972. /**
  54973. * Define a task used by AssetsManager to load cube textures
  54974. */
  54975. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54976. /**
  54977. * Defines the name of the task
  54978. */
  54979. name: string;
  54980. /**
  54981. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54982. */
  54983. url: string;
  54984. /**
  54985. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54986. */
  54987. extensions?: string[] | undefined;
  54988. /**
  54989. * Defines if mipmaps should not be generated (default is false)
  54990. */
  54991. noMipmap?: boolean | undefined;
  54992. /**
  54993. * Defines the explicit list of files (undefined by default)
  54994. */
  54995. files?: string[] | undefined;
  54996. /**
  54997. * Gets the loaded texture
  54998. */
  54999. texture: CubeTexture;
  55000. /**
  55001. * Callback called when the task is successful
  55002. */
  55003. onSuccess: (task: CubeTextureAssetTask) => void;
  55004. /**
  55005. * Callback called when the task is successful
  55006. */
  55007. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55008. /**
  55009. * Creates a new CubeTextureAssetTask
  55010. * @param name defines the name of the task
  55011. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55012. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55013. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55014. * @param files defines the explicit list of files (undefined by default)
  55015. */
  55016. constructor(
  55017. /**
  55018. * Defines the name of the task
  55019. */
  55020. name: string,
  55021. /**
  55022. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55023. */
  55024. url: string,
  55025. /**
  55026. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55027. */
  55028. extensions?: string[] | undefined,
  55029. /**
  55030. * Defines if mipmaps should not be generated (default is false)
  55031. */
  55032. noMipmap?: boolean | undefined,
  55033. /**
  55034. * Defines the explicit list of files (undefined by default)
  55035. */
  55036. files?: string[] | undefined);
  55037. /**
  55038. * Execute the current task
  55039. * @param scene defines the scene where you want your assets to be loaded
  55040. * @param onSuccess is a callback called when the task is successfully executed
  55041. * @param onError is a callback called if an error occurs
  55042. */
  55043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55044. }
  55045. /**
  55046. * Define a task used by AssetsManager to load HDR cube textures
  55047. */
  55048. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55049. /**
  55050. * Defines the name of the task
  55051. */
  55052. name: string;
  55053. /**
  55054. * Defines the location of the file to load
  55055. */
  55056. url: string;
  55057. /**
  55058. * Defines the desired size (the more it increases the longer the generation will be)
  55059. */
  55060. size: number;
  55061. /**
  55062. * Defines if mipmaps should not be generated (default is false)
  55063. */
  55064. noMipmap: boolean;
  55065. /**
  55066. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55067. */
  55068. generateHarmonics: boolean;
  55069. /**
  55070. * 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)
  55071. */
  55072. gammaSpace: boolean;
  55073. /**
  55074. * Internal Use Only
  55075. */
  55076. reserved: boolean;
  55077. /**
  55078. * Gets the loaded texture
  55079. */
  55080. texture: HDRCubeTexture;
  55081. /**
  55082. * Callback called when the task is successful
  55083. */
  55084. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55085. /**
  55086. * Callback called when the task is successful
  55087. */
  55088. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55089. /**
  55090. * Creates a new HDRCubeTextureAssetTask object
  55091. * @param name defines the name of the task
  55092. * @param url defines the location of the file to load
  55093. * @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.
  55094. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55095. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55096. * @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)
  55097. * @param reserved Internal use only
  55098. */
  55099. constructor(
  55100. /**
  55101. * Defines the name of the task
  55102. */
  55103. name: string,
  55104. /**
  55105. * Defines the location of the file to load
  55106. */
  55107. url: string,
  55108. /**
  55109. * Defines the desired size (the more it increases the longer the generation will be)
  55110. */
  55111. size: number,
  55112. /**
  55113. * Defines if mipmaps should not be generated (default is false)
  55114. */
  55115. noMipmap?: boolean,
  55116. /**
  55117. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55118. */
  55119. generateHarmonics?: boolean,
  55120. /**
  55121. * 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)
  55122. */
  55123. gammaSpace?: boolean,
  55124. /**
  55125. * Internal Use Only
  55126. */
  55127. reserved?: boolean);
  55128. /**
  55129. * Execute the current task
  55130. * @param scene defines the scene where you want your assets to be loaded
  55131. * @param onSuccess is a callback called when the task is successfully executed
  55132. * @param onError is a callback called if an error occurs
  55133. */
  55134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55135. }
  55136. /**
  55137. * Define a task used by AssetsManager to load Equirectangular cube textures
  55138. */
  55139. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55140. /**
  55141. * Defines the name of the task
  55142. */
  55143. name: string;
  55144. /**
  55145. * Defines the location of the file to load
  55146. */
  55147. url: string;
  55148. /**
  55149. * Defines the desired size (the more it increases the longer the generation will be)
  55150. */
  55151. size: number;
  55152. /**
  55153. * Defines if mipmaps should not be generated (default is false)
  55154. */
  55155. noMipmap: boolean;
  55156. /**
  55157. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55158. * but the standard material would require them in Gamma space) (default is true)
  55159. */
  55160. gammaSpace: boolean;
  55161. /**
  55162. * Gets the loaded texture
  55163. */
  55164. texture: EquiRectangularCubeTexture;
  55165. /**
  55166. * Callback called when the task is successful
  55167. */
  55168. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55169. /**
  55170. * Callback called when the task is successful
  55171. */
  55172. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55173. /**
  55174. * Creates a new EquiRectangularCubeTextureAssetTask object
  55175. * @param name defines the name of the task
  55176. * @param url defines the location of the file to load
  55177. * @param size defines the desired size (the more it increases the longer the generation will be)
  55178. * If the size is omitted this implies you are using a preprocessed cubemap.
  55179. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55180. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55181. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55182. * (default is true)
  55183. */
  55184. constructor(
  55185. /**
  55186. * Defines the name of the task
  55187. */
  55188. name: string,
  55189. /**
  55190. * Defines the location of the file to load
  55191. */
  55192. url: string,
  55193. /**
  55194. * Defines the desired size (the more it increases the longer the generation will be)
  55195. */
  55196. size: number,
  55197. /**
  55198. * Defines if mipmaps should not be generated (default is false)
  55199. */
  55200. noMipmap?: boolean,
  55201. /**
  55202. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55203. * but the standard material would require them in Gamma space) (default is true)
  55204. */
  55205. gammaSpace?: boolean);
  55206. /**
  55207. * Execute the current task
  55208. * @param scene defines the scene where you want your assets to be loaded
  55209. * @param onSuccess is a callback called when the task is successfully executed
  55210. * @param onError is a callback called if an error occurs
  55211. */
  55212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55213. }
  55214. /**
  55215. * This class can be used to easily import assets into a scene
  55216. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55217. */
  55218. export class AssetsManager {
  55219. private _scene;
  55220. private _isLoading;
  55221. protected _tasks: AbstractAssetTask[];
  55222. protected _waitingTasksCount: number;
  55223. protected _totalTasksCount: number;
  55224. /**
  55225. * Callback called when all tasks are processed
  55226. */
  55227. onFinish: (tasks: AbstractAssetTask[]) => void;
  55228. /**
  55229. * Callback called when a task is successful
  55230. */
  55231. onTaskSuccess: (task: AbstractAssetTask) => void;
  55232. /**
  55233. * Callback called when a task had an error
  55234. */
  55235. onTaskError: (task: AbstractAssetTask) => void;
  55236. /**
  55237. * Callback called when a task is done (whatever the result is)
  55238. */
  55239. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55240. /**
  55241. * Observable called when all tasks are processed
  55242. */
  55243. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55244. /**
  55245. * Observable called when a task had an error
  55246. */
  55247. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55248. /**
  55249. * Observable called when all tasks were executed
  55250. */
  55251. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55252. /**
  55253. * Observable called when a task is done (whatever the result is)
  55254. */
  55255. onProgressObservable: Observable<IAssetsProgressEvent>;
  55256. /**
  55257. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55259. */
  55260. useDefaultLoadingScreen: boolean;
  55261. /**
  55262. * Creates a new AssetsManager
  55263. * @param scene defines the scene to work on
  55264. */
  55265. constructor(scene: Scene);
  55266. /**
  55267. * Add a MeshAssetTask to the list of active tasks
  55268. * @param taskName defines the name of the new task
  55269. * @param meshesNames defines the name of meshes to load
  55270. * @param rootUrl defines the root url to use to locate files
  55271. * @param sceneFilename defines the filename of the scene file
  55272. * @returns a new MeshAssetTask object
  55273. */
  55274. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55275. /**
  55276. * Add a TextFileAssetTask to the list of active tasks
  55277. * @param taskName defines the name of the new task
  55278. * @param url defines the url of the file to load
  55279. * @returns a new TextFileAssetTask object
  55280. */
  55281. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55282. /**
  55283. * Add a BinaryFileAssetTask to the list of active tasks
  55284. * @param taskName defines the name of the new task
  55285. * @param url defines the url of the file to load
  55286. * @returns a new BinaryFileAssetTask object
  55287. */
  55288. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55289. /**
  55290. * Add a ImageAssetTask to the list of active tasks
  55291. * @param taskName defines the name of the new task
  55292. * @param url defines the url of the file to load
  55293. * @returns a new ImageAssetTask object
  55294. */
  55295. addImageTask(taskName: string, url: string): ImageAssetTask;
  55296. /**
  55297. * Add a TextureAssetTask to the list of active tasks
  55298. * @param taskName defines the name of the new task
  55299. * @param url defines the url of the file to load
  55300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55301. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55303. * @returns a new TextureAssetTask object
  55304. */
  55305. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55306. /**
  55307. * Add a CubeTextureAssetTask to the list of active tasks
  55308. * @param taskName defines the name of the new task
  55309. * @param url defines the url of the file to load
  55310. * @param extensions defines the extension to use to load the cube map (can be null)
  55311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55312. * @param files defines the list of files to load (can be null)
  55313. * @returns a new CubeTextureAssetTask object
  55314. */
  55315. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55316. /**
  55317. *
  55318. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55319. * @param taskName defines the name of the new task
  55320. * @param url defines the url of the file to load
  55321. * @param size defines the size you want for the cubemap (can be null)
  55322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55323. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55324. * @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)
  55325. * @param reserved Internal use only
  55326. * @returns a new HDRCubeTextureAssetTask object
  55327. */
  55328. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55329. /**
  55330. *
  55331. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55332. * @param taskName defines the name of the new task
  55333. * @param url defines the url of the file to load
  55334. * @param size defines the size you want for the cubemap (can be null)
  55335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55336. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55337. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55338. * @returns a new EquiRectangularCubeTextureAssetTask object
  55339. */
  55340. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55341. /**
  55342. * Remove a task from the assets manager.
  55343. * @param task the task to remove
  55344. */
  55345. removeTask(task: AbstractAssetTask): void;
  55346. private _decreaseWaitingTasksCount;
  55347. private _runTask;
  55348. /**
  55349. * Reset the AssetsManager and remove all tasks
  55350. * @return the current instance of the AssetsManager
  55351. */
  55352. reset(): AssetsManager;
  55353. /**
  55354. * Start the loading process
  55355. * @return the current instance of the AssetsManager
  55356. */
  55357. load(): AssetsManager;
  55358. /**
  55359. * Start the loading process as an async operation
  55360. * @return a promise returning the list of failed tasks
  55361. */
  55362. loadAsync(): Promise<void>;
  55363. }
  55364. }
  55365. declare module BABYLON {
  55366. /**
  55367. * Wrapper class for promise with external resolve and reject.
  55368. */
  55369. export class Deferred<T> {
  55370. /**
  55371. * The promise associated with this deferred object.
  55372. */
  55373. readonly promise: Promise<T>;
  55374. private _resolve;
  55375. private _reject;
  55376. /**
  55377. * The resolve method of the promise associated with this deferred object.
  55378. */
  55379. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55380. /**
  55381. * The reject method of the promise associated with this deferred object.
  55382. */
  55383. readonly reject: (reason?: any) => void;
  55384. /**
  55385. * Constructor for this deferred object.
  55386. */
  55387. constructor();
  55388. }
  55389. }
  55390. declare module BABYLON {
  55391. /**
  55392. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55393. */
  55394. export class MeshExploder {
  55395. private _centerMesh;
  55396. private _meshes;
  55397. private _meshesOrigins;
  55398. private _toCenterVectors;
  55399. private _scaledDirection;
  55400. private _newPosition;
  55401. private _centerPosition;
  55402. /**
  55403. * Explodes meshes from a center mesh.
  55404. * @param meshes The meshes to explode.
  55405. * @param centerMesh The mesh to be center of explosion.
  55406. */
  55407. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55408. private _setCenterMesh;
  55409. /**
  55410. * Get class name
  55411. * @returns "MeshExploder"
  55412. */
  55413. getClassName(): string;
  55414. /**
  55415. * "Exploded meshes"
  55416. * @returns Array of meshes with the centerMesh at index 0.
  55417. */
  55418. getMeshes(): Array<Mesh>;
  55419. /**
  55420. * Explodes meshes giving a specific direction
  55421. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55422. */
  55423. explode(direction?: number): void;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Class used to help managing file picking and drag'n'drop
  55429. */
  55430. export class FilesInput {
  55431. /**
  55432. * List of files ready to be loaded
  55433. */
  55434. static readonly FilesToLoad: {
  55435. [key: string]: File;
  55436. };
  55437. /**
  55438. * Callback called when a file is processed
  55439. */
  55440. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55441. private _engine;
  55442. private _currentScene;
  55443. private _sceneLoadedCallback;
  55444. private _progressCallback;
  55445. private _additionalRenderLoopLogicCallback;
  55446. private _textureLoadingCallback;
  55447. private _startingProcessingFilesCallback;
  55448. private _onReloadCallback;
  55449. private _errorCallback;
  55450. private _elementToMonitor;
  55451. private _sceneFileToLoad;
  55452. private _filesToLoad;
  55453. /**
  55454. * Creates a new FilesInput
  55455. * @param engine defines the rendering engine
  55456. * @param scene defines the hosting scene
  55457. * @param sceneLoadedCallback callback called when scene is loaded
  55458. * @param progressCallback callback called to track progress
  55459. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55460. * @param textureLoadingCallback callback called when a texture is loading
  55461. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55462. * @param onReloadCallback callback called when a reload is requested
  55463. * @param errorCallback callback call if an error occurs
  55464. */
  55465. 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);
  55466. private _dragEnterHandler;
  55467. private _dragOverHandler;
  55468. private _dropHandler;
  55469. /**
  55470. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55471. * @param elementToMonitor defines the DOM element to track
  55472. */
  55473. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55474. /**
  55475. * Release all associated resources
  55476. */
  55477. dispose(): void;
  55478. private renderFunction;
  55479. private drag;
  55480. private drop;
  55481. private _traverseFolder;
  55482. private _processFiles;
  55483. /**
  55484. * Load files from a drop event
  55485. * @param event defines the drop event to use as source
  55486. */
  55487. loadFiles(event: any): void;
  55488. private _processReload;
  55489. /**
  55490. * Reload the current scene from the loaded files
  55491. */
  55492. reload(): void;
  55493. }
  55494. }
  55495. declare module BABYLON {
  55496. /**
  55497. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55499. */
  55500. export class SceneOptimization {
  55501. /**
  55502. * Defines the priority of this optimization (0 by default which means first in the list)
  55503. */
  55504. priority: number;
  55505. /**
  55506. * Gets a string describing the action executed by the current optimization
  55507. * @returns description string
  55508. */
  55509. getDescription(): string;
  55510. /**
  55511. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55512. * @param scene defines the current scene where to apply this optimization
  55513. * @param optimizer defines the current optimizer
  55514. * @returns true if everything that can be done was applied
  55515. */
  55516. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55517. /**
  55518. * Creates the SceneOptimization object
  55519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55520. * @param desc defines the description associated with the optimization
  55521. */
  55522. constructor(
  55523. /**
  55524. * Defines the priority of this optimization (0 by default which means first in the list)
  55525. */
  55526. priority?: number);
  55527. }
  55528. /**
  55529. * Defines an optimization used to reduce the size of render target textures
  55530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55531. */
  55532. export class TextureOptimization extends SceneOptimization {
  55533. /**
  55534. * Defines the priority of this optimization (0 by default which means first in the list)
  55535. */
  55536. priority: number;
  55537. /**
  55538. * 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
  55539. */
  55540. maximumSize: number;
  55541. /**
  55542. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55543. */
  55544. step: number;
  55545. /**
  55546. * Gets a string describing the action executed by the current optimization
  55547. * @returns description string
  55548. */
  55549. getDescription(): string;
  55550. /**
  55551. * Creates the TextureOptimization object
  55552. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55553. * @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
  55554. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55555. */
  55556. constructor(
  55557. /**
  55558. * Defines the priority of this optimization (0 by default which means first in the list)
  55559. */
  55560. priority?: number,
  55561. /**
  55562. * 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
  55563. */
  55564. maximumSize?: number,
  55565. /**
  55566. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55567. */
  55568. step?: number);
  55569. /**
  55570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55571. * @param scene defines the current scene where to apply this optimization
  55572. * @param optimizer defines the current optimizer
  55573. * @returns true if everything that can be done was applied
  55574. */
  55575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55576. }
  55577. /**
  55578. * Defines an optimization used to increase or decrease the rendering resolution
  55579. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55580. */
  55581. export class HardwareScalingOptimization extends SceneOptimization {
  55582. /**
  55583. * Defines the priority of this optimization (0 by default which means first in the list)
  55584. */
  55585. priority: number;
  55586. /**
  55587. * Defines the maximum scale to use (2 by default)
  55588. */
  55589. maximumScale: number;
  55590. /**
  55591. * Defines the step to use between two passes (0.5 by default)
  55592. */
  55593. step: number;
  55594. private _currentScale;
  55595. private _directionOffset;
  55596. /**
  55597. * Gets a string describing the action executed by the current optimization
  55598. * @return description string
  55599. */
  55600. getDescription(): string;
  55601. /**
  55602. * Creates the HardwareScalingOptimization object
  55603. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55604. * @param maximumScale defines the maximum scale to use (2 by default)
  55605. * @param step defines the step to use between two passes (0.5 by default)
  55606. */
  55607. constructor(
  55608. /**
  55609. * Defines the priority of this optimization (0 by default which means first in the list)
  55610. */
  55611. priority?: number,
  55612. /**
  55613. * Defines the maximum scale to use (2 by default)
  55614. */
  55615. maximumScale?: number,
  55616. /**
  55617. * Defines the step to use between two passes (0.5 by default)
  55618. */
  55619. step?: number);
  55620. /**
  55621. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55622. * @param scene defines the current scene where to apply this optimization
  55623. * @param optimizer defines the current optimizer
  55624. * @returns true if everything that can be done was applied
  55625. */
  55626. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55627. }
  55628. /**
  55629. * Defines an optimization used to remove shadows
  55630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55631. */
  55632. export class ShadowsOptimization extends SceneOptimization {
  55633. /**
  55634. * Gets a string describing the action executed by the current optimization
  55635. * @return description string
  55636. */
  55637. getDescription(): string;
  55638. /**
  55639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55640. * @param scene defines the current scene where to apply this optimization
  55641. * @param optimizer defines the current optimizer
  55642. * @returns true if everything that can be done was applied
  55643. */
  55644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55645. }
  55646. /**
  55647. * Defines an optimization used to turn post-processes off
  55648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55649. */
  55650. export class PostProcessesOptimization extends SceneOptimization {
  55651. /**
  55652. * Gets a string describing the action executed by the current optimization
  55653. * @return description string
  55654. */
  55655. getDescription(): string;
  55656. /**
  55657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55658. * @param scene defines the current scene where to apply this optimization
  55659. * @param optimizer defines the current optimizer
  55660. * @returns true if everything that can be done was applied
  55661. */
  55662. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55663. }
  55664. /**
  55665. * Defines an optimization used to turn lens flares off
  55666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55667. */
  55668. export class LensFlaresOptimization extends SceneOptimization {
  55669. /**
  55670. * Gets a string describing the action executed by the current optimization
  55671. * @return description string
  55672. */
  55673. getDescription(): string;
  55674. /**
  55675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55676. * @param scene defines the current scene where to apply this optimization
  55677. * @param optimizer defines the current optimizer
  55678. * @returns true if everything that can be done was applied
  55679. */
  55680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55681. }
  55682. /**
  55683. * Defines an optimization based on user defined callback.
  55684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55685. */
  55686. export class CustomOptimization extends SceneOptimization {
  55687. /**
  55688. * Callback called to apply the custom optimization.
  55689. */
  55690. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55691. /**
  55692. * Callback called to get custom description
  55693. */
  55694. onGetDescription: () => string;
  55695. /**
  55696. * Gets a string describing the action executed by the current optimization
  55697. * @returns description string
  55698. */
  55699. getDescription(): string;
  55700. /**
  55701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55702. * @param scene defines the current scene where to apply this optimization
  55703. * @param optimizer defines the current optimizer
  55704. * @returns true if everything that can be done was applied
  55705. */
  55706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55707. }
  55708. /**
  55709. * Defines an optimization used to turn particles off
  55710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55711. */
  55712. export class ParticlesOptimization extends SceneOptimization {
  55713. /**
  55714. * Gets a string describing the action executed by the current optimization
  55715. * @return description string
  55716. */
  55717. getDescription(): string;
  55718. /**
  55719. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55720. * @param scene defines the current scene where to apply this optimization
  55721. * @param optimizer defines the current optimizer
  55722. * @returns true if everything that can be done was applied
  55723. */
  55724. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55725. }
  55726. /**
  55727. * Defines an optimization used to turn render targets off
  55728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55729. */
  55730. export class RenderTargetsOptimization extends SceneOptimization {
  55731. /**
  55732. * Gets a string describing the action executed by the current optimization
  55733. * @return description string
  55734. */
  55735. getDescription(): string;
  55736. /**
  55737. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55738. * @param scene defines the current scene where to apply this optimization
  55739. * @param optimizer defines the current optimizer
  55740. * @returns true if everything that can be done was applied
  55741. */
  55742. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55743. }
  55744. /**
  55745. * Defines an optimization used to merge meshes with compatible materials
  55746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55747. */
  55748. export class MergeMeshesOptimization extends SceneOptimization {
  55749. private static _UpdateSelectionTree;
  55750. /**
  55751. * Gets or sets a boolean which defines if optimization octree has to be updated
  55752. */
  55753. /**
  55754. * Gets or sets a boolean which defines if optimization octree has to be updated
  55755. */
  55756. static UpdateSelectionTree: boolean;
  55757. /**
  55758. * Gets a string describing the action executed by the current optimization
  55759. * @return description string
  55760. */
  55761. getDescription(): string;
  55762. private _canBeMerged;
  55763. /**
  55764. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55765. * @param scene defines the current scene where to apply this optimization
  55766. * @param optimizer defines the current optimizer
  55767. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55768. * @returns true if everything that can be done was applied
  55769. */
  55770. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55771. }
  55772. /**
  55773. * Defines a list of options used by SceneOptimizer
  55774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55775. */
  55776. export class SceneOptimizerOptions {
  55777. /**
  55778. * Defines the target frame rate to reach (60 by default)
  55779. */
  55780. targetFrameRate: number;
  55781. /**
  55782. * Defines the interval between two checkes (2000ms by default)
  55783. */
  55784. trackerDuration: number;
  55785. /**
  55786. * Gets the list of optimizations to apply
  55787. */
  55788. optimizations: SceneOptimization[];
  55789. /**
  55790. * Creates a new list of options used by SceneOptimizer
  55791. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55792. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55793. */
  55794. constructor(
  55795. /**
  55796. * Defines the target frame rate to reach (60 by default)
  55797. */
  55798. targetFrameRate?: number,
  55799. /**
  55800. * Defines the interval between two checkes (2000ms by default)
  55801. */
  55802. trackerDuration?: number);
  55803. /**
  55804. * Add a new optimization
  55805. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55806. * @returns the current SceneOptimizerOptions
  55807. */
  55808. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55809. /**
  55810. * Add a new custom optimization
  55811. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55812. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55813. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55814. * @returns the current SceneOptimizerOptions
  55815. */
  55816. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55817. /**
  55818. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55819. * @param targetFrameRate defines the target frame rate (60 by default)
  55820. * @returns a SceneOptimizerOptions object
  55821. */
  55822. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55823. /**
  55824. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55825. * @param targetFrameRate defines the target frame rate (60 by default)
  55826. * @returns a SceneOptimizerOptions object
  55827. */
  55828. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55829. /**
  55830. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55831. * @param targetFrameRate defines the target frame rate (60 by default)
  55832. * @returns a SceneOptimizerOptions object
  55833. */
  55834. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55835. }
  55836. /**
  55837. * Class used to run optimizations in order to reach a target frame rate
  55838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55839. */
  55840. export class SceneOptimizer implements IDisposable {
  55841. private _isRunning;
  55842. private _options;
  55843. private _scene;
  55844. private _currentPriorityLevel;
  55845. private _targetFrameRate;
  55846. private _trackerDuration;
  55847. private _currentFrameRate;
  55848. private _sceneDisposeObserver;
  55849. private _improvementMode;
  55850. /**
  55851. * Defines an observable called when the optimizer reaches the target frame rate
  55852. */
  55853. onSuccessObservable: Observable<SceneOptimizer>;
  55854. /**
  55855. * Defines an observable called when the optimizer enables an optimization
  55856. */
  55857. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55858. /**
  55859. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55860. */
  55861. onFailureObservable: Observable<SceneOptimizer>;
  55862. /**
  55863. * Gets a boolean indicating if the optimizer is in improvement mode
  55864. */
  55865. readonly isInImprovementMode: boolean;
  55866. /**
  55867. * Gets the current priority level (0 at start)
  55868. */
  55869. readonly currentPriorityLevel: number;
  55870. /**
  55871. * Gets the current frame rate checked by the SceneOptimizer
  55872. */
  55873. readonly currentFrameRate: number;
  55874. /**
  55875. * Gets or sets the current target frame rate (60 by default)
  55876. */
  55877. /**
  55878. * Gets or sets the current target frame rate (60 by default)
  55879. */
  55880. targetFrameRate: number;
  55881. /**
  55882. * Gets or sets the current interval between two checks (every 2000ms by default)
  55883. */
  55884. /**
  55885. * Gets or sets the current interval between two checks (every 2000ms by default)
  55886. */
  55887. trackerDuration: number;
  55888. /**
  55889. * Gets the list of active optimizations
  55890. */
  55891. readonly optimizations: SceneOptimization[];
  55892. /**
  55893. * Creates a new SceneOptimizer
  55894. * @param scene defines the scene to work on
  55895. * @param options defines the options to use with the SceneOptimizer
  55896. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55897. * @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)
  55898. */
  55899. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55900. /**
  55901. * Stops the current optimizer
  55902. */
  55903. stop(): void;
  55904. /**
  55905. * Reset the optimizer to initial step (current priority level = 0)
  55906. */
  55907. reset(): void;
  55908. /**
  55909. * Start the optimizer. By default it will try to reach a specific framerate
  55910. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55911. */
  55912. start(): void;
  55913. private _checkCurrentState;
  55914. /**
  55915. * Release all resources
  55916. */
  55917. dispose(): void;
  55918. /**
  55919. * Helper function to create a SceneOptimizer with one single line of code
  55920. * @param scene defines the scene to work on
  55921. * @param options defines the options to use with the SceneOptimizer
  55922. * @param onSuccess defines a callback to call on success
  55923. * @param onFailure defines a callback to call on failure
  55924. * @returns the new SceneOptimizer object
  55925. */
  55926. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55927. }
  55928. }
  55929. declare module BABYLON {
  55930. /**
  55931. * Class used to serialize a scene into a string
  55932. */
  55933. export class SceneSerializer {
  55934. /**
  55935. * Clear cache used by a previous serialization
  55936. */
  55937. static ClearCache(): void;
  55938. /**
  55939. * Serialize a scene into a JSON compatible object
  55940. * @param scene defines the scene to serialize
  55941. * @returns a JSON compatible object
  55942. */
  55943. static Serialize(scene: Scene): any;
  55944. /**
  55945. * Serialize a mesh into a JSON compatible object
  55946. * @param toSerialize defines the mesh to serialize
  55947. * @param withParents defines if parents must be serialized as well
  55948. * @param withChildren defines if children must be serialized as well
  55949. * @returns a JSON compatible object
  55950. */
  55951. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55952. }
  55953. }
  55954. declare module BABYLON {
  55955. /**
  55956. * Class used to host texture specific utilities
  55957. */
  55958. export class TextureTools {
  55959. /**
  55960. * Uses the GPU to create a copy texture rescaled at a given size
  55961. * @param texture Texture to copy from
  55962. * @param width defines the desired width
  55963. * @param height defines the desired height
  55964. * @param useBilinearMode defines if bilinear mode has to be used
  55965. * @return the generated texture
  55966. */
  55967. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55968. }
  55969. }
  55970. declare module BABYLON {
  55971. /**
  55972. * This represents the different options avilable for the video capture.
  55973. */
  55974. export interface VideoRecorderOptions {
  55975. /** Defines the mime type of the video */
  55976. mimeType: string;
  55977. /** Defines the video the video should be recorded at */
  55978. fps: number;
  55979. /** Defines the chunk size for the recording data */
  55980. recordChunckSize: number;
  55981. /** The audio tracks to attach to the record */
  55982. audioTracks?: MediaStreamTrack[];
  55983. }
  55984. /**
  55985. * This can helps recording videos from BabylonJS.
  55986. * This is based on the available WebRTC functionalities of the browser.
  55987. *
  55988. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55989. */
  55990. export class VideoRecorder {
  55991. private static readonly _defaultOptions;
  55992. /**
  55993. * Returns wehther or not the VideoRecorder is available in your browser.
  55994. * @param engine Defines the Babylon Engine to check the support for
  55995. * @returns true if supported otherwise false
  55996. */
  55997. static IsSupported(engine: Engine): boolean;
  55998. private readonly _options;
  55999. private _canvas;
  56000. private _mediaRecorder;
  56001. private _recordedChunks;
  56002. private _fileName;
  56003. private _resolve;
  56004. private _reject;
  56005. /**
  56006. * True wether a recording is already in progress.
  56007. */
  56008. readonly isRecording: boolean;
  56009. /**
  56010. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56011. * a video file.
  56012. * @param engine Defines the BabylonJS Engine you wish to record
  56013. * @param options Defines options that can be used to customized the capture
  56014. */
  56015. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56016. /**
  56017. * Stops the current recording before the default capture timeout passed in the startRecording
  56018. * functions.
  56019. */
  56020. stopRecording(): void;
  56021. /**
  56022. * Starts recording the canvas for a max duration specified in parameters.
  56023. * @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.
  56024. * @param maxDuration Defines the maximum recording time in seconds.
  56025. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56026. * @return a promise callback at the end of the recording with the video data in Blob.
  56027. */
  56028. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56029. /**
  56030. * Releases internal resources used during the recording.
  56031. */
  56032. dispose(): void;
  56033. private _handleDataAvailable;
  56034. private _handleError;
  56035. private _handleStop;
  56036. }
  56037. }
  56038. declare module BABYLON {
  56039. /**
  56040. * Class containing a set of static utilities functions for screenshots
  56041. */
  56042. export class ScreenshotTools {
  56043. /**
  56044. * Captures a screenshot of the current rendering
  56045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56046. * @param engine defines the rendering engine
  56047. * @param camera defines the source camera
  56048. * @param size This parameter can be set to a single number or to an object with the
  56049. * following (optional) properties: precision, width, height. If a single number is passed,
  56050. * it will be used for both width and height. If an object is passed, the screenshot size
  56051. * will be derived from the parameters. The precision property is a multiplier allowing
  56052. * rendering at a higher or lower resolution
  56053. * @param successCallback defines the callback receives a single parameter which contains the
  56054. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56055. * src parameter of an <img> to display it
  56056. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56057. * Check your browser for supported MIME types
  56058. */
  56059. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56060. /**
  56061. * Generates an image screenshot from the specified camera.
  56062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56063. * @param engine The engine to use for rendering
  56064. * @param camera The camera to use for rendering
  56065. * @param size This parameter can be set to a single number or to an object with the
  56066. * following (optional) properties: precision, width, height. If a single number is passed,
  56067. * it will be used for both width and height. If an object is passed, the screenshot size
  56068. * will be derived from the parameters. The precision property is a multiplier allowing
  56069. * rendering at a higher or lower resolution
  56070. * @param successCallback The callback receives a single parameter which contains the
  56071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56072. * src parameter of an <img> to display it
  56073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56074. * Check your browser for supported MIME types
  56075. * @param samples Texture samples (default: 1)
  56076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56077. * @param fileName A name for for the downloaded file.
  56078. */
  56079. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56080. }
  56081. }
  56082. declare module BABYLON {
  56083. /**
  56084. * A cursor which tracks a point on a path
  56085. */
  56086. export class PathCursor {
  56087. private path;
  56088. /**
  56089. * Stores path cursor callbacks for when an onchange event is triggered
  56090. */
  56091. private _onchange;
  56092. /**
  56093. * The value of the path cursor
  56094. */
  56095. value: number;
  56096. /**
  56097. * The animation array of the path cursor
  56098. */
  56099. animations: Animation[];
  56100. /**
  56101. * Initializes the path cursor
  56102. * @param path The path to track
  56103. */
  56104. constructor(path: Path2);
  56105. /**
  56106. * Gets the cursor point on the path
  56107. * @returns A point on the path cursor at the cursor location
  56108. */
  56109. getPoint(): Vector3;
  56110. /**
  56111. * Moves the cursor ahead by the step amount
  56112. * @param step The amount to move the cursor forward
  56113. * @returns This path cursor
  56114. */
  56115. moveAhead(step?: number): PathCursor;
  56116. /**
  56117. * Moves the cursor behind by the step amount
  56118. * @param step The amount to move the cursor back
  56119. * @returns This path cursor
  56120. */
  56121. moveBack(step?: number): PathCursor;
  56122. /**
  56123. * Moves the cursor by the step amount
  56124. * If the step amount is greater than one, an exception is thrown
  56125. * @param step The amount to move the cursor
  56126. * @returns This path cursor
  56127. */
  56128. move(step: number): PathCursor;
  56129. /**
  56130. * Ensures that the value is limited between zero and one
  56131. * @returns This path cursor
  56132. */
  56133. private ensureLimits;
  56134. /**
  56135. * Runs onchange callbacks on change (used by the animation engine)
  56136. * @returns This path cursor
  56137. */
  56138. private raiseOnChange;
  56139. /**
  56140. * Executes a function on change
  56141. * @param f A path cursor onchange callback
  56142. * @returns This path cursor
  56143. */
  56144. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56145. }
  56146. }
  56147. declare module BABYLON {
  56148. /** @hidden */
  56149. export var blurPixelShader: {
  56150. name: string;
  56151. shader: string;
  56152. };
  56153. }
  56154. declare module BABYLON {
  56155. /** @hidden */
  56156. export var bones300Declaration: {
  56157. name: string;
  56158. shader: string;
  56159. };
  56160. }
  56161. declare module BABYLON {
  56162. /** @hidden */
  56163. export var instances300Declaration: {
  56164. name: string;
  56165. shader: string;
  56166. };
  56167. }
  56168. declare module BABYLON {
  56169. /** @hidden */
  56170. export var pointCloudVertexDeclaration: {
  56171. name: string;
  56172. shader: string;
  56173. };
  56174. }
  56175. // Mixins
  56176. interface Window {
  56177. mozIndexedDB: IDBFactory;
  56178. webkitIndexedDB: IDBFactory;
  56179. msIndexedDB: IDBFactory;
  56180. webkitURL: typeof URL;
  56181. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56182. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56183. WebGLRenderingContext: WebGLRenderingContext;
  56184. MSGesture: MSGesture;
  56185. CANNON: any;
  56186. AudioContext: AudioContext;
  56187. webkitAudioContext: AudioContext;
  56188. PointerEvent: any;
  56189. Math: Math;
  56190. Uint8Array: Uint8ArrayConstructor;
  56191. Float32Array: Float32ArrayConstructor;
  56192. mozURL: typeof URL;
  56193. msURL: typeof URL;
  56194. VRFrameData: any; // WebVR, from specs 1.1
  56195. DracoDecoderModule: any;
  56196. setImmediate(handler: (...args: any[]) => void): number;
  56197. }
  56198. interface HTMLCanvasElement {
  56199. requestPointerLock(): void;
  56200. msRequestPointerLock?(): void;
  56201. mozRequestPointerLock?(): void;
  56202. webkitRequestPointerLock?(): void;
  56203. /** Track wether a record is in progress */
  56204. isRecording: boolean;
  56205. /** Capture Stream method defined by some browsers */
  56206. captureStream(fps?: number): MediaStream;
  56207. }
  56208. interface CanvasRenderingContext2D {
  56209. msImageSmoothingEnabled: boolean;
  56210. }
  56211. interface MouseEvent {
  56212. mozMovementX: number;
  56213. mozMovementY: number;
  56214. webkitMovementX: number;
  56215. webkitMovementY: number;
  56216. msMovementX: number;
  56217. msMovementY: number;
  56218. }
  56219. interface Navigator {
  56220. mozGetVRDevices: (any: any) => any;
  56221. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56222. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56223. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56224. webkitGetGamepads(): Gamepad[];
  56225. msGetGamepads(): Gamepad[];
  56226. webkitGamepads(): Gamepad[];
  56227. }
  56228. interface HTMLVideoElement {
  56229. mozSrcObject: any;
  56230. }
  56231. interface Math {
  56232. fround(x: number): number;
  56233. imul(a: number, b: number): number;
  56234. }
  56235. interface WebGLProgram {
  56236. context?: WebGLRenderingContext;
  56237. vertexShader?: WebGLShader;
  56238. fragmentShader?: WebGLShader;
  56239. isParallelCompiled: boolean;
  56240. onCompiled?: () => void;
  56241. }
  56242. interface WebGLRenderingContext {
  56243. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56244. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56245. vertexAttribDivisor(index: number, divisor: number): void;
  56246. createVertexArray(): any;
  56247. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56248. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56249. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56250. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56251. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56252. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56253. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56254. // Queries
  56255. createQuery(): WebGLQuery;
  56256. deleteQuery(query: WebGLQuery): void;
  56257. beginQuery(target: number, query: WebGLQuery): void;
  56258. endQuery(target: number): void;
  56259. getQueryParameter(query: WebGLQuery, pname: number): any;
  56260. getQuery(target: number, pname: number): any;
  56261. MAX_SAMPLES: number;
  56262. RGBA8: number;
  56263. READ_FRAMEBUFFER: number;
  56264. DRAW_FRAMEBUFFER: number;
  56265. UNIFORM_BUFFER: number;
  56266. HALF_FLOAT_OES: number;
  56267. RGBA16F: number;
  56268. RGBA32F: number;
  56269. R32F: number;
  56270. RG32F: number;
  56271. RGB32F: number;
  56272. R16F: number;
  56273. RG16F: number;
  56274. RGB16F: number;
  56275. RED: number;
  56276. RG: number;
  56277. R8: number;
  56278. RG8: number;
  56279. UNSIGNED_INT_24_8: number;
  56280. DEPTH24_STENCIL8: number;
  56281. /* Multiple Render Targets */
  56282. drawBuffers(buffers: number[]): void;
  56283. readBuffer(src: number): void;
  56284. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56285. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56286. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56287. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56288. // Occlusion Query
  56289. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56290. ANY_SAMPLES_PASSED: number;
  56291. QUERY_RESULT_AVAILABLE: number;
  56292. QUERY_RESULT: number;
  56293. }
  56294. interface WebGLBuffer {
  56295. references: number;
  56296. capacity: number;
  56297. is32Bits: boolean;
  56298. }
  56299. interface WebGLProgram {
  56300. transformFeedback?: WebGLTransformFeedback | null;
  56301. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56302. }
  56303. interface EXT_disjoint_timer_query {
  56304. QUERY_COUNTER_BITS_EXT: number;
  56305. TIME_ELAPSED_EXT: number;
  56306. TIMESTAMP_EXT: number;
  56307. GPU_DISJOINT_EXT: number;
  56308. QUERY_RESULT_EXT: number;
  56309. QUERY_RESULT_AVAILABLE_EXT: number;
  56310. queryCounterEXT(query: WebGLQuery, target: number): void;
  56311. createQueryEXT(): WebGLQuery;
  56312. beginQueryEXT(target: number, query: WebGLQuery): void;
  56313. endQueryEXT(target: number): void;
  56314. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56315. deleteQueryEXT(query: WebGLQuery): void;
  56316. }
  56317. interface WebGLUniformLocation {
  56318. _currentState: any;
  56319. }
  56320. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56321. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56322. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56323. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56324. interface WebGLRenderingContext {
  56325. readonly RASTERIZER_DISCARD: number;
  56326. readonly DEPTH_COMPONENT24: number;
  56327. readonly TEXTURE_3D: number;
  56328. readonly TEXTURE_2D_ARRAY: number;
  56329. readonly TEXTURE_COMPARE_FUNC: number;
  56330. readonly TEXTURE_COMPARE_MODE: number;
  56331. readonly COMPARE_REF_TO_TEXTURE: number;
  56332. readonly TEXTURE_WRAP_R: number;
  56333. readonly HALF_FLOAT: number;
  56334. readonly RGB8: number;
  56335. readonly RED_INTEGER: number;
  56336. readonly RG_INTEGER: number;
  56337. readonly RGB_INTEGER: number;
  56338. readonly RGBA_INTEGER: number;
  56339. readonly R8_SNORM: number;
  56340. readonly RG8_SNORM: number;
  56341. readonly RGB8_SNORM: number;
  56342. readonly RGBA8_SNORM: number;
  56343. readonly R8I: number;
  56344. readonly RG8I: number;
  56345. readonly RGB8I: number;
  56346. readonly RGBA8I: number;
  56347. readonly R8UI: number;
  56348. readonly RG8UI: number;
  56349. readonly RGB8UI: number;
  56350. readonly RGBA8UI: number;
  56351. readonly R16I: number;
  56352. readonly RG16I: number;
  56353. readonly RGB16I: number;
  56354. readonly RGBA16I: number;
  56355. readonly R16UI: number;
  56356. readonly RG16UI: number;
  56357. readonly RGB16UI: number;
  56358. readonly RGBA16UI: number;
  56359. readonly R32I: number;
  56360. readonly RG32I: number;
  56361. readonly RGB32I: number;
  56362. readonly RGBA32I: number;
  56363. readonly R32UI: number;
  56364. readonly RG32UI: number;
  56365. readonly RGB32UI: number;
  56366. readonly RGBA32UI: number;
  56367. readonly RGB10_A2UI: number;
  56368. readonly R11F_G11F_B10F: number;
  56369. readonly RGB9_E5: number;
  56370. readonly RGB10_A2: number;
  56371. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56372. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56373. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56374. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56375. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56376. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56377. 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;
  56378. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56379. readonly TRANSFORM_FEEDBACK: number;
  56380. readonly INTERLEAVED_ATTRIBS: number;
  56381. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56382. createTransformFeedback(): WebGLTransformFeedback;
  56383. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56384. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56385. beginTransformFeedback(primitiveMode: number): void;
  56386. endTransformFeedback(): void;
  56387. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56388. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56389. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56390. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56391. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56392. }
  56393. interface ImageBitmap {
  56394. readonly width: number;
  56395. readonly height: number;
  56396. close(): void;
  56397. }
  56398. interface WebGLQuery extends WebGLObject {
  56399. }
  56400. declare var WebGLQuery: {
  56401. prototype: WebGLQuery;
  56402. new(): WebGLQuery;
  56403. };
  56404. interface WebGLSampler extends WebGLObject {
  56405. }
  56406. declare var WebGLSampler: {
  56407. prototype: WebGLSampler;
  56408. new(): WebGLSampler;
  56409. };
  56410. interface WebGLSync extends WebGLObject {
  56411. }
  56412. declare var WebGLSync: {
  56413. prototype: WebGLSync;
  56414. new(): WebGLSync;
  56415. };
  56416. interface WebGLTransformFeedback extends WebGLObject {
  56417. }
  56418. declare var WebGLTransformFeedback: {
  56419. prototype: WebGLTransformFeedback;
  56420. new(): WebGLTransformFeedback;
  56421. };
  56422. interface WebGLVertexArrayObject extends WebGLObject {
  56423. }
  56424. declare var WebGLVertexArrayObject: {
  56425. prototype: WebGLVertexArrayObject;
  56426. new(): WebGLVertexArrayObject;
  56427. };
  56428. // Type definitions for WebVR API
  56429. // Project: https://w3c.github.io/webvr/
  56430. // Definitions by: six a <https://github.com/lostfictions>
  56431. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56432. interface VRDisplay extends EventTarget {
  56433. /**
  56434. * Dictionary of capabilities describing the VRDisplay.
  56435. */
  56436. readonly capabilities: VRDisplayCapabilities;
  56437. /**
  56438. * z-depth defining the far plane of the eye view frustum
  56439. * enables mapping of values in the render target depth
  56440. * attachment to scene coordinates. Initially set to 10000.0.
  56441. */
  56442. depthFar: number;
  56443. /**
  56444. * z-depth defining the near plane of the eye view frustum
  56445. * enables mapping of values in the render target depth
  56446. * attachment to scene coordinates. Initially set to 0.01.
  56447. */
  56448. depthNear: number;
  56449. /**
  56450. * An identifier for this distinct VRDisplay. Used as an
  56451. * association point in the Gamepad API.
  56452. */
  56453. readonly displayId: number;
  56454. /**
  56455. * A display name, a user-readable name identifying it.
  56456. */
  56457. readonly displayName: string;
  56458. readonly isConnected: boolean;
  56459. readonly isPresenting: boolean;
  56460. /**
  56461. * If this VRDisplay supports room-scale experiences, the optional
  56462. * stage attribute contains details on the room-scale parameters.
  56463. */
  56464. readonly stageParameters: VRStageParameters | null;
  56465. /**
  56466. * Passing the value returned by `requestAnimationFrame` to
  56467. * `cancelAnimationFrame` will unregister the callback.
  56468. * @param handle Define the hanle of the request to cancel
  56469. */
  56470. cancelAnimationFrame(handle: number): void;
  56471. /**
  56472. * Stops presenting to the VRDisplay.
  56473. * @returns a promise to know when it stopped
  56474. */
  56475. exitPresent(): Promise<void>;
  56476. /**
  56477. * Return the current VREyeParameters for the given eye.
  56478. * @param whichEye Define the eye we want the parameter for
  56479. * @returns the eye parameters
  56480. */
  56481. getEyeParameters(whichEye: string): VREyeParameters;
  56482. /**
  56483. * Populates the passed VRFrameData with the information required to render
  56484. * the current frame.
  56485. * @param frameData Define the data structure to populate
  56486. * @returns true if ok otherwise false
  56487. */
  56488. getFrameData(frameData: VRFrameData): boolean;
  56489. /**
  56490. * Get the layers currently being presented.
  56491. * @returns the list of VR layers
  56492. */
  56493. getLayers(): VRLayer[];
  56494. /**
  56495. * Return a VRPose containing the future predicted pose of the VRDisplay
  56496. * when the current frame will be presented. The value returned will not
  56497. * change until JavaScript has returned control to the browser.
  56498. *
  56499. * The VRPose will contain the position, orientation, velocity,
  56500. * and acceleration of each of these properties.
  56501. * @returns the pose object
  56502. */
  56503. getPose(): VRPose;
  56504. /**
  56505. * Return the current instantaneous pose of the VRDisplay, with no
  56506. * prediction applied.
  56507. * @returns the current instantaneous pose
  56508. */
  56509. getImmediatePose(): VRPose;
  56510. /**
  56511. * The callback passed to `requestAnimationFrame` will be called
  56512. * any time a new frame should be rendered. When the VRDisplay is
  56513. * presenting the callback will be called at the native refresh
  56514. * rate of the HMD. When not presenting this function acts
  56515. * identically to how window.requestAnimationFrame acts. Content should
  56516. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56517. * asynchronously from other displays and at differing refresh rates.
  56518. * @param callback Define the eaction to run next frame
  56519. * @returns the request handle it
  56520. */
  56521. requestAnimationFrame(callback: FrameRequestCallback): number;
  56522. /**
  56523. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56524. * Repeat calls while already presenting will update the VRLayers being displayed.
  56525. * @param layers Define the list of layer to present
  56526. * @returns a promise to know when the request has been fulfilled
  56527. */
  56528. requestPresent(layers: VRLayer[]): Promise<void>;
  56529. /**
  56530. * Reset the pose for this display, treating its current position and
  56531. * orientation as the "origin/zero" values. VRPose.position,
  56532. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56533. * updated when calling resetPose(). This should be called in only
  56534. * sitting-space experiences.
  56535. */
  56536. resetPose(): void;
  56537. /**
  56538. * The VRLayer provided to the VRDisplay will be captured and presented
  56539. * in the HMD. Calling this function has the same effect on the source
  56540. * canvas as any other operation that uses its source image, and canvases
  56541. * created without preserveDrawingBuffer set to true will be cleared.
  56542. * @param pose Define the pose to submit
  56543. */
  56544. submitFrame(pose?: VRPose): void;
  56545. }
  56546. declare var VRDisplay: {
  56547. prototype: VRDisplay;
  56548. new(): VRDisplay;
  56549. };
  56550. interface VRLayer {
  56551. leftBounds?: number[] | Float32Array | null;
  56552. rightBounds?: number[] | Float32Array | null;
  56553. source?: HTMLCanvasElement | null;
  56554. }
  56555. interface VRDisplayCapabilities {
  56556. readonly canPresent: boolean;
  56557. readonly hasExternalDisplay: boolean;
  56558. readonly hasOrientation: boolean;
  56559. readonly hasPosition: boolean;
  56560. readonly maxLayers: number;
  56561. }
  56562. interface VREyeParameters {
  56563. /** @deprecated */
  56564. readonly fieldOfView: VRFieldOfView;
  56565. readonly offset: Float32Array;
  56566. readonly renderHeight: number;
  56567. readonly renderWidth: number;
  56568. }
  56569. interface VRFieldOfView {
  56570. readonly downDegrees: number;
  56571. readonly leftDegrees: number;
  56572. readonly rightDegrees: number;
  56573. readonly upDegrees: number;
  56574. }
  56575. interface VRFrameData {
  56576. readonly leftProjectionMatrix: Float32Array;
  56577. readonly leftViewMatrix: Float32Array;
  56578. readonly pose: VRPose;
  56579. readonly rightProjectionMatrix: Float32Array;
  56580. readonly rightViewMatrix: Float32Array;
  56581. readonly timestamp: number;
  56582. }
  56583. interface VRPose {
  56584. readonly angularAcceleration: Float32Array | null;
  56585. readonly angularVelocity: Float32Array | null;
  56586. readonly linearAcceleration: Float32Array | null;
  56587. readonly linearVelocity: Float32Array | null;
  56588. readonly orientation: Float32Array | null;
  56589. readonly position: Float32Array | null;
  56590. readonly timestamp: number;
  56591. }
  56592. interface VRStageParameters {
  56593. sittingToStandingTransform?: Float32Array;
  56594. sizeX?: number;
  56595. sizeY?: number;
  56596. }
  56597. interface Navigator {
  56598. getVRDisplays(): Promise<VRDisplay[]>;
  56599. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56600. }
  56601. interface Window {
  56602. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56603. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56604. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56605. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56606. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56607. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56608. }
  56609. interface Gamepad {
  56610. readonly displayId: number;
  56611. }
  56612. interface XRDevice {
  56613. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56614. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56615. }
  56616. interface XRSession {
  56617. getInputSources(): Array<any>;
  56618. baseLayer: XRWebGLLayer;
  56619. requestFrameOfReference(type: string): Promise<void>;
  56620. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56621. end(): Promise<void>;
  56622. requestAnimationFrame: Function;
  56623. addEventListener: Function;
  56624. }
  56625. interface XRSessionCreationOptions {
  56626. outputContext?: WebGLRenderingContext | null;
  56627. immersive?: boolean;
  56628. environmentIntegration?: boolean;
  56629. }
  56630. interface XRLayer {
  56631. getViewport: Function;
  56632. framebufferWidth: number;
  56633. framebufferHeight: number;
  56634. }
  56635. interface XRView {
  56636. projectionMatrix: Float32Array;
  56637. }
  56638. interface XRFrame {
  56639. getDevicePose: Function;
  56640. getInputPose: Function;
  56641. views: Array<XRView>;
  56642. baseLayer: XRLayer;
  56643. }
  56644. interface XRFrameOfReference {
  56645. }
  56646. interface XRWebGLLayer extends XRLayer {
  56647. framebuffer: WebGLFramebuffer;
  56648. }
  56649. declare var XRWebGLLayer: {
  56650. prototype: XRWebGLLayer;
  56651. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56652. };