babylon.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4310. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Moves the observable to the top of the observer list making it get called first when notified
  4354. * @param observer the observer to move
  4355. */
  4356. makeObserverTopPriority(observer: Observer<T>): void;
  4357. /**
  4358. * Moves the observable to the bottom of the observer list making it get called last when notified
  4359. * @param observer the observer to move
  4360. */
  4361. makeObserverBottomPriority(observer: Observer<T>): void;
  4362. /**
  4363. * Notify all Observers by calling their respective callback with the given data
  4364. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4365. * @param eventData defines the data to send to all observers
  4366. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4367. * @param target defines the original target of the state
  4368. * @param currentTarget defines the current target of the state
  4369. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4370. */
  4371. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4372. /**
  4373. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4374. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4375. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4376. * and it is crucial that all callbacks will be executed.
  4377. * The order of the callbacks is kept, callbacks are not executed parallel.
  4378. *
  4379. * @param eventData The data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. * @param target defines the callback target (see EventState)
  4382. * @param currentTarget defines he current object in the bubbling phase
  4383. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4384. */
  4385. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4386. /**
  4387. * Notify a specific observer
  4388. * @param observer defines the observer to notify
  4389. * @param eventData defines the data to be sent to each callback
  4390. * @param mask is used to filter observers defaults to -1
  4391. */
  4392. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4393. /**
  4394. * Gets a boolean indicating if the observable has at least one observer
  4395. * @returns true is the Observable has at least one Observer registered
  4396. */
  4397. hasObservers(): boolean;
  4398. /**
  4399. * Clear the list of observers
  4400. */
  4401. clear(): void;
  4402. /**
  4403. * Clone the current observable
  4404. * @returns a new observable
  4405. */
  4406. clone(): Observable<T>;
  4407. /**
  4408. * Does this observable handles observer registered with a given mask
  4409. * @param mask defines the mask to be tested
  4410. * @return whether or not one observer registered with the given mask is handeled
  4411. **/
  4412. hasSpecificMask(mask?: number): boolean;
  4413. }
  4414. }
  4415. declare module BABYLON {
  4416. /**
  4417. * Class used to help managing file picking and drag'n'drop
  4418. * File Storage
  4419. */
  4420. export class FilesInputStore {
  4421. /**
  4422. * List of files ready to be loaded
  4423. */
  4424. static FilesToLoad: {
  4425. [key: string]: File;
  4426. };
  4427. }
  4428. }
  4429. declare module BABYLON {
  4430. /** Defines the cross module used constants to avoid circular dependncies */
  4431. export class Constants {
  4432. /** Defines that alpha blending is disabled */
  4433. static readonly ALPHA_DISABLE: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4435. static readonly ALPHA_ADD: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_COMBINE: number;
  4438. /** Defines that alpha blending to DEST - SRC * DEST */
  4439. static readonly ALPHA_SUBTRACT: number;
  4440. /** Defines that alpha blending to SRC * DEST */
  4441. static readonly ALPHA_MULTIPLY: number;
  4442. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4443. static readonly ALPHA_MAXIMIZED: number;
  4444. /** Defines that alpha blending to SRC + DEST */
  4445. static readonly ALPHA_ONEONE: number;
  4446. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4447. static readonly ALPHA_PREMULTIPLIED: number;
  4448. /**
  4449. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4450. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4451. */
  4452. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4453. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4454. static readonly ALPHA_INTERPOLATE: number;
  4455. /**
  4456. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4457. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4458. */
  4459. static readonly ALPHA_SCREENMODE: number;
  4460. /** Defines that the ressource is not delayed*/
  4461. static readonly DELAYLOADSTATE_NONE: number;
  4462. /** Defines that the ressource was successfully delay loaded */
  4463. static readonly DELAYLOADSTATE_LOADED: number;
  4464. /** Defines that the ressource is currently delay loading */
  4465. static readonly DELAYLOADSTATE_LOADING: number;
  4466. /** Defines that the ressource is delayed and has not started loading */
  4467. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4469. static readonly NEVER: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4471. static readonly ALWAYS: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4473. static readonly LESS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4475. static readonly EQUAL: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4477. static readonly LEQUAL: number;
  4478. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4479. static readonly GREATER: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4481. static readonly GEQUAL: number;
  4482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4483. static readonly NOTEQUAL: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be kept */
  4485. static readonly KEEP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4487. static readonly REPLACE: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4489. static readonly INCR: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4491. static readonly DECR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4493. static readonly INVERT: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4495. static readonly INCR_WRAP: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4497. static readonly DECR_WRAP: number;
  4498. /** Texture is not repeating outside of 0..1 UVs */
  4499. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4500. /** Texture is repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4502. /** Texture is repeating and mirrored */
  4503. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4504. /** ALPHA */
  4505. static readonly TEXTUREFORMAT_ALPHA: number;
  4506. /** LUMINANCE */
  4507. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4508. /** LUMINANCE_ALPHA */
  4509. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4510. /** RGB */
  4511. static readonly TEXTUREFORMAT_RGB: number;
  4512. /** RGBA */
  4513. static readonly TEXTUREFORMAT_RGBA: number;
  4514. /** RED */
  4515. static readonly TEXTUREFORMAT_RED: number;
  4516. /** RED (2nd reference) */
  4517. static readonly TEXTUREFORMAT_R: number;
  4518. /** RG */
  4519. static readonly TEXTUREFORMAT_RG: number;
  4520. /** RED_INTEGER */
  4521. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4522. /** RED_INTEGER (2nd reference) */
  4523. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4524. /** RG_INTEGER */
  4525. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4526. /** RGB_INTEGER */
  4527. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4528. /** RGBA_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4530. /** UNSIGNED_BYTE */
  4531. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4532. /** UNSIGNED_BYTE (2nd reference) */
  4533. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4534. /** FLOAT */
  4535. static readonly TEXTURETYPE_FLOAT: number;
  4536. /** HALF_FLOAT */
  4537. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4538. /** BYTE */
  4539. static readonly TEXTURETYPE_BYTE: number;
  4540. /** SHORT */
  4541. static readonly TEXTURETYPE_SHORT: number;
  4542. /** UNSIGNED_SHORT */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4544. /** INT */
  4545. static readonly TEXTURETYPE_INT: number;
  4546. /** UNSIGNED_INT */
  4547. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4548. /** UNSIGNED_SHORT_4_4_4_4 */
  4549. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4550. /** UNSIGNED_SHORT_5_5_5_1 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4552. /** UNSIGNED_SHORT_5_6_5 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4554. /** UNSIGNED_INT_2_10_10_10_REV */
  4555. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4556. /** UNSIGNED_INT_24_8 */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4558. /** UNSIGNED_INT_10F_11F_11F_REV */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4560. /** UNSIGNED_INT_5_9_9_9_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4562. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4563. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4564. /** nearest is mag = nearest and min = nearest and mip = linear */
  4565. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4566. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4567. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4568. /** Trilinear is mag = linear and min = linear and mip = linear */
  4569. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4570. /** nearest is mag = nearest and min = nearest and mip = linear */
  4571. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4572. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4573. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4574. /** Trilinear is mag = linear and min = linear and mip = linear */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4578. /** mag = nearest and min = linear and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = linear */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4582. /** mag = nearest and min = linear and mip = none */
  4583. static readonly TEXTURE_NEAREST_LINEAR: number;
  4584. /** mag = nearest and min = nearest and mip = none */
  4585. static readonly TEXTURE_NEAREST_NEAREST: number;
  4586. /** mag = linear and min = nearest and mip = nearest */
  4587. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4588. /** mag = linear and min = nearest and mip = linear */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4590. /** mag = linear and min = linear and mip = none */
  4591. static readonly TEXTURE_LINEAR_LINEAR: number;
  4592. /** mag = linear and min = nearest and mip = none */
  4593. static readonly TEXTURE_LINEAR_NEAREST: number;
  4594. /** Explicit coordinates mode */
  4595. static readonly TEXTURE_EXPLICIT_MODE: number;
  4596. /** Spherical coordinates mode */
  4597. static readonly TEXTURE_SPHERICAL_MODE: number;
  4598. /** Planar coordinates mode */
  4599. static readonly TEXTURE_PLANAR_MODE: number;
  4600. /** Cubic coordinates mode */
  4601. static readonly TEXTURE_CUBIC_MODE: number;
  4602. /** Projection coordinates mode */
  4603. static readonly TEXTURE_PROJECTION_MODE: number;
  4604. /** Skybox coordinates mode */
  4605. static readonly TEXTURE_SKYBOX_MODE: number;
  4606. /** Inverse Cubic coordinates mode */
  4607. static readonly TEXTURE_INVCUBIC_MODE: number;
  4608. /** Equirectangular coordinates mode */
  4609. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4610. /** Equirectangular Fixed coordinates mode */
  4611. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed Mirrored coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4614. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4615. static readonly SCALEMODE_FLOOR: number;
  4616. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4617. static readonly SCALEMODE_NEAREST: number;
  4618. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4619. static readonly SCALEMODE_CEILING: number;
  4620. /**
  4621. * The dirty texture flag value
  4622. */
  4623. static readonly MATERIAL_TextureDirtyFlag: number;
  4624. /**
  4625. * The dirty light flag value
  4626. */
  4627. static readonly MATERIAL_LightDirtyFlag: number;
  4628. /**
  4629. * The dirty fresnel flag value
  4630. */
  4631. static readonly MATERIAL_FresnelDirtyFlag: number;
  4632. /**
  4633. * The dirty attribute flag value
  4634. */
  4635. static readonly MATERIAL_AttributesDirtyFlag: number;
  4636. /**
  4637. * The dirty misc flag value
  4638. */
  4639. static readonly MATERIAL_MiscDirtyFlag: number;
  4640. /**
  4641. * The all dirty flag value
  4642. */
  4643. static readonly MATERIAL_AllDirtyFlag: number;
  4644. /**
  4645. * Returns the triangle fill mode
  4646. */
  4647. static readonly MATERIAL_TriangleFillMode: number;
  4648. /**
  4649. * Returns the wireframe mode
  4650. */
  4651. static readonly MATERIAL_WireFrameFillMode: number;
  4652. /**
  4653. * Returns the point fill mode
  4654. */
  4655. static readonly MATERIAL_PointFillMode: number;
  4656. /**
  4657. * Returns the point list draw mode
  4658. */
  4659. static readonly MATERIAL_PointListDrawMode: number;
  4660. /**
  4661. * Returns the line list draw mode
  4662. */
  4663. static readonly MATERIAL_LineListDrawMode: number;
  4664. /**
  4665. * Returns the line loop draw mode
  4666. */
  4667. static readonly MATERIAL_LineLoopDrawMode: number;
  4668. /**
  4669. * Returns the line strip draw mode
  4670. */
  4671. static readonly MATERIAL_LineStripDrawMode: number;
  4672. /**
  4673. * Returns the triangle strip draw mode
  4674. */
  4675. static readonly MATERIAL_TriangleStripDrawMode: number;
  4676. /**
  4677. * Returns the triangle fan draw mode
  4678. */
  4679. static readonly MATERIAL_TriangleFanDrawMode: number;
  4680. /**
  4681. * Stores the clock-wise side orientation
  4682. */
  4683. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4684. /**
  4685. * Stores the counter clock-wise side orientation
  4686. */
  4687. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4688. /**
  4689. * Nothing
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_NothingTrigger: number;
  4693. /**
  4694. * On pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnPickTrigger: number;
  4698. /**
  4699. * On left pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnLeftPickTrigger: number;
  4703. /**
  4704. * On right pick
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnRightPickTrigger: number;
  4708. /**
  4709. * On center pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnCenterPickTrigger: number;
  4713. /**
  4714. * On pick down
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickDownTrigger: number;
  4718. /**
  4719. * On double pick
  4720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4721. */
  4722. static readonly ACTION_OnDoublePickTrigger: number;
  4723. /**
  4724. * On pick up
  4725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4726. */
  4727. static readonly ACTION_OnPickUpTrigger: number;
  4728. /**
  4729. * On pick out.
  4730. * This trigger will only be raised if you also declared a OnPickDown
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickOutTrigger: number;
  4734. /**
  4735. * On long press
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLongPressTrigger: number;
  4739. /**
  4740. * On pointer over
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPointerOverTrigger: number;
  4744. /**
  4745. * On pointer out
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnPointerOutTrigger: number;
  4749. /**
  4750. * On every frame
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnEveryFrameTrigger: number;
  4754. /**
  4755. * On intersection enter
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4759. /**
  4760. * On intersection exit
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnIntersectionExitTrigger: number;
  4764. /**
  4765. * On key down
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnKeyDownTrigger: number;
  4769. /**
  4770. * On key up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnKeyUpTrigger: number;
  4774. /**
  4775. * Billboard mode will only apply to Y axis
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4778. /**
  4779. * Billboard mode will apply to all axes
  4780. */
  4781. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4782. /**
  4783. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4784. */
  4785. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4786. /**
  4787. * Gets or sets base Assets URL
  4788. */
  4789. static readonly PARTICLES_BaseAssetsUrl: string;
  4790. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4791. * Test order :
  4792. * Is the bounding sphere outside the frustum ?
  4793. * If not, are the bounding box vertices outside the frustum ?
  4794. * It not, then the cullable object is in the frustum.
  4795. */
  4796. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4797. /** Culling strategy : Bounding Sphere Only.
  4798. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4799. * It's also less accurate than the standard because some not visible objects can still be selected.
  4800. * Test : is the bounding sphere outside the frustum ?
  4801. * If not, then the cullable object is in the frustum.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4804. /** Culling strategy : Optimistic Inclusion.
  4805. * This in an inclusion test first, then the standard exclusion test.
  4806. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4808. * Anyway, it's as accurate as the standard strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the default culling strategy.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4814. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4815. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4816. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4817. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4818. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4819. * Test :
  4820. * Is the cullable object bounding sphere center in the frustum ?
  4821. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4822. */
  4823. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4824. /**
  4825. * No logging while loading
  4826. */
  4827. static readonly SCENELOADER_NO_LOGGING: number;
  4828. /**
  4829. * Minimal logging while loading
  4830. */
  4831. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4832. /**
  4833. * Summary logging while loading
  4834. */
  4835. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4836. /**
  4837. * Detailled logging while loading
  4838. */
  4839. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4840. }
  4841. }
  4842. declare module BABYLON {
  4843. /**
  4844. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4845. * Babylon.js
  4846. */
  4847. export class DomManagement {
  4848. /**
  4849. * Checks if the window object exists
  4850. * @returns true if the window object exists
  4851. */
  4852. static IsWindowObjectExist(): boolean;
  4853. /**
  4854. * Extracts text content from a DOM element hierarchy
  4855. * @param element defines the root element
  4856. * @returns a string
  4857. */
  4858. static GetDOMTextContent(element: HTMLElement): string;
  4859. }
  4860. }
  4861. declare module BABYLON {
  4862. /**
  4863. * Logger used througouht the application to allow configuration of
  4864. * the log level required for the messages.
  4865. */
  4866. export class Logger {
  4867. /**
  4868. * No log
  4869. */
  4870. static readonly NoneLogLevel: number;
  4871. /**
  4872. * Only message logs
  4873. */
  4874. static readonly MessageLogLevel: number;
  4875. /**
  4876. * Only warning logs
  4877. */
  4878. static readonly WarningLogLevel: number;
  4879. /**
  4880. * Only error logs
  4881. */
  4882. static readonly ErrorLogLevel: number;
  4883. /**
  4884. * All logs
  4885. */
  4886. static readonly AllLogLevel: number;
  4887. private static _LogCache;
  4888. /**
  4889. * Gets a value indicating the number of loading errors
  4890. * @ignorenaming
  4891. */
  4892. static errorsCount: number;
  4893. /**
  4894. * Callback called when a new log is added
  4895. */
  4896. static OnNewCacheEntry: (entry: string) => void;
  4897. private static _AddLogEntry;
  4898. private static _FormatMessage;
  4899. private static _LogDisabled;
  4900. private static _LogEnabled;
  4901. private static _WarnDisabled;
  4902. private static _WarnEnabled;
  4903. private static _ErrorDisabled;
  4904. private static _ErrorEnabled;
  4905. /**
  4906. * Log a message to the console
  4907. */
  4908. static Log: (message: string) => void;
  4909. /**
  4910. * Write a warning message to the console
  4911. */
  4912. static Warn: (message: string) => void;
  4913. /**
  4914. * Write an error message to the console
  4915. */
  4916. static Error: (message: string) => void;
  4917. /**
  4918. * Gets current log cache (list of logs)
  4919. */
  4920. static readonly LogCache: string;
  4921. /**
  4922. * Clears the log cache
  4923. */
  4924. static ClearLogCache(): void;
  4925. /**
  4926. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4927. */
  4928. static LogLevels: number;
  4929. }
  4930. }
  4931. declare module BABYLON {
  4932. /** @hidden */
  4933. export class _TypeStore {
  4934. /** @hidden */
  4935. static RegisteredTypes: {
  4936. [key: string]: Object;
  4937. };
  4938. /** @hidden */
  4939. static GetClass(fqdn: string): any;
  4940. }
  4941. }
  4942. declare module BABYLON {
  4943. /**
  4944. * Class containing a set of static utilities functions for deep copy.
  4945. */
  4946. export class DeepCopier {
  4947. /**
  4948. * Tries to copy an object by duplicating every property
  4949. * @param source defines the source object
  4950. * @param destination defines the target object
  4951. * @param doNotCopyList defines a list of properties to avoid
  4952. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4953. */
  4954. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4955. }
  4956. }
  4957. declare module BABYLON {
  4958. /**
  4959. * Class containing a set of static utilities functions for precision date
  4960. */
  4961. export class PrecisionDate {
  4962. /**
  4963. * Gets either window.performance.now() if supported or Date.now() else
  4964. */
  4965. static readonly Now: number;
  4966. }
  4967. }
  4968. declare module BABYLON {
  4969. /** @hidden */
  4970. export class _DevTools {
  4971. static WarnImport(name: string): string;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4977. */
  4978. export class WebRequest {
  4979. private _xhr;
  4980. /**
  4981. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4982. * i.e. when loading files, where the server/service expects an Authorization header
  4983. */
  4984. static CustomRequestHeaders: {
  4985. [key: string]: string;
  4986. };
  4987. /**
  4988. * Add callback functions in this array to update all the requests before they get sent to the network
  4989. */
  4990. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4991. private _injectCustomRequestHeaders;
  4992. /**
  4993. * Gets or sets a function to be called when loading progress changes
  4994. */
  4995. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4996. /**
  4997. * Returns client's state
  4998. */
  4999. readonly readyState: number;
  5000. /**
  5001. * Returns client's status
  5002. */
  5003. readonly status: number;
  5004. /**
  5005. * Returns client's status as a text
  5006. */
  5007. readonly statusText: string;
  5008. /**
  5009. * Returns client's response
  5010. */
  5011. readonly response: any;
  5012. /**
  5013. * Returns client's response url
  5014. */
  5015. readonly responseURL: string;
  5016. /**
  5017. * Returns client's response as text
  5018. */
  5019. readonly responseText: string;
  5020. /**
  5021. * Gets or sets the expected response type
  5022. */
  5023. responseType: XMLHttpRequestResponseType;
  5024. /** @hidden */
  5025. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5026. /** @hidden */
  5027. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5028. /**
  5029. * Cancels any network activity
  5030. */
  5031. abort(): void;
  5032. /**
  5033. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5034. * @param body defines an optional request body
  5035. */
  5036. send(body?: Document | BodyInit | null): void;
  5037. /**
  5038. * Sets the request method, request URL
  5039. * @param method defines the method to use (GET, POST, etc..)
  5040. * @param url defines the url to connect with
  5041. */
  5042. open(method: string, url: string): void;
  5043. }
  5044. }
  5045. declare module BABYLON {
  5046. /**
  5047. * Class used to evalaute queries containing `and` and `or` operators
  5048. */
  5049. export class AndOrNotEvaluator {
  5050. /**
  5051. * Evaluate a query
  5052. * @param query defines the query to evaluate
  5053. * @param evaluateCallback defines the callback used to filter result
  5054. * @returns true if the query matches
  5055. */
  5056. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5057. private static _HandleParenthesisContent;
  5058. private static _SimplifyNegation;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to store custom tags
  5064. */
  5065. export class Tags {
  5066. /**
  5067. * Adds support for tags on the given object
  5068. * @param obj defines the object to use
  5069. */
  5070. static EnableFor(obj: any): void;
  5071. /**
  5072. * Removes tags support
  5073. * @param obj defines the object to use
  5074. */
  5075. static DisableFor(obj: any): void;
  5076. /**
  5077. * Gets a boolean indicating if the given object has tags
  5078. * @param obj defines the object to use
  5079. * @returns a boolean
  5080. */
  5081. static HasTags(obj: any): boolean;
  5082. /**
  5083. * Gets the tags available on a given object
  5084. * @param obj defines the object to use
  5085. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5086. * @returns the tags
  5087. */
  5088. static GetTags(obj: any, asString?: boolean): any;
  5089. /**
  5090. * Adds tags to an object
  5091. * @param obj defines the object to use
  5092. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5093. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5094. */
  5095. static AddTagsTo(obj: any, tagsString: string): void;
  5096. /**
  5097. * @hidden
  5098. */
  5099. static _AddTagTo(obj: any, tag: string): void;
  5100. /**
  5101. * Removes specific tags from a specific object
  5102. * @param obj defines the object to use
  5103. * @param tagsString defines the tags to remove
  5104. */
  5105. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5106. /**
  5107. * @hidden
  5108. */
  5109. static _RemoveTagFrom(obj: any, tag: string): void;
  5110. /**
  5111. * Defines if tags hosted on an object match a given query
  5112. * @param obj defines the object to use
  5113. * @param tagsQuery defines the tag query
  5114. * @returns a boolean
  5115. */
  5116. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5117. }
  5118. }
  5119. declare module BABYLON {
  5120. /**
  5121. * Manages the defines for the Material
  5122. */
  5123. export class MaterialDefines {
  5124. private _keys;
  5125. private _isDirty;
  5126. /** @hidden */
  5127. _renderId: number;
  5128. /** @hidden */
  5129. _areLightsDirty: boolean;
  5130. /** @hidden */
  5131. _areAttributesDirty: boolean;
  5132. /** @hidden */
  5133. _areTexturesDirty: boolean;
  5134. /** @hidden */
  5135. _areFresnelDirty: boolean;
  5136. /** @hidden */
  5137. _areMiscDirty: boolean;
  5138. /** @hidden */
  5139. _areImageProcessingDirty: boolean;
  5140. /** @hidden */
  5141. _normals: boolean;
  5142. /** @hidden */
  5143. _uvs: boolean;
  5144. /** @hidden */
  5145. _needNormals: boolean;
  5146. /** @hidden */
  5147. _needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5217. */
  5218. export class PerformanceMonitor {
  5219. private _enabled;
  5220. private _rollingFrameTime;
  5221. private _lastFrameTimeMs;
  5222. /**
  5223. * constructor
  5224. * @param frameSampleSize The number of samples required to saturate the sliding window
  5225. */
  5226. constructor(frameSampleSize?: number);
  5227. /**
  5228. * Samples current frame
  5229. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5230. */
  5231. sampleFrame(timeMs?: number): void;
  5232. /**
  5233. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5234. */
  5235. readonly averageFrameTime: number;
  5236. /**
  5237. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5238. */
  5239. readonly averageFrameTimeVariance: number;
  5240. /**
  5241. * Returns the frame time of the most recent frame
  5242. */
  5243. readonly instantaneousFrameTime: number;
  5244. /**
  5245. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5246. */
  5247. readonly averageFPS: number;
  5248. /**
  5249. * Returns the average framerate in frames per second using the most recent frame time
  5250. */
  5251. readonly instantaneousFPS: number;
  5252. /**
  5253. * Returns true if enough samples have been taken to completely fill the sliding window
  5254. */
  5255. readonly isSaturated: boolean;
  5256. /**
  5257. * Enables contributions to the sliding window sample set
  5258. */
  5259. enable(): void;
  5260. /**
  5261. * Disables contributions to the sliding window sample set
  5262. * Samples will not be interpolated over the disabled period
  5263. */
  5264. disable(): void;
  5265. /**
  5266. * Returns true if sampling is enabled
  5267. */
  5268. readonly isEnabled: boolean;
  5269. /**
  5270. * Resets performance monitor
  5271. */
  5272. reset(): void;
  5273. }
  5274. /**
  5275. * RollingAverage
  5276. *
  5277. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5278. */
  5279. export class RollingAverage {
  5280. /**
  5281. * Current average
  5282. */
  5283. average: number;
  5284. /**
  5285. * Current variance
  5286. */
  5287. variance: number;
  5288. protected _samples: Array<number>;
  5289. protected _sampleCount: number;
  5290. protected _pos: number;
  5291. protected _m2: number;
  5292. /**
  5293. * constructor
  5294. * @param length The number of samples required to saturate the sliding window
  5295. */
  5296. constructor(length: number);
  5297. /**
  5298. * Adds a sample to the sample set
  5299. * @param v The sample value
  5300. */
  5301. add(v: number): void;
  5302. /**
  5303. * Returns previously added values or null if outside of history or outside the sliding window domain
  5304. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5305. * @return Value previously recorded with add() or null if outside of range
  5306. */
  5307. history(i: number): number;
  5308. /**
  5309. * Returns true if enough samples have been taken to completely fill the sliding window
  5310. * @return true if sample-set saturated
  5311. */
  5312. isSaturated(): boolean;
  5313. /**
  5314. * Resets the rolling average (equivalent to 0 samples taken so far)
  5315. */
  5316. reset(): void;
  5317. /**
  5318. * Wraps a value around the sample range boundaries
  5319. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5320. * @return Wrapped position in sample range
  5321. */
  5322. protected _wrapPosition(i: number): number;
  5323. }
  5324. }
  5325. declare module BABYLON {
  5326. /**
  5327. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5328. * The underlying implementation relies on an associative array to ensure the best performances.
  5329. * The value can be anything including 'null' but except 'undefined'
  5330. */
  5331. export class StringDictionary<T> {
  5332. /**
  5333. * This will clear this dictionary and copy the content from the 'source' one.
  5334. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5335. * @param source the dictionary to take the content from and copy to this dictionary
  5336. */
  5337. copyFrom(source: StringDictionary<T>): void;
  5338. /**
  5339. * Get a value based from its key
  5340. * @param key the given key to get the matching value from
  5341. * @return the value if found, otherwise undefined is returned
  5342. */
  5343. get(key: string): T | undefined;
  5344. /**
  5345. * Get a value from its key or add it if it doesn't exist.
  5346. * This method will ensure you that a given key/data will be present in the dictionary.
  5347. * @param key the given key to get the matching value from
  5348. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5349. * The factory will only be invoked if there's no data for the given key.
  5350. * @return the value corresponding to the key.
  5351. */
  5352. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5353. /**
  5354. * Get a value from its key if present in the dictionary otherwise add it
  5355. * @param key the key to get the value from
  5356. * @param val if there's no such key/value pair in the dictionary add it with this value
  5357. * @return the value corresponding to the key
  5358. */
  5359. getOrAdd(key: string, val: T): T;
  5360. /**
  5361. * Check if there's a given key in the dictionary
  5362. * @param key the key to check for
  5363. * @return true if the key is present, false otherwise
  5364. */
  5365. contains(key: string): boolean;
  5366. /**
  5367. * Add a new key and its corresponding value
  5368. * @param key the key to add
  5369. * @param value the value corresponding to the key
  5370. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5371. */
  5372. add(key: string, value: T): boolean;
  5373. /**
  5374. * Update a specific value associated to a key
  5375. * @param key defines the key to use
  5376. * @param value defines the value to store
  5377. * @returns true if the value was updated (or false if the key was not found)
  5378. */
  5379. set(key: string, value: T): boolean;
  5380. /**
  5381. * Get the element of the given key and remove it from the dictionary
  5382. * @param key defines the key to search
  5383. * @returns the value associated with the key or null if not found
  5384. */
  5385. getAndRemove(key: string): Nullable<T>;
  5386. /**
  5387. * Remove a key/value from the dictionary.
  5388. * @param key the key to remove
  5389. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5390. */
  5391. remove(key: string): boolean;
  5392. /**
  5393. * Clear the whole content of the dictionary
  5394. */
  5395. clear(): void;
  5396. /**
  5397. * Gets the current count
  5398. */
  5399. readonly count: number;
  5400. /**
  5401. * Execute a callback on each key/val of the dictionary.
  5402. * Note that you can remove any element in this dictionary in the callback implementation
  5403. * @param callback the callback to execute on a given key/value pair
  5404. */
  5405. forEach(callback: (key: string, val: T) => void): void;
  5406. /**
  5407. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5408. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5409. * Note that you can remove any element in this dictionary in the callback implementation
  5410. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5411. * @returns the first item
  5412. */
  5413. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5414. private _count;
  5415. private _data;
  5416. }
  5417. }
  5418. declare module BABYLON {
  5419. /**
  5420. * Helper class that provides a small promise polyfill
  5421. */
  5422. export class PromisePolyfill {
  5423. /**
  5424. * Static function used to check if the polyfill is required
  5425. * If this is the case then the function will inject the polyfill to window.Promise
  5426. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5427. */
  5428. static Apply(force?: boolean): void;
  5429. }
  5430. }
  5431. declare module BABYLON {
  5432. /**
  5433. * Class used to store data that will be store in GPU memory
  5434. */
  5435. export class Buffer {
  5436. private _engine;
  5437. private _buffer;
  5438. /** @hidden */
  5439. _data: Nullable<DataArray>;
  5440. private _updatable;
  5441. private _instanced;
  5442. /**
  5443. * Gets the byte stride.
  5444. */
  5445. readonly byteStride: number;
  5446. /**
  5447. * Constructor
  5448. * @param engine the engine
  5449. * @param data the data to use for this buffer
  5450. * @param updatable whether the data is updatable
  5451. * @param stride the stride (optional)
  5452. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5453. * @param instanced whether the buffer is instanced (optional)
  5454. * @param useBytes set to true if the stride in in bytes (optional)
  5455. */
  5456. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5457. /**
  5458. * Create a new VertexBuffer based on the current buffer
  5459. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5460. * @param offset defines offset in the buffer (0 by default)
  5461. * @param size defines the size in floats of attributes (position is 3 for instance)
  5462. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5463. * @param instanced defines if the vertex buffer contains indexed data
  5464. * @param useBytes defines if the offset and stride are in bytes
  5465. * @returns the new vertex buffer
  5466. */
  5467. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5468. /**
  5469. * Gets a boolean indicating if the Buffer is updatable?
  5470. * @returns true if the buffer is updatable
  5471. */
  5472. isUpdatable(): boolean;
  5473. /**
  5474. * Gets current buffer's data
  5475. * @returns a DataArray or null
  5476. */
  5477. getData(): Nullable<DataArray>;
  5478. /**
  5479. * Gets underlying native buffer
  5480. * @returns underlying native buffer
  5481. */
  5482. getBuffer(): Nullable<WebGLBuffer>;
  5483. /**
  5484. * Gets the stride in float32 units (i.e. byte stride / 4).
  5485. * May not be an integer if the byte stride is not divisible by 4.
  5486. * DEPRECATED. Use byteStride instead.
  5487. * @returns the stride in float32 units
  5488. */
  5489. getStrideSize(): number;
  5490. /**
  5491. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5492. * @param data defines the data to store
  5493. */
  5494. create(data?: Nullable<DataArray>): void;
  5495. /** @hidden */
  5496. _rebuild(): void;
  5497. /**
  5498. * Update current buffer data
  5499. * @param data defines the data to store
  5500. */
  5501. update(data: DataArray): void;
  5502. /**
  5503. * Updates the data directly.
  5504. * @param data the new data
  5505. * @param offset the new offset
  5506. * @param vertexCount the vertex count (optional)
  5507. * @param useBytes set to true if the offset is in bytes
  5508. */
  5509. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5510. /**
  5511. * Release all resources
  5512. */
  5513. dispose(): void;
  5514. }
  5515. /**
  5516. * Specialized buffer used to store vertex data
  5517. */
  5518. export class VertexBuffer {
  5519. /** @hidden */
  5520. _buffer: Buffer;
  5521. private _kind;
  5522. private _size;
  5523. private _ownsBuffer;
  5524. private _instanced;
  5525. private _instanceDivisor;
  5526. /**
  5527. * The byte type.
  5528. */
  5529. static readonly BYTE: number;
  5530. /**
  5531. * The unsigned byte type.
  5532. */
  5533. static readonly UNSIGNED_BYTE: number;
  5534. /**
  5535. * The short type.
  5536. */
  5537. static readonly SHORT: number;
  5538. /**
  5539. * The unsigned short type.
  5540. */
  5541. static readonly UNSIGNED_SHORT: number;
  5542. /**
  5543. * The integer type.
  5544. */
  5545. static readonly INT: number;
  5546. /**
  5547. * The unsigned integer type.
  5548. */
  5549. static readonly UNSIGNED_INT: number;
  5550. /**
  5551. * The float type.
  5552. */
  5553. static readonly FLOAT: number;
  5554. /**
  5555. * Gets or sets the instance divisor when in instanced mode
  5556. */
  5557. instanceDivisor: number;
  5558. /**
  5559. * Gets the byte stride.
  5560. */
  5561. readonly byteStride: number;
  5562. /**
  5563. * Gets the byte offset.
  5564. */
  5565. readonly byteOffset: number;
  5566. /**
  5567. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5568. */
  5569. readonly normalized: boolean;
  5570. /**
  5571. * Gets the data type of each component in the array.
  5572. */
  5573. readonly type: number;
  5574. /**
  5575. * Constructor
  5576. * @param engine the engine
  5577. * @param data the data to use for this vertex buffer
  5578. * @param kind the vertex buffer kind
  5579. * @param updatable whether the data is updatable
  5580. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5581. * @param stride the stride (optional)
  5582. * @param instanced whether the buffer is instanced (optional)
  5583. * @param offset the offset of the data (optional)
  5584. * @param size the number of components (optional)
  5585. * @param type the type of the component (optional)
  5586. * @param normalized whether the data contains normalized data (optional)
  5587. * @param useBytes set to true if stride and offset are in bytes (optional)
  5588. */
  5589. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5590. /** @hidden */
  5591. _rebuild(): void;
  5592. /**
  5593. * Returns the kind of the VertexBuffer (string)
  5594. * @returns a string
  5595. */
  5596. getKind(): string;
  5597. /**
  5598. * Gets a boolean indicating if the VertexBuffer is updatable?
  5599. * @returns true if the buffer is updatable
  5600. */
  5601. isUpdatable(): boolean;
  5602. /**
  5603. * Gets current buffer's data
  5604. * @returns a DataArray or null
  5605. */
  5606. getData(): Nullable<DataArray>;
  5607. /**
  5608. * Gets underlying native buffer
  5609. * @returns underlying native buffer
  5610. */
  5611. getBuffer(): Nullable<WebGLBuffer>;
  5612. /**
  5613. * Gets the stride in float32 units (i.e. byte stride / 4).
  5614. * May not be an integer if the byte stride is not divisible by 4.
  5615. * DEPRECATED. Use byteStride instead.
  5616. * @returns the stride in float32 units
  5617. */
  5618. getStrideSize(): number;
  5619. /**
  5620. * Returns the offset as a multiple of the type byte length.
  5621. * DEPRECATED. Use byteOffset instead.
  5622. * @returns the offset in bytes
  5623. */
  5624. getOffset(): number;
  5625. /**
  5626. * Returns the number of components per vertex attribute (integer)
  5627. * @returns the size in float
  5628. */
  5629. getSize(): number;
  5630. /**
  5631. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5632. * @returns true if this buffer is instanced
  5633. */
  5634. getIsInstanced(): boolean;
  5635. /**
  5636. * Returns the instancing divisor, zero for non-instanced (integer).
  5637. * @returns a number
  5638. */
  5639. getInstanceDivisor(): number;
  5640. /**
  5641. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5642. * @param data defines the data to store
  5643. */
  5644. create(data?: DataArray): void;
  5645. /**
  5646. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5647. * This function will create a new buffer if the current one is not updatable
  5648. * @param data defines the data to store
  5649. */
  5650. update(data: DataArray): void;
  5651. /**
  5652. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5653. * Returns the directly updated WebGLBuffer.
  5654. * @param data the new data
  5655. * @param offset the new offset
  5656. * @param useBytes set to true if the offset is in bytes
  5657. */
  5658. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5659. /**
  5660. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5661. */
  5662. dispose(): void;
  5663. /**
  5664. * Enumerates each value of this vertex buffer as numbers.
  5665. * @param count the number of values to enumerate
  5666. * @param callback the callback function called for each value
  5667. */
  5668. forEach(count: number, callback: (value: number, index: number) => void): void;
  5669. /**
  5670. * Positions
  5671. */
  5672. static readonly PositionKind: string;
  5673. /**
  5674. * Normals
  5675. */
  5676. static readonly NormalKind: string;
  5677. /**
  5678. * Tangents
  5679. */
  5680. static readonly TangentKind: string;
  5681. /**
  5682. * Texture coordinates
  5683. */
  5684. static readonly UVKind: string;
  5685. /**
  5686. * Texture coordinates 2
  5687. */
  5688. static readonly UV2Kind: string;
  5689. /**
  5690. * Texture coordinates 3
  5691. */
  5692. static readonly UV3Kind: string;
  5693. /**
  5694. * Texture coordinates 4
  5695. */
  5696. static readonly UV4Kind: string;
  5697. /**
  5698. * Texture coordinates 5
  5699. */
  5700. static readonly UV5Kind: string;
  5701. /**
  5702. * Texture coordinates 6
  5703. */
  5704. static readonly UV6Kind: string;
  5705. /**
  5706. * Colors
  5707. */
  5708. static readonly ColorKind: string;
  5709. /**
  5710. * Matrix indices (for bones)
  5711. */
  5712. static readonly MatricesIndicesKind: string;
  5713. /**
  5714. * Matrix weights (for bones)
  5715. */
  5716. static readonly MatricesWeightsKind: string;
  5717. /**
  5718. * Additional matrix indices (for bones)
  5719. */
  5720. static readonly MatricesIndicesExtraKind: string;
  5721. /**
  5722. * Additional matrix weights (for bones)
  5723. */
  5724. static readonly MatricesWeightsExtraKind: string;
  5725. /**
  5726. * Deduces the stride given a kind.
  5727. * @param kind The kind string to deduce
  5728. * @returns The deduced stride
  5729. */
  5730. static DeduceStride(kind: string): number;
  5731. /**
  5732. * Gets the byte length of the given type.
  5733. * @param type the type
  5734. * @returns the number of bytes
  5735. */
  5736. static GetTypeByteLength(type: number): number;
  5737. /**
  5738. * Enumerates each value of the given parameters as numbers.
  5739. * @param data the data to enumerate
  5740. * @param byteOffset the byte offset of the data
  5741. * @param byteStride the byte stride of the data
  5742. * @param componentCount the number of components per element
  5743. * @param componentType the type of the component
  5744. * @param count the total number of components
  5745. * @param normalized whether the data is normalized
  5746. * @param callback the callback function called for each value
  5747. */
  5748. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5749. private static _GetFloatValue;
  5750. }
  5751. }
  5752. declare module BABYLON {
  5753. /**
  5754. * Class representing spherical polynomial coefficients to the 3rd degree
  5755. */
  5756. export class SphericalPolynomial {
  5757. /**
  5758. * The x coefficients of the spherical polynomial
  5759. */
  5760. x: Vector3;
  5761. /**
  5762. * The y coefficients of the spherical polynomial
  5763. */
  5764. y: Vector3;
  5765. /**
  5766. * The z coefficients of the spherical polynomial
  5767. */
  5768. z: Vector3;
  5769. /**
  5770. * The xx coefficients of the spherical polynomial
  5771. */
  5772. xx: Vector3;
  5773. /**
  5774. * The yy coefficients of the spherical polynomial
  5775. */
  5776. yy: Vector3;
  5777. /**
  5778. * The zz coefficients of the spherical polynomial
  5779. */
  5780. zz: Vector3;
  5781. /**
  5782. * The xy coefficients of the spherical polynomial
  5783. */
  5784. xy: Vector3;
  5785. /**
  5786. * The yz coefficients of the spherical polynomial
  5787. */
  5788. yz: Vector3;
  5789. /**
  5790. * The zx coefficients of the spherical polynomial
  5791. */
  5792. zx: Vector3;
  5793. /**
  5794. * Adds an ambient color to the spherical polynomial
  5795. * @param color the color to add
  5796. */
  5797. addAmbient(color: Color3): void;
  5798. /**
  5799. * Scales the spherical polynomial by the given amount
  5800. * @param scale the amount to scale
  5801. */
  5802. scale(scale: number): void;
  5803. /**
  5804. * Gets the spherical polynomial from harmonics
  5805. * @param harmonics the spherical harmonics
  5806. * @returns the spherical polynomial
  5807. */
  5808. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5809. /**
  5810. * Constructs a spherical polynomial from an array.
  5811. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5812. * @returns the spherical polynomial
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5815. }
  5816. /**
  5817. * Class representing spherical harmonics coefficients to the 3rd degree
  5818. */
  5819. export class SphericalHarmonics {
  5820. /**
  5821. * The l0,0 coefficients of the spherical harmonics
  5822. */
  5823. l00: Vector3;
  5824. /**
  5825. * The l1,-1 coefficients of the spherical harmonics
  5826. */
  5827. l1_1: Vector3;
  5828. /**
  5829. * The l1,0 coefficients of the spherical harmonics
  5830. */
  5831. l10: Vector3;
  5832. /**
  5833. * The l1,1 coefficients of the spherical harmonics
  5834. */
  5835. l11: Vector3;
  5836. /**
  5837. * The l2,-2 coefficients of the spherical harmonics
  5838. */
  5839. l2_2: Vector3;
  5840. /**
  5841. * The l2,-1 coefficients of the spherical harmonics
  5842. */
  5843. l2_1: Vector3;
  5844. /**
  5845. * The l2,0 coefficients of the spherical harmonics
  5846. */
  5847. l20: Vector3;
  5848. /**
  5849. * The l2,1 coefficients of the spherical harmonics
  5850. */
  5851. l21: Vector3;
  5852. /**
  5853. * The l2,2 coefficients of the spherical harmonics
  5854. */
  5855. lL22: Vector3;
  5856. /**
  5857. * Adds a light to the spherical harmonics
  5858. * @param direction the direction of the light
  5859. * @param color the color of the light
  5860. * @param deltaSolidAngle the delta solid angle of the light
  5861. */
  5862. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5863. /**
  5864. * Scales the spherical harmonics by the given amount
  5865. * @param scale the amount to scale
  5866. */
  5867. scale(scale: number): void;
  5868. /**
  5869. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5870. *
  5871. * ```
  5872. * E_lm = A_l * L_lm
  5873. * ```
  5874. *
  5875. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5876. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5877. * the scaling factors are given in equation 9.
  5878. */
  5879. convertIncidentRadianceToIrradiance(): void;
  5880. /**
  5881. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5882. *
  5883. * ```
  5884. * L = (1/pi) * E * rho
  5885. * ```
  5886. *
  5887. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5888. */
  5889. convertIrradianceToLambertianRadiance(): void;
  5890. /**
  5891. * Gets the spherical harmonics from polynomial
  5892. * @param polynomial the spherical polynomial
  5893. * @returns the spherical harmonics
  5894. */
  5895. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5896. /**
  5897. * Constructs a spherical harmonics from an array.
  5898. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5899. * @returns the spherical harmonics
  5900. */
  5901. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. /**
  5906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5907. */
  5908. export interface CubeMapInfo {
  5909. /**
  5910. * The pixel array for the front face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. front: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the back face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. back: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The pixel array for the left face.
  5921. * This is stored in format, left to right, up to down format.
  5922. */
  5923. left: Nullable<ArrayBufferView>;
  5924. /**
  5925. * The pixel array for the right face.
  5926. * This is stored in format, left to right, up to down format.
  5927. */
  5928. right: Nullable<ArrayBufferView>;
  5929. /**
  5930. * The pixel array for the up face.
  5931. * This is stored in format, left to right, up to down format.
  5932. */
  5933. up: Nullable<ArrayBufferView>;
  5934. /**
  5935. * The pixel array for the down face.
  5936. * This is stored in format, left to right, up to down format.
  5937. */
  5938. down: Nullable<ArrayBufferView>;
  5939. /**
  5940. * The size of the cubemap stored.
  5941. *
  5942. * Each faces will be size * size pixels.
  5943. */
  5944. size: number;
  5945. /**
  5946. * The format of the texture.
  5947. *
  5948. * RGBA, RGB.
  5949. */
  5950. format: number;
  5951. /**
  5952. * The type of the texture data.
  5953. *
  5954. * UNSIGNED_INT, FLOAT.
  5955. */
  5956. type: number;
  5957. /**
  5958. * Specifies whether the texture is in gamma space.
  5959. */
  5960. gammaSpace: boolean;
  5961. }
  5962. /**
  5963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5964. */
  5965. export class PanoramaToCubeMapTools {
  5966. private static FACE_FRONT;
  5967. private static FACE_BACK;
  5968. private static FACE_RIGHT;
  5969. private static FACE_LEFT;
  5970. private static FACE_DOWN;
  5971. private static FACE_UP;
  5972. /**
  5973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5974. *
  5975. * @param float32Array The source data.
  5976. * @param inputWidth The width of the input panorama.
  5977. * @param inputHeight The height of the input panorama.
  5978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5979. * @return The cubemap data
  5980. */
  5981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5982. private static CreateCubemapTexture;
  5983. private static CalcProjectionSpherical;
  5984. }
  5985. }
  5986. declare module BABYLON {
  5987. /**
  5988. * Helper class dealing with the extraction of spherical polynomial dataArray
  5989. * from a cube map.
  5990. */
  5991. export class CubeMapToSphericalPolynomialTools {
  5992. private static FileFaces;
  5993. /**
  5994. * Converts a texture to the according Spherical Polynomial data.
  5995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5996. *
  5997. * @param texture The texture to extract the information from.
  5998. * @return The Spherical Polynomial data.
  5999. */
  6000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6001. /**
  6002. * Converts a cubemap to the according Spherical Polynomial data.
  6003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6004. *
  6005. * @param cubeInfo The Cube map to extract the information from.
  6006. * @return The Spherical Polynomial data.
  6007. */
  6008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6009. }
  6010. }
  6011. declare module BABYLON {
  6012. /**
  6013. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6014. * during the life time of the application.
  6015. */
  6016. export class EngineStore {
  6017. /** Gets the list of created engines */
  6018. static Instances: Engine[];
  6019. /**
  6020. * Gets the latest created engine
  6021. */
  6022. static readonly LastCreatedEngine: Nullable<Engine>;
  6023. /**
  6024. * Gets the latest created scene
  6025. */
  6026. static readonly LastCreatedScene: Nullable<Scene>;
  6027. }
  6028. }
  6029. declare module BABYLON {
  6030. /**
  6031. * Define options used to create a render target texture
  6032. */
  6033. export class RenderTargetCreationOptions {
  6034. /**
  6035. * Specifies is mipmaps must be generated
  6036. */
  6037. generateMipMaps?: boolean;
  6038. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6039. generateDepthBuffer?: boolean;
  6040. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6041. generateStencilBuffer?: boolean;
  6042. /** Defines texture type (int by default) */
  6043. type?: number;
  6044. /** Defines sampling mode (trilinear by default) */
  6045. samplingMode?: number;
  6046. /** Defines format (RGBA by default) */
  6047. format?: number;
  6048. }
  6049. }
  6050. declare module BABYLON {
  6051. /**
  6052. * @hidden
  6053. **/
  6054. export class _AlphaState {
  6055. private _isAlphaBlendDirty;
  6056. private _isBlendFunctionParametersDirty;
  6057. private _isBlendEquationParametersDirty;
  6058. private _isBlendConstantsDirty;
  6059. private _alphaBlend;
  6060. private _blendFunctionParameters;
  6061. private _blendEquationParameters;
  6062. private _blendConstants;
  6063. /**
  6064. * Initializes the state.
  6065. */
  6066. constructor();
  6067. readonly isDirty: boolean;
  6068. alphaBlend: boolean;
  6069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6072. reset(): void;
  6073. apply(gl: WebGLRenderingContext): void;
  6074. }
  6075. }
  6076. declare module BABYLON {
  6077. /**
  6078. * @hidden
  6079. **/
  6080. export class _DepthCullingState {
  6081. private _isDepthTestDirty;
  6082. private _isDepthMaskDirty;
  6083. private _isDepthFuncDirty;
  6084. private _isCullFaceDirty;
  6085. private _isCullDirty;
  6086. private _isZOffsetDirty;
  6087. private _isFrontFaceDirty;
  6088. private _depthTest;
  6089. private _depthMask;
  6090. private _depthFunc;
  6091. private _cull;
  6092. private _cullFace;
  6093. private _zOffset;
  6094. private _frontFace;
  6095. /**
  6096. * Initializes the state.
  6097. */
  6098. constructor();
  6099. readonly isDirty: boolean;
  6100. zOffset: number;
  6101. cullFace: Nullable<number>;
  6102. cull: Nullable<boolean>;
  6103. depthFunc: Nullable<number>;
  6104. depthMask: boolean;
  6105. depthTest: boolean;
  6106. frontFace: Nullable<number>;
  6107. reset(): void;
  6108. apply(gl: WebGLRenderingContext): void;
  6109. }
  6110. }
  6111. declare module BABYLON {
  6112. /**
  6113. * @hidden
  6114. **/
  6115. export class _StencilState {
  6116. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6117. static readonly ALWAYS: number;
  6118. /** Passed to stencilOperation to specify that stencil value must be kept */
  6119. static readonly KEEP: number;
  6120. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6121. static readonly REPLACE: number;
  6122. private _isStencilTestDirty;
  6123. private _isStencilMaskDirty;
  6124. private _isStencilFuncDirty;
  6125. private _isStencilOpDirty;
  6126. private _stencilTest;
  6127. private _stencilMask;
  6128. private _stencilFunc;
  6129. private _stencilFuncRef;
  6130. private _stencilFuncMask;
  6131. private _stencilOpStencilFail;
  6132. private _stencilOpDepthFail;
  6133. private _stencilOpStencilDepthPass;
  6134. readonly isDirty: boolean;
  6135. stencilFunc: number;
  6136. stencilFuncRef: number;
  6137. stencilFuncMask: number;
  6138. stencilOpStencilFail: number;
  6139. stencilOpDepthFail: number;
  6140. stencilOpStencilDepthPass: number;
  6141. stencilMask: number;
  6142. stencilTest: boolean;
  6143. constructor();
  6144. reset(): void;
  6145. apply(gl: WebGLRenderingContext): void;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _TimeToken {
  6153. _startTimeQuery: Nullable<WebGLQuery>;
  6154. _endTimeQuery: Nullable<WebGLQuery>;
  6155. _timeElapsedQuery: Nullable<WebGLQuery>;
  6156. _timeElapsedQueryEnded: boolean;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Internal interface used to track InternalTexture already bound to the GL context
  6162. */
  6163. export interface IInternalTextureTracker {
  6164. /**
  6165. * Gets or set the previous tracker in the list
  6166. */
  6167. previous: Nullable<IInternalTextureTracker>;
  6168. /**
  6169. * Gets or set the next tracker in the list
  6170. */
  6171. next: Nullable<IInternalTextureTracker>;
  6172. }
  6173. /**
  6174. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6175. */
  6176. export class DummyInternalTextureTracker {
  6177. /**
  6178. * Gets or set the previous tracker in the list
  6179. */
  6180. previous: Nullable<IInternalTextureTracker>;
  6181. /**
  6182. * Gets or set the next tracker in the list
  6183. */
  6184. next: Nullable<IInternalTextureTracker>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Class used to store data associated with WebGL texture data for the engine
  6190. * This class should not be used directly
  6191. */
  6192. export class InternalTexture implements IInternalTextureTracker {
  6193. /** hidden */
  6194. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6195. /**
  6196. * The source of the texture data is unknown
  6197. */
  6198. static DATASOURCE_UNKNOWN: number;
  6199. /**
  6200. * Texture data comes from an URL
  6201. */
  6202. static DATASOURCE_URL: number;
  6203. /**
  6204. * Texture data is only used for temporary storage
  6205. */
  6206. static DATASOURCE_TEMP: number;
  6207. /**
  6208. * Texture data comes from raw data (ArrayBuffer)
  6209. */
  6210. static DATASOURCE_RAW: number;
  6211. /**
  6212. * Texture content is dynamic (video or dynamic texture)
  6213. */
  6214. static DATASOURCE_DYNAMIC: number;
  6215. /**
  6216. * Texture content is generated by rendering to it
  6217. */
  6218. static DATASOURCE_RENDERTARGET: number;
  6219. /**
  6220. * Texture content is part of a multi render target process
  6221. */
  6222. static DATASOURCE_MULTIRENDERTARGET: number;
  6223. /**
  6224. * Texture data comes from a cube data file
  6225. */
  6226. static DATASOURCE_CUBE: number;
  6227. /**
  6228. * Texture data comes from a raw cube data
  6229. */
  6230. static DATASOURCE_CUBERAW: number;
  6231. /**
  6232. * Texture data come from a prefiltered cube data file
  6233. */
  6234. static DATASOURCE_CUBEPREFILTERED: number;
  6235. /**
  6236. * Texture content is raw 3D data
  6237. */
  6238. static DATASOURCE_RAW3D: number;
  6239. /**
  6240. * Texture content is a depth texture
  6241. */
  6242. static DATASOURCE_DEPTHTEXTURE: number;
  6243. /**
  6244. * Texture data comes from a raw cube data encoded with RGBD
  6245. */
  6246. static DATASOURCE_CUBERAW_RGBD: number;
  6247. /**
  6248. * Defines if the texture is ready
  6249. */
  6250. isReady: boolean;
  6251. /**
  6252. * Defines if the texture is a cube texture
  6253. */
  6254. isCube: boolean;
  6255. /**
  6256. * Defines if the texture contains 3D data
  6257. */
  6258. is3D: boolean;
  6259. /**
  6260. * Defines if the texture contains multiview data
  6261. */
  6262. isMultiview: boolean;
  6263. /**
  6264. * Gets the URL used to load this texture
  6265. */
  6266. url: string;
  6267. /**
  6268. * Gets the sampling mode of the texture
  6269. */
  6270. samplingMode: number;
  6271. /**
  6272. * Gets a boolean indicating if the texture needs mipmaps generation
  6273. */
  6274. generateMipMaps: boolean;
  6275. /**
  6276. * Gets the number of samples used by the texture (WebGL2+ only)
  6277. */
  6278. samples: number;
  6279. /**
  6280. * Gets the type of the texture (int, float...)
  6281. */
  6282. type: number;
  6283. /**
  6284. * Gets the format of the texture (RGB, RGBA...)
  6285. */
  6286. format: number;
  6287. /**
  6288. * Observable called when the texture is loaded
  6289. */
  6290. onLoadedObservable: Observable<InternalTexture>;
  6291. /**
  6292. * Gets the width of the texture
  6293. */
  6294. width: number;
  6295. /**
  6296. * Gets the height of the texture
  6297. */
  6298. height: number;
  6299. /**
  6300. * Gets the depth of the texture
  6301. */
  6302. depth: number;
  6303. /**
  6304. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6305. */
  6306. baseWidth: number;
  6307. /**
  6308. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6309. */
  6310. baseHeight: number;
  6311. /**
  6312. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6313. */
  6314. baseDepth: number;
  6315. /**
  6316. * Gets a boolean indicating if the texture is inverted on Y axis
  6317. */
  6318. invertY: boolean;
  6319. /**
  6320. * Gets or set the previous tracker in the list
  6321. */
  6322. previous: Nullable<IInternalTextureTracker>;
  6323. /**
  6324. * Gets or set the next tracker in the list
  6325. */
  6326. next: Nullable<IInternalTextureTracker>;
  6327. /** @hidden */
  6328. _invertVScale: boolean;
  6329. /** @hidden */
  6330. _initialSlot: number;
  6331. /** @hidden */
  6332. _designatedSlot: number;
  6333. /** @hidden */
  6334. _dataSource: number;
  6335. /** @hidden */
  6336. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6337. /** @hidden */
  6338. _bufferView: Nullable<ArrayBufferView>;
  6339. /** @hidden */
  6340. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6341. /** @hidden */
  6342. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */
  6344. _size: number;
  6345. /** @hidden */
  6346. _extension: string;
  6347. /** @hidden */
  6348. _files: Nullable<string[]>;
  6349. /** @hidden */
  6350. _workingCanvas: HTMLCanvasElement;
  6351. /** @hidden */
  6352. _workingContext: CanvasRenderingContext2D;
  6353. /** @hidden */
  6354. _framebuffer: Nullable<WebGLFramebuffer>;
  6355. /** @hidden */
  6356. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6357. /** @hidden */
  6358. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6359. /** @hidden */
  6360. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6361. /** @hidden */
  6362. _attachments: Nullable<number[]>;
  6363. /** @hidden */
  6364. _cachedCoordinatesMode: Nullable<number>;
  6365. /** @hidden */
  6366. _cachedWrapU: Nullable<number>;
  6367. /** @hidden */
  6368. _cachedWrapV: Nullable<number>;
  6369. /** @hidden */
  6370. _cachedWrapR: Nullable<number>;
  6371. /** @hidden */
  6372. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6373. /** @hidden */
  6374. _isDisabled: boolean;
  6375. /** @hidden */
  6376. _compression: Nullable<string>;
  6377. /** @hidden */
  6378. _generateStencilBuffer: boolean;
  6379. /** @hidden */
  6380. _generateDepthBuffer: boolean;
  6381. /** @hidden */
  6382. _comparisonFunction: number;
  6383. /** @hidden */
  6384. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6385. /** @hidden */
  6386. _lodGenerationScale: number;
  6387. /** @hidden */
  6388. _lodGenerationOffset: number;
  6389. /** @hidden */
  6390. _colorTextureArray: Nullable<WebGLTexture>;
  6391. /** @hidden */
  6392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */
  6394. _lodTextureHigh: BaseTexture;
  6395. /** @hidden */
  6396. _lodTextureMid: BaseTexture;
  6397. /** @hidden */
  6398. _lodTextureLow: BaseTexture;
  6399. /** @hidden */
  6400. _isRGBD: boolean;
  6401. /** @hidden */
  6402. _webGLTexture: Nullable<WebGLTexture>;
  6403. /** @hidden */
  6404. _references: number;
  6405. private _engine;
  6406. /**
  6407. * Gets the Engine the texture belongs to.
  6408. * @returns The babylon engine
  6409. */
  6410. getEngine(): Engine;
  6411. /**
  6412. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6413. */
  6414. readonly dataSource: number;
  6415. /**
  6416. * Creates a new InternalTexture
  6417. * @param engine defines the engine to use
  6418. * @param dataSource defines the type of data that will be used
  6419. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6420. */
  6421. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6422. /**
  6423. * Increments the number of references (ie. the number of Texture that point to it)
  6424. */
  6425. incrementReferences(): void;
  6426. /**
  6427. * Change the size of the texture (not the size of the content)
  6428. * @param width defines the new width
  6429. * @param height defines the new height
  6430. * @param depth defines the new depth (1 by default)
  6431. */
  6432. updateSize(width: int, height: int, depth?: int): void;
  6433. /** @hidden */
  6434. _rebuild(): void;
  6435. /** @hidden */
  6436. _swapAndDie(target: InternalTexture): void;
  6437. /**
  6438. * Dispose the current allocated resources
  6439. */
  6440. dispose(): void;
  6441. }
  6442. }
  6443. declare module BABYLON {
  6444. /**
  6445. * This represents the main contract an easing function should follow.
  6446. * Easing functions are used throughout the animation system.
  6447. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6448. */
  6449. export interface IEasingFunction {
  6450. /**
  6451. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6452. * of the easing function.
  6453. * The link below provides some of the most common examples of easing functions.
  6454. * @see https://easings.net/
  6455. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6456. * @returns the corresponding value on the curve defined by the easing function
  6457. */
  6458. ease(gradient: number): number;
  6459. }
  6460. /**
  6461. * Base class used for every default easing function.
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class EasingFunction implements IEasingFunction {
  6465. /**
  6466. * Interpolation follows the mathematical formula associated with the easing function.
  6467. */
  6468. static readonly EASINGMODE_EASEIN: number;
  6469. /**
  6470. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6471. */
  6472. static readonly EASINGMODE_EASEOUT: number;
  6473. /**
  6474. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6475. */
  6476. static readonly EASINGMODE_EASEINOUT: number;
  6477. private _easingMode;
  6478. /**
  6479. * Sets the easing mode of the current function.
  6480. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6481. */
  6482. setEasingMode(easingMode: number): void;
  6483. /**
  6484. * Gets the current easing mode.
  6485. * @returns the easing mode
  6486. */
  6487. getEasingMode(): number;
  6488. /**
  6489. * @hidden
  6490. */
  6491. easeInCore(gradient: number): number;
  6492. /**
  6493. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6494. * of the easing function.
  6495. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6496. * @returns the corresponding value on the curve defined by the easing function
  6497. */
  6498. ease(gradient: number): number;
  6499. }
  6500. /**
  6501. * Easing function with a circle shape (see link below).
  6502. * @see https://easings.net/#easeInCirc
  6503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6504. */
  6505. export class CircleEase extends EasingFunction implements IEasingFunction {
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a ease back shape (see link below).
  6511. * @see https://easings.net/#easeInBack
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class BackEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the amplitude of the function */
  6516. amplitude: number;
  6517. /**
  6518. * Instantiates a back ease easing
  6519. * @see https://easings.net/#easeInBack
  6520. * @param amplitude Defines the amplitude of the function
  6521. */
  6522. constructor(
  6523. /** Defines the amplitude of the function */
  6524. amplitude?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a bouncing shape (see link below).
  6530. * @see https://easings.net/#easeInBounce
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class BounceEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of bounces */
  6535. bounces: number;
  6536. /** Defines the amplitude of the bounce */
  6537. bounciness: number;
  6538. /**
  6539. * Instantiates a bounce easing
  6540. * @see https://easings.net/#easeInBounce
  6541. * @param bounces Defines the number of bounces
  6542. * @param bounciness Defines the amplitude of the bounce
  6543. */
  6544. constructor(
  6545. /** Defines the number of bounces */
  6546. bounces?: number,
  6547. /** Defines the amplitude of the bounce */
  6548. bounciness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 3 shape (see link below).
  6554. * @see https://easings.net/#easeInCubic
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class CubicEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with an elastic shape (see link below).
  6563. * @see https://easings.net/#easeInElastic
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6567. /** Defines the number of oscillations*/
  6568. oscillations: number;
  6569. /** Defines the amplitude of the oscillations*/
  6570. springiness: number;
  6571. /**
  6572. * Instantiates an elastic easing function
  6573. * @see https://easings.net/#easeInElastic
  6574. * @param oscillations Defines the number of oscillations
  6575. * @param springiness Defines the amplitude of the oscillations
  6576. */
  6577. constructor(
  6578. /** Defines the number of oscillations*/
  6579. oscillations?: number,
  6580. /** Defines the amplitude of the oscillations*/
  6581. springiness?: number);
  6582. /** @hidden */
  6583. easeInCore(gradient: number): number;
  6584. }
  6585. /**
  6586. * Easing function with an exponential shape (see link below).
  6587. * @see https://easings.net/#easeInExpo
  6588. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6589. */
  6590. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6591. /** Defines the exponent of the function */
  6592. exponent: number;
  6593. /**
  6594. * Instantiates an exponential easing function
  6595. * @see https://easings.net/#easeInExpo
  6596. * @param exponent Defines the exponent of the function
  6597. */
  6598. constructor(
  6599. /** Defines the exponent of the function */
  6600. exponent?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. /**
  6605. * Easing function with a power shape (see link below).
  6606. * @see https://easings.net/#easeInQuad
  6607. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6608. */
  6609. export class PowerEase extends EasingFunction implements IEasingFunction {
  6610. /** Defines the power of the function */
  6611. power: number;
  6612. /**
  6613. * Instantiates an power base easing function
  6614. * @see https://easings.net/#easeInQuad
  6615. * @param power Defines the power of the function
  6616. */
  6617. constructor(
  6618. /** Defines the power of the function */
  6619. power?: number);
  6620. /** @hidden */
  6621. easeInCore(gradient: number): number;
  6622. }
  6623. /**
  6624. * Easing function with a power of 2 shape (see link below).
  6625. * @see https://easings.net/#easeInQuad
  6626. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6627. */
  6628. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6629. /** @hidden */
  6630. easeInCore(gradient: number): number;
  6631. }
  6632. /**
  6633. * Easing function with a power of 4 shape (see link below).
  6634. * @see https://easings.net/#easeInQuart
  6635. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6636. */
  6637. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 5 shape (see link below).
  6643. * @see https://easings.net/#easeInQuint
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a sin shape (see link below).
  6652. * @see https://easings.net/#easeInSine
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class SineEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a bezier shape (see link below).
  6661. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6665. /** Defines the x component of the start tangent in the bezier curve */
  6666. x1: number;
  6667. /** Defines the y component of the start tangent in the bezier curve */
  6668. y1: number;
  6669. /** Defines the x component of the end tangent in the bezier curve */
  6670. x2: number;
  6671. /** Defines the y component of the end tangent in the bezier curve */
  6672. y2: number;
  6673. /**
  6674. * Instantiates a bezier function
  6675. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6676. * @param x1 Defines the x component of the start tangent in the bezier curve
  6677. * @param y1 Defines the y component of the start tangent in the bezier curve
  6678. * @param x2 Defines the x component of the end tangent in the bezier curve
  6679. * @param y2 Defines the y component of the end tangent in the bezier curve
  6680. */
  6681. constructor(
  6682. /** Defines the x component of the start tangent in the bezier curve */
  6683. x1?: number,
  6684. /** Defines the y component of the start tangent in the bezier curve */
  6685. y1?: number,
  6686. /** Defines the x component of the end tangent in the bezier curve */
  6687. x2?: number,
  6688. /** Defines the y component of the end tangent in the bezier curve */
  6689. y2?: number);
  6690. /** @hidden */
  6691. easeInCore(gradient: number): number;
  6692. }
  6693. }
  6694. declare module BABYLON {
  6695. /**
  6696. * Defines an interface which represents an animation key frame
  6697. */
  6698. export interface IAnimationKey {
  6699. /**
  6700. * Frame of the key frame
  6701. */
  6702. frame: number;
  6703. /**
  6704. * Value at the specifies key frame
  6705. */
  6706. value: any;
  6707. /**
  6708. * The input tangent for the cubic hermite spline
  6709. */
  6710. inTangent?: any;
  6711. /**
  6712. * The output tangent for the cubic hermite spline
  6713. */
  6714. outTangent?: any;
  6715. /**
  6716. * The animation interpolation type
  6717. */
  6718. interpolation?: AnimationKeyInterpolation;
  6719. }
  6720. /**
  6721. * Enum for the animation key frame interpolation type
  6722. */
  6723. export enum AnimationKeyInterpolation {
  6724. /**
  6725. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6726. */
  6727. STEP = 1
  6728. }
  6729. }
  6730. declare module BABYLON {
  6731. /**
  6732. * Represents the range of an animation
  6733. */
  6734. export class AnimationRange {
  6735. /**The name of the animation range**/
  6736. name: string;
  6737. /**The starting frame of the animation */
  6738. from: number;
  6739. /**The ending frame of the animation*/
  6740. to: number;
  6741. /**
  6742. * Initializes the range of an animation
  6743. * @param name The name of the animation range
  6744. * @param from The starting frame of the animation
  6745. * @param to The ending frame of the animation
  6746. */
  6747. constructor(
  6748. /**The name of the animation range**/
  6749. name: string,
  6750. /**The starting frame of the animation */
  6751. from: number,
  6752. /**The ending frame of the animation*/
  6753. to: number);
  6754. /**
  6755. * Makes a copy of the animation range
  6756. * @returns A copy of the animation range
  6757. */
  6758. clone(): AnimationRange;
  6759. }
  6760. }
  6761. declare module BABYLON {
  6762. /**
  6763. * Composed of a frame, and an action function
  6764. */
  6765. export class AnimationEvent {
  6766. /** The frame for which the event is triggered **/
  6767. frame: number;
  6768. /** The event to perform when triggered **/
  6769. action: (currentFrame: number) => void;
  6770. /** Specifies if the event should be triggered only once**/
  6771. onlyOnce?: boolean | undefined;
  6772. /**
  6773. * Specifies if the animation event is done
  6774. */
  6775. isDone: boolean;
  6776. /**
  6777. * Initializes the animation event
  6778. * @param frame The frame for which the event is triggered
  6779. * @param action The event to perform when triggered
  6780. * @param onlyOnce Specifies if the event should be triggered only once
  6781. */
  6782. constructor(
  6783. /** The frame for which the event is triggered **/
  6784. frame: number,
  6785. /** The event to perform when triggered **/
  6786. action: (currentFrame: number) => void,
  6787. /** Specifies if the event should be triggered only once**/
  6788. onlyOnce?: boolean | undefined);
  6789. /** @hidden */
  6790. _clone(): AnimationEvent;
  6791. }
  6792. }
  6793. declare module BABYLON {
  6794. /**
  6795. * Interface used to define a behavior
  6796. */
  6797. export interface Behavior<T> {
  6798. /** gets or sets behavior's name */
  6799. name: string;
  6800. /**
  6801. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6802. */
  6803. init(): void;
  6804. /**
  6805. * Called when the behavior is attached to a target
  6806. * @param target defines the target where the behavior is attached to
  6807. */
  6808. attach(target: T): void;
  6809. /**
  6810. * Called when the behavior is detached from its target
  6811. */
  6812. detach(): void;
  6813. }
  6814. /**
  6815. * Interface implemented by classes supporting behaviors
  6816. */
  6817. export interface IBehaviorAware<T> {
  6818. /**
  6819. * Attach a behavior
  6820. * @param behavior defines the behavior to attach
  6821. * @returns the current host
  6822. */
  6823. addBehavior(behavior: Behavior<T>): T;
  6824. /**
  6825. * Remove a behavior from the current object
  6826. * @param behavior defines the behavior to detach
  6827. * @returns the current host
  6828. */
  6829. removeBehavior(behavior: Behavior<T>): T;
  6830. /**
  6831. * Gets a behavior using its name to search
  6832. * @param name defines the name to search
  6833. * @returns the behavior or null if not found
  6834. */
  6835. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6836. }
  6837. }
  6838. declare module BABYLON {
  6839. /**
  6840. * @hidden
  6841. */
  6842. export class IntersectionInfo {
  6843. bu: Nullable<number>;
  6844. bv: Nullable<number>;
  6845. distance: number;
  6846. faceId: number;
  6847. subMeshId: number;
  6848. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6849. }
  6850. }
  6851. declare module BABYLON {
  6852. /**
  6853. * Class used to store bounding sphere information
  6854. */
  6855. export class BoundingSphere {
  6856. /**
  6857. * Gets the center of the bounding sphere in local space
  6858. */
  6859. readonly center: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in local space
  6862. */
  6863. radius: number;
  6864. /**
  6865. * Gets the center of the bounding sphere in world space
  6866. */
  6867. readonly centerWorld: Vector3;
  6868. /**
  6869. * Radius of the bounding sphere in world space
  6870. */
  6871. radiusWorld: number;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Creates a new bounding sphere
  6884. * @param min defines the minimum vector (in local space)
  6885. * @param max defines the maximum vector (in local space)
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * Scale the current bounding sphere by applying a scale factor
  6898. * @param factor defines the scale factor to apply
  6899. * @returns the current bounding box
  6900. */
  6901. scale(factor: number): BoundingSphere;
  6902. /**
  6903. * Gets the world matrix of the bounding box
  6904. * @returns a matrix
  6905. */
  6906. getWorldMatrix(): DeepImmutable<Matrix>;
  6907. /** @hidden */
  6908. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6909. /**
  6910. * Tests if the bounding sphere is intersecting the frustum planes
  6911. * @param frustumPlanes defines the frustum planes to test
  6912. * @returns true if there is an intersection
  6913. */
  6914. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6915. /**
  6916. * Tests if the bounding sphere center is in between the frustum planes.
  6917. * Used for optimistic fast inclusion.
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if the sphere center is in between the frustum planes
  6920. */
  6921. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if a point is inside the bounding sphere
  6924. * @param point defines the point to test
  6925. * @returns true if the point is inside the bounding sphere
  6926. */
  6927. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6928. /**
  6929. * Checks if two sphere intersct
  6930. * @param sphere0 sphere 0
  6931. * @param sphere1 sphere 1
  6932. * @returns true if the speres intersect
  6933. */
  6934. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6935. }
  6936. }
  6937. declare module BABYLON {
  6938. /**
  6939. * Class used to store bounding box information
  6940. */
  6941. export class BoundingBox implements ICullable {
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in local space
  6944. */
  6945. readonly vectors: Vector3[];
  6946. /**
  6947. * Gets the center of the bounding box in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Gets the center of the bounding box in world space
  6952. */
  6953. readonly centerWorld: Vector3;
  6954. /**
  6955. * Gets the extend size in local space
  6956. */
  6957. readonly extendSize: Vector3;
  6958. /**
  6959. * Gets the extend size in world space
  6960. */
  6961. readonly extendSizeWorld: Vector3;
  6962. /**
  6963. * Gets the OBB (object bounding box) directions
  6964. */
  6965. readonly directions: Vector3[];
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in world space
  6968. */
  6969. readonly vectorsWorld: Vector3[];
  6970. /**
  6971. * Gets the minimum vector in world space
  6972. */
  6973. readonly minimumWorld: Vector3;
  6974. /**
  6975. * Gets the maximum vector in world space
  6976. */
  6977. readonly maximumWorld: Vector3;
  6978. /**
  6979. * Gets the minimum vector in local space
  6980. */
  6981. readonly minimum: Vector3;
  6982. /**
  6983. * Gets the maximum vector in local space
  6984. */
  6985. readonly maximum: Vector3;
  6986. private _worldMatrix;
  6987. private static readonly TmpVector3;
  6988. /**
  6989. * @hidden
  6990. */
  6991. _tag: number;
  6992. /**
  6993. * Creates a new bounding box
  6994. * @param min defines the minimum vector (in local space)
  6995. * @param max defines the maximum vector (in local space)
  6996. * @param worldMatrix defines the new world matrix
  6997. */
  6998. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6999. /**
  7000. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7001. * @param min defines the new minimum vector (in local space)
  7002. * @param max defines the new maximum vector (in local space)
  7003. * @param worldMatrix defines the new world matrix
  7004. */
  7005. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7006. /**
  7007. * Scale the current bounding box by applying a scale factor
  7008. * @param factor defines the scale factor to apply
  7009. * @returns the current bounding box
  7010. */
  7011. scale(factor: number): BoundingBox;
  7012. /**
  7013. * Gets the world matrix of the bounding box
  7014. * @returns a matrix
  7015. */
  7016. getWorldMatrix(): DeepImmutable<Matrix>;
  7017. /** @hidden */
  7018. _update(world: DeepImmutable<Matrix>): void;
  7019. /**
  7020. * Tests if the bounding box is intersecting the frustum planes
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @returns true if there is an intersection
  7023. */
  7024. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. /**
  7026. * Tests if the bounding box is entirely inside the frustum planes
  7027. * @param frustumPlanes defines the frustum planes to test
  7028. * @returns true if there is an inclusion
  7029. */
  7030. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7031. /**
  7032. * Tests if a point is inside the bounding box
  7033. * @param point defines the point to test
  7034. * @returns true if the point is inside the bounding box
  7035. */
  7036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7037. /**
  7038. * Tests if the bounding box intersects with a bounding sphere
  7039. * @param sphere defines the sphere to test
  7040. * @returns true if there is an intersection
  7041. */
  7042. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7043. /**
  7044. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7045. * @param min defines the min vector to use
  7046. * @param max defines the max vector to use
  7047. * @returns true if there is an intersection
  7048. */
  7049. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7050. /**
  7051. * Tests if two bounding boxes are intersections
  7052. * @param box0 defines the first box to test
  7053. * @param box1 defines the second box to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7057. /**
  7058. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7059. * @param minPoint defines the minimum vector of the bounding box
  7060. * @param maxPoint defines the maximum vector of the bounding box
  7061. * @param sphereCenter defines the sphere center
  7062. * @param sphereRadius defines the sphere radius
  7063. * @returns true if there is an intersection
  7064. */
  7065. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7066. /**
  7067. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7068. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7069. * @param frustumPlanes defines the frustum planes to test
  7070. * @return true if there is an inclusion
  7071. */
  7072. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7073. /**
  7074. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7075. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7076. * @param frustumPlanes defines the frustum planes to test
  7077. * @return true if there is an intersection
  7078. */
  7079. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7080. }
  7081. }
  7082. declare module BABYLON {
  7083. /** @hidden */
  7084. export class Collider {
  7085. /** Define if a collision was found */
  7086. collisionFound: boolean;
  7087. /**
  7088. * Define last intersection point in local space
  7089. */
  7090. intersectionPoint: Vector3;
  7091. /**
  7092. * Define last collided mesh
  7093. */
  7094. collidedMesh: Nullable<AbstractMesh>;
  7095. private _collisionPoint;
  7096. private _planeIntersectionPoint;
  7097. private _tempVector;
  7098. private _tempVector2;
  7099. private _tempVector3;
  7100. private _tempVector4;
  7101. private _edge;
  7102. private _baseToVertex;
  7103. private _destinationPoint;
  7104. private _slidePlaneNormal;
  7105. private _displacementVector;
  7106. /** @hidden */
  7107. _radius: Vector3;
  7108. /** @hidden */
  7109. _retry: number;
  7110. private _velocity;
  7111. private _basePoint;
  7112. private _epsilon;
  7113. /** @hidden */
  7114. _velocityWorldLength: number;
  7115. /** @hidden */
  7116. _basePointWorld: Vector3;
  7117. private _velocityWorld;
  7118. private _normalizedVelocity;
  7119. /** @hidden */
  7120. _initialVelocity: Vector3;
  7121. /** @hidden */
  7122. _initialPosition: Vector3;
  7123. private _nearestDistance;
  7124. private _collisionMask;
  7125. collisionMask: number;
  7126. /**
  7127. * Gets the plane normal used to compute the sliding response (in local space)
  7128. */
  7129. readonly slidePlaneNormal: Vector3;
  7130. /** @hidden */
  7131. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7132. /** @hidden */
  7133. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7134. /** @hidden */
  7135. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7136. /** @hidden */
  7137. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7138. /** @hidden */
  7139. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7140. /** @hidden */
  7141. _getResponse(pos: Vector3, vel: Vector3): void;
  7142. }
  7143. }
  7144. declare module BABYLON {
  7145. /**
  7146. * Interface for cullable objects
  7147. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7148. */
  7149. export interface ICullable {
  7150. /**
  7151. * Checks if the object or part of the object is in the frustum
  7152. * @param frustumPlanes Camera near/planes
  7153. * @returns true if the object is in frustum otherwise false
  7154. */
  7155. isInFrustum(frustumPlanes: Plane[]): boolean;
  7156. /**
  7157. * Checks if a cullable object (mesh...) is in the camera frustum
  7158. * Unlike isInFrustum this cheks the full bounding box
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7163. }
  7164. /**
  7165. * Info for a bounding data of a mesh
  7166. */
  7167. export class BoundingInfo implements ICullable {
  7168. /**
  7169. * Bounding box for the mesh
  7170. */
  7171. readonly boundingBox: BoundingBox;
  7172. /**
  7173. * Bounding sphere for the mesh
  7174. */
  7175. readonly boundingSphere: BoundingSphere;
  7176. private _isLocked;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * Constructs bounding info
  7180. * @param minimum min vector of the bounding box/sphere
  7181. * @param maximum max vector of the bounding box/sphere
  7182. * @param worldMatrix defines the new world matrix
  7183. */
  7184. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7185. /**
  7186. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7187. * @param min defines the new minimum vector (in local space)
  7188. * @param max defines the new maximum vector (in local space)
  7189. * @param worldMatrix defines the new world matrix
  7190. */
  7191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7192. /**
  7193. * min vector of the bounding box/sphere
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * max vector of the bounding box/sphere
  7198. */
  7199. readonly maximum: Vector3;
  7200. /**
  7201. * If the info is locked and won't be updated to avoid perf overhead
  7202. */
  7203. isLocked: boolean;
  7204. /**
  7205. * Updates the bounding sphere and box
  7206. * @param world world matrix to be used to update
  7207. */
  7208. update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7211. * @param center New center of the bounding info
  7212. * @param extend New extend of the bounding info
  7213. * @returns the current bounding info
  7214. */
  7215. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7216. /**
  7217. * Scale the current bounding info by applying a scale factor
  7218. * @param factor defines the scale factor to apply
  7219. * @returns the current bounding info
  7220. */
  7221. scale(factor: number): BoundingInfo;
  7222. /**
  7223. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7224. * @param frustumPlanes defines the frustum to test
  7225. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7226. * @returns true if the bounding info is in the frustum planes
  7227. */
  7228. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7229. /**
  7230. * Gets the world distance between the min and max points of the bounding box
  7231. */
  7232. readonly diagonalLength: number;
  7233. /**
  7234. * Checks if a cullable object (mesh...) is in the camera frustum
  7235. * Unlike isInFrustum this cheks the full bounding box
  7236. * @param frustumPlanes Camera near/planes
  7237. * @returns true if the object is in frustum otherwise false
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /** @hidden */
  7241. _checkCollision(collider: Collider): boolean;
  7242. /**
  7243. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7244. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7245. * @param point the point to check intersection with
  7246. * @returns if the point intersects
  7247. */
  7248. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7249. /**
  7250. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7251. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7252. * @param boundingInfo the bounding info to check intersection with
  7253. * @param precise if the intersection should be done using OBB
  7254. * @returns if the bounding info intersects
  7255. */
  7256. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Defines an array and its length.
  7262. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7263. */
  7264. export interface ISmartArrayLike<T> {
  7265. /**
  7266. * The data of the array.
  7267. */
  7268. data: Array<T>;
  7269. /**
  7270. * The active length of the array.
  7271. */
  7272. length: number;
  7273. }
  7274. /**
  7275. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7276. */
  7277. export class SmartArray<T> implements ISmartArrayLike<T> {
  7278. /**
  7279. * The full set of data from the array.
  7280. */
  7281. data: Array<T>;
  7282. /**
  7283. * The active length of the array.
  7284. */
  7285. length: number;
  7286. protected _id: number;
  7287. /**
  7288. * Instantiates a Smart Array.
  7289. * @param capacity defines the default capacity of the array.
  7290. */
  7291. constructor(capacity: number);
  7292. /**
  7293. * Pushes a value at the end of the active data.
  7294. * @param value defines the object to push in the array.
  7295. */
  7296. push(value: T): void;
  7297. /**
  7298. * Iterates over the active data and apply the lambda to them.
  7299. * @param func defines the action to apply on each value.
  7300. */
  7301. forEach(func: (content: T) => void): void;
  7302. /**
  7303. * Sorts the full sets of data.
  7304. * @param compareFn defines the comparison function to apply.
  7305. */
  7306. sort(compareFn: (a: T, b: T) => number): void;
  7307. /**
  7308. * Resets the active data to an empty array.
  7309. */
  7310. reset(): void;
  7311. /**
  7312. * Releases all the data from the array as well as the array.
  7313. */
  7314. dispose(): void;
  7315. /**
  7316. * Concats the active data with a given array.
  7317. * @param array defines the data to concatenate with.
  7318. */
  7319. concat(array: any): void;
  7320. /**
  7321. * Returns the position of a value in the active data.
  7322. * @param value defines the value to find the index for
  7323. * @returns the index if found in the active data otherwise -1
  7324. */
  7325. indexOf(value: T): number;
  7326. /**
  7327. * Returns whether an element is part of the active data.
  7328. * @param value defines the value to look for
  7329. * @returns true if found in the active data otherwise false
  7330. */
  7331. contains(value: T): boolean;
  7332. private static _GlobalId;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. * The data in this array can only be present once
  7337. */
  7338. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7339. private _duplicateId;
  7340. /**
  7341. * Pushes a value at the end of the active data.
  7342. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7343. * @param value defines the object to push in the array.
  7344. */
  7345. push(value: T): void;
  7346. /**
  7347. * Pushes a value at the end of the active data.
  7348. * If the data is already present, it won t be added again
  7349. * @param value defines the object to push in the array.
  7350. * @returns true if added false if it was already present
  7351. */
  7352. pushNoDuplicate(value: T): boolean;
  7353. /**
  7354. * Resets the active data to an empty array.
  7355. */
  7356. reset(): void;
  7357. /**
  7358. * Concats the active data with a given array.
  7359. * This ensures no dupplicate will be present in the result.
  7360. * @param array defines the data to concatenate with.
  7361. */
  7362. concatWithNoDuplicate(array: any): void;
  7363. }
  7364. }
  7365. declare module BABYLON {
  7366. /**
  7367. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7368. * separate meshes. This can be use to improve performances.
  7369. * @see http://doc.babylonjs.com/how_to/multi_materials
  7370. */
  7371. export class MultiMaterial extends Material {
  7372. private _subMaterials;
  7373. /**
  7374. * Gets or Sets the list of Materials used within the multi material.
  7375. * They need to be ordered according to the submeshes order in the associated mesh
  7376. */
  7377. subMaterials: Nullable<Material>[];
  7378. /**
  7379. * Function used to align with Node.getChildren()
  7380. * @returns the list of Materials used within the multi material
  7381. */
  7382. getChildren(): Nullable<Material>[];
  7383. /**
  7384. * Instantiates a new Multi Material
  7385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7386. * separate meshes. This can be use to improve performances.
  7387. * @see http://doc.babylonjs.com/how_to/multi_materials
  7388. * @param name Define the name in the scene
  7389. * @param scene Define the scene the material belongs to
  7390. */
  7391. constructor(name: string, scene: Scene);
  7392. private _hookArray;
  7393. /**
  7394. * Get one of the submaterial by its index in the submaterials array
  7395. * @param index The index to look the sub material at
  7396. * @returns The Material if the index has been defined
  7397. */
  7398. getSubMaterial(index: number): Nullable<Material>;
  7399. /**
  7400. * Get the list of active textures for the whole sub materials list.
  7401. * @returns All the textures that will be used during the rendering
  7402. */
  7403. getActiveTextures(): BaseTexture[];
  7404. /**
  7405. * Gets the current class name of the material e.g. "MultiMaterial"
  7406. * Mainly use in serialization.
  7407. * @returns the class name
  7408. */
  7409. getClassName(): string;
  7410. /**
  7411. * Checks if the material is ready to render the requested sub mesh
  7412. * @param mesh Define the mesh the submesh belongs to
  7413. * @param subMesh Define the sub mesh to look readyness for
  7414. * @param useInstances Define whether or not the material is used with instances
  7415. * @returns true if ready, otherwise false
  7416. */
  7417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7418. /**
  7419. * Clones the current material and its related sub materials
  7420. * @param name Define the name of the newly cloned material
  7421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7422. * @returns the cloned material
  7423. */
  7424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7425. /**
  7426. * Serializes the materials into a JSON representation.
  7427. * @returns the JSON representation
  7428. */
  7429. serialize(): any;
  7430. /**
  7431. * Dispose the material and release its associated resources
  7432. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7433. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7434. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7435. */
  7436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7437. /**
  7438. * Creates a MultiMaterial from parsed MultiMaterial data.
  7439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7440. * @param scene defines the hosting scene
  7441. * @returns a new MultiMaterial
  7442. */
  7443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7444. }
  7445. }
  7446. declare module BABYLON {
  7447. /**
  7448. * Class used to represent data loading progression
  7449. */
  7450. export class SceneLoaderFlags {
  7451. private static _ForceFullSceneLoadingForIncremental;
  7452. private static _ShowLoadingScreen;
  7453. private static _CleanBoneMatrixWeights;
  7454. private static _loggingLevel;
  7455. /**
  7456. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7457. */
  7458. static ForceFullSceneLoadingForIncremental: boolean;
  7459. /**
  7460. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7461. */
  7462. static ShowLoadingScreen: boolean;
  7463. /**
  7464. * Defines the current logging level (while loading the scene)
  7465. * @ignorenaming
  7466. */
  7467. static loggingLevel: number;
  7468. /**
  7469. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7470. */
  7471. static CleanBoneMatrixWeights: boolean;
  7472. }
  7473. }
  7474. declare module BABYLON {
  7475. /**
  7476. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7477. * @see https://doc.babylonjs.com/how_to/transformnode
  7478. */
  7479. export class TransformNode extends Node {
  7480. /**
  7481. * Object will not rotate to face the camera
  7482. */
  7483. static BILLBOARDMODE_NONE: number;
  7484. /**
  7485. * Object will rotate to face the camera but only on the x axis
  7486. */
  7487. static BILLBOARDMODE_X: number;
  7488. /**
  7489. * Object will rotate to face the camera but only on the y axis
  7490. */
  7491. static BILLBOARDMODE_Y: number;
  7492. /**
  7493. * Object will rotate to face the camera but only on the z axis
  7494. */
  7495. static BILLBOARDMODE_Z: number;
  7496. /**
  7497. * Object will rotate to face the camera
  7498. */
  7499. static BILLBOARDMODE_ALL: number;
  7500. private _forward;
  7501. private _forwardInverted;
  7502. private _up;
  7503. private _right;
  7504. private _rightInverted;
  7505. private _position;
  7506. private _rotation;
  7507. private _rotationQuaternion;
  7508. protected _scaling: Vector3;
  7509. protected _isDirty: boolean;
  7510. private _transformToBoneReferal;
  7511. /**
  7512. * Set the billboard mode. Default is 0.
  7513. *
  7514. * | Value | Type | Description |
  7515. * | --- | --- | --- |
  7516. * | 0 | BILLBOARDMODE_NONE | |
  7517. * | 1 | BILLBOARDMODE_X | |
  7518. * | 2 | BILLBOARDMODE_Y | |
  7519. * | 4 | BILLBOARDMODE_Z | |
  7520. * | 7 | BILLBOARDMODE_ALL | |
  7521. *
  7522. */
  7523. billboardMode: number;
  7524. /**
  7525. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7526. */
  7527. scalingDeterminant: number;
  7528. /**
  7529. * Sets the distance of the object to max, often used by skybox
  7530. */
  7531. infiniteDistance: boolean;
  7532. /**
  7533. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7534. * By default the system will update normals to compensate
  7535. */
  7536. ignoreNonUniformScaling: boolean;
  7537. /** @hidden */
  7538. _poseMatrix: Matrix;
  7539. /** @hidden */
  7540. _localMatrix: Matrix;
  7541. private _absolutePosition;
  7542. private _pivotMatrix;
  7543. private _pivotMatrixInverse;
  7544. protected _postMultiplyPivotMatrix: boolean;
  7545. private _tempMatrix;
  7546. private _tempMatrix2;
  7547. protected _isWorldMatrixFrozen: boolean;
  7548. /** @hidden */
  7549. _indexInSceneTransformNodesArray: number;
  7550. /**
  7551. * An event triggered after the world matrix is updated
  7552. */
  7553. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7554. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7555. /**
  7556. * Gets a string identifying the name of the class
  7557. * @returns "TransformNode" string
  7558. */
  7559. getClassName(): string;
  7560. /**
  7561. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7562. */
  7563. position: Vector3;
  7564. /**
  7565. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7566. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7567. */
  7568. rotation: Vector3;
  7569. /**
  7570. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7571. */
  7572. scaling: Vector3;
  7573. /**
  7574. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7575. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7576. */
  7577. rotationQuaternion: Nullable<Quaternion>;
  7578. /**
  7579. * The forward direction of that transform in world space.
  7580. */
  7581. readonly forward: Vector3;
  7582. /**
  7583. * The up direction of that transform in world space.
  7584. */
  7585. readonly up: Vector3;
  7586. /**
  7587. * The right direction of that transform in world space.
  7588. */
  7589. readonly right: Vector3;
  7590. /**
  7591. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7592. * @param matrix the matrix to copy the pose from
  7593. * @returns this TransformNode.
  7594. */
  7595. updatePoseMatrix(matrix: Matrix): TransformNode;
  7596. /**
  7597. * Returns the mesh Pose matrix.
  7598. * @returns the pose matrix
  7599. */
  7600. getPoseMatrix(): Matrix;
  7601. /** @hidden */
  7602. _isSynchronized(): boolean;
  7603. /** @hidden */
  7604. _initCache(): void;
  7605. /**
  7606. * Flag the transform node as dirty (Forcing it to update everything)
  7607. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7608. * @returns this transform node
  7609. */
  7610. markAsDirty(property: string): TransformNode;
  7611. /**
  7612. * Returns the current mesh absolute position.
  7613. * Returns a Vector3.
  7614. */
  7615. readonly absolutePosition: Vector3;
  7616. /**
  7617. * Sets a new matrix to apply before all other transformation
  7618. * @param matrix defines the transform matrix
  7619. * @returns the current TransformNode
  7620. */
  7621. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7622. /**
  7623. * Sets a new pivot matrix to the current node
  7624. * @param matrix defines the new pivot matrix to use
  7625. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7626. * @returns the current TransformNode
  7627. */
  7628. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7629. /**
  7630. * Returns the mesh pivot matrix.
  7631. * Default : Identity.
  7632. * @returns the matrix
  7633. */
  7634. getPivotMatrix(): Matrix;
  7635. /**
  7636. * Prevents the World matrix to be computed any longer.
  7637. * @returns the TransformNode.
  7638. */
  7639. freezeWorldMatrix(): TransformNode;
  7640. /**
  7641. * Allows back the World matrix computation.
  7642. * @returns the TransformNode.
  7643. */
  7644. unfreezeWorldMatrix(): this;
  7645. /**
  7646. * True if the World matrix has been frozen.
  7647. */
  7648. readonly isWorldMatrixFrozen: boolean;
  7649. /**
  7650. * Retuns the mesh absolute position in the World.
  7651. * @returns a Vector3.
  7652. */
  7653. getAbsolutePosition(): Vector3;
  7654. /**
  7655. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7656. * @param absolutePosition the absolute position to set
  7657. * @returns the TransformNode.
  7658. */
  7659. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7660. /**
  7661. * Sets the mesh position in its local space.
  7662. * @param vector3 the position to set in localspace
  7663. * @returns the TransformNode.
  7664. */
  7665. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7666. /**
  7667. * Returns the mesh position in the local space from the current World matrix values.
  7668. * @returns a new Vector3.
  7669. */
  7670. getPositionExpressedInLocalSpace(): Vector3;
  7671. /**
  7672. * Translates the mesh along the passed Vector3 in its local space.
  7673. * @param vector3 the distance to translate in localspace
  7674. * @returns the TransformNode.
  7675. */
  7676. locallyTranslate(vector3: Vector3): TransformNode;
  7677. private static _lookAtVectorCache;
  7678. /**
  7679. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7680. * @param targetPoint the position (must be in same space as current mesh) to look at
  7681. * @param yawCor optional yaw (y-axis) correction in radians
  7682. * @param pitchCor optional pitch (x-axis) correction in radians
  7683. * @param rollCor optional roll (z-axis) correction in radians
  7684. * @param space the choosen space of the target
  7685. * @returns the TransformNode.
  7686. */
  7687. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7688. /**
  7689. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7690. * This Vector3 is expressed in the World space.
  7691. * @param localAxis axis to rotate
  7692. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7693. */
  7694. getDirection(localAxis: Vector3): Vector3;
  7695. /**
  7696. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7697. * localAxis is expressed in the mesh local space.
  7698. * result is computed in the Wordl space from the mesh World matrix.
  7699. * @param localAxis axis to rotate
  7700. * @param result the resulting transformnode
  7701. * @returns this TransformNode.
  7702. */
  7703. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7704. /**
  7705. * Sets this transform node rotation to the given local axis.
  7706. * @param localAxis the axis in local space
  7707. * @param yawCor optional yaw (y-axis) correction in radians
  7708. * @param pitchCor optional pitch (x-axis) correction in radians
  7709. * @param rollCor optional roll (z-axis) correction in radians
  7710. * @returns this TransformNode
  7711. */
  7712. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7713. /**
  7714. * Sets a new pivot point to the current node
  7715. * @param point defines the new pivot point to use
  7716. * @param space defines if the point is in world or local space (local by default)
  7717. * @returns the current TransformNode
  7718. */
  7719. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7720. /**
  7721. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7722. * @returns the pivot point
  7723. */
  7724. getPivotPoint(): Vector3;
  7725. /**
  7726. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7727. * @param result the vector3 to store the result
  7728. * @returns this TransformNode.
  7729. */
  7730. getPivotPointToRef(result: Vector3): TransformNode;
  7731. /**
  7732. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7733. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7734. */
  7735. getAbsolutePivotPoint(): Vector3;
  7736. /**
  7737. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7738. * @param result vector3 to store the result
  7739. * @returns this TransformNode.
  7740. */
  7741. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7742. /**
  7743. * Defines the passed node as the parent of the current node.
  7744. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7745. * @see https://doc.babylonjs.com/how_to/parenting
  7746. * @param node the node ot set as the parent
  7747. * @returns this TransformNode.
  7748. */
  7749. setParent(node: Nullable<Node>): TransformNode;
  7750. private _nonUniformScaling;
  7751. /**
  7752. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7753. */
  7754. readonly nonUniformScaling: boolean;
  7755. /** @hidden */
  7756. _updateNonUniformScalingState(value: boolean): boolean;
  7757. /**
  7758. * Attach the current TransformNode to another TransformNode associated with a bone
  7759. * @param bone Bone affecting the TransformNode
  7760. * @param affectedTransformNode TransformNode associated with the bone
  7761. * @returns this object
  7762. */
  7763. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7764. /**
  7765. * Detach the transform node if its associated with a bone
  7766. * @returns this object
  7767. */
  7768. detachFromBone(): TransformNode;
  7769. private static _rotationAxisCache;
  7770. /**
  7771. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7772. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7773. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7774. * The passed axis is also normalized.
  7775. * @param axis the axis to rotate around
  7776. * @param amount the amount to rotate in radians
  7777. * @param space Space to rotate in (Default: local)
  7778. * @returns the TransformNode.
  7779. */
  7780. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7781. /**
  7782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7783. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7784. * The passed axis is also normalized. .
  7785. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7786. * @param point the point to rotate around
  7787. * @param axis the axis to rotate around
  7788. * @param amount the amount to rotate in radians
  7789. * @returns the TransformNode
  7790. */
  7791. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7792. /**
  7793. * Translates the mesh along the axis vector for the passed distance in the given space.
  7794. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7795. * @param axis the axis to translate in
  7796. * @param distance the distance to translate
  7797. * @param space Space to rotate in (Default: local)
  7798. * @returns the TransformNode.
  7799. */
  7800. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7801. /**
  7802. * Adds a rotation step to the mesh current rotation.
  7803. * x, y, z are Euler angles expressed in radians.
  7804. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7805. * This means this rotation is made in the mesh local space only.
  7806. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7807. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7808. * ```javascript
  7809. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7810. * ```
  7811. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7812. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7813. * @param x Rotation to add
  7814. * @param y Rotation to add
  7815. * @param z Rotation to add
  7816. * @returns the TransformNode.
  7817. */
  7818. addRotation(x: number, y: number, z: number): TransformNode;
  7819. /**
  7820. * Computes the world matrix of the node
  7821. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7822. * @returns the world matrix
  7823. */
  7824. computeWorldMatrix(force?: boolean): Matrix;
  7825. protected _afterComputeWorldMatrix(): void;
  7826. /**
  7827. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7828. * @param func callback function to add
  7829. *
  7830. * @returns the TransformNode.
  7831. */
  7832. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7833. /**
  7834. * Removes a registered callback function.
  7835. * @param func callback function to remove
  7836. * @returns the TransformNode.
  7837. */
  7838. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7839. /**
  7840. * Gets the position of the current mesh in camera space
  7841. * @param camera defines the camera to use
  7842. * @returns a position
  7843. */
  7844. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7845. /**
  7846. * Returns the distance from the mesh to the active camera
  7847. * @param camera defines the camera to use
  7848. * @returns the distance
  7849. */
  7850. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7851. /**
  7852. * Clone the current transform node
  7853. * @param name Name of the new clone
  7854. * @param newParent New parent for the clone
  7855. * @param doNotCloneChildren Do not clone children hierarchy
  7856. * @returns the new transform node
  7857. */
  7858. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7859. /**
  7860. * Serializes the objects information.
  7861. * @param currentSerializationObject defines the object to serialize in
  7862. * @returns the serialized object
  7863. */
  7864. serialize(currentSerializationObject?: any): any;
  7865. /**
  7866. * Returns a new TransformNode object parsed from the source provided.
  7867. * @param parsedTransformNode is the source.
  7868. * @param scene the scne the object belongs to
  7869. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7870. * @returns a new TransformNode object parsed from the source provided.
  7871. */
  7872. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7873. /**
  7874. * Get all child-transformNodes of this node
  7875. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7876. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7877. * @returns an array of TransformNode
  7878. */
  7879. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7880. /**
  7881. * Releases resources associated with this transform node.
  7882. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7883. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7884. */
  7885. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7886. }
  7887. }
  7888. declare module BABYLON {
  7889. /**
  7890. * Class used to override all child animations of a given target
  7891. */
  7892. export class AnimationPropertiesOverride {
  7893. /**
  7894. * Gets or sets a value indicating if animation blending must be used
  7895. */
  7896. enableBlending: boolean;
  7897. /**
  7898. * Gets or sets the blending speed to use when enableBlending is true
  7899. */
  7900. blendingSpeed: number;
  7901. /**
  7902. * Gets or sets the default loop mode to use
  7903. */
  7904. loopMode: number;
  7905. }
  7906. }
  7907. declare module BABYLON {
  7908. /**
  7909. * Class used to store bone information
  7910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7911. */
  7912. export class Bone extends Node {
  7913. /**
  7914. * defines the bone name
  7915. */
  7916. name: string;
  7917. private static _tmpVecs;
  7918. private static _tmpQuat;
  7919. private static _tmpMats;
  7920. /**
  7921. * Gets the list of child bones
  7922. */
  7923. children: Bone[];
  7924. /** Gets the animations associated with this bone */
  7925. animations: Animation[];
  7926. /**
  7927. * Gets or sets bone length
  7928. */
  7929. length: number;
  7930. /**
  7931. * @hidden Internal only
  7932. * Set this value to map this bone to a different index in the transform matrices
  7933. * Set this value to -1 to exclude the bone from the transform matrices
  7934. */
  7935. _index: Nullable<number>;
  7936. private _skeleton;
  7937. private _localMatrix;
  7938. private _restPose;
  7939. private _baseMatrix;
  7940. private _absoluteTransform;
  7941. private _invertedAbsoluteTransform;
  7942. private _parent;
  7943. private _scalingDeterminant;
  7944. private _worldTransform;
  7945. private _localScaling;
  7946. private _localRotation;
  7947. private _localPosition;
  7948. private _needToDecompose;
  7949. private _needToCompose;
  7950. /** @hidden */
  7951. _linkedTransformNode: Nullable<TransformNode>;
  7952. /** @hidden */
  7953. /** @hidden */
  7954. _matrix: Matrix;
  7955. /**
  7956. * Create a new bone
  7957. * @param name defines the bone name
  7958. * @param skeleton defines the parent skeleton
  7959. * @param parentBone defines the parent (can be null if the bone is the root)
  7960. * @param localMatrix defines the local matrix
  7961. * @param restPose defines the rest pose matrix
  7962. * @param baseMatrix defines the base matrix
  7963. * @param index defines index of the bone in the hiearchy
  7964. */
  7965. constructor(
  7966. /**
  7967. * defines the bone name
  7968. */
  7969. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7970. /**
  7971. * Gets the current object class name.
  7972. * @return the class name
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Gets the parent skeleton
  7977. * @returns a skeleton
  7978. */
  7979. getSkeleton(): Skeleton;
  7980. /**
  7981. * Gets parent bone
  7982. * @returns a bone or null if the bone is the root of the bone hierarchy
  7983. */
  7984. getParent(): Nullable<Bone>;
  7985. /**
  7986. * Returns an array containing the root bones
  7987. * @returns an array containing the root bones
  7988. */
  7989. getChildren(): Array<Bone>;
  7990. /**
  7991. * Sets the parent bone
  7992. * @param parent defines the parent (can be null if the bone is the root)
  7993. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7994. */
  7995. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7996. /**
  7997. * Gets the local matrix
  7998. * @returns a matrix
  7999. */
  8000. getLocalMatrix(): Matrix;
  8001. /**
  8002. * Gets the base matrix (initial matrix which remains unchanged)
  8003. * @returns a matrix
  8004. */
  8005. getBaseMatrix(): Matrix;
  8006. /**
  8007. * Gets the rest pose matrix
  8008. * @returns a matrix
  8009. */
  8010. getRestPose(): Matrix;
  8011. /**
  8012. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8013. */
  8014. getWorldMatrix(): Matrix;
  8015. /**
  8016. * Sets the local matrix to rest pose matrix
  8017. */
  8018. returnToRest(): void;
  8019. /**
  8020. * Gets the inverse of the absolute transform matrix.
  8021. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8022. * @returns a matrix
  8023. */
  8024. getInvertedAbsoluteTransform(): Matrix;
  8025. /**
  8026. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8027. * @returns a matrix
  8028. */
  8029. getAbsoluteTransform(): Matrix;
  8030. /**
  8031. * Links with the given transform node.
  8032. * The local matrix of this bone is copied from the transform node every frame.
  8033. * @param transformNode defines the transform node to link to
  8034. */
  8035. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8036. /** Gets or sets current position (in local space) */
  8037. position: Vector3;
  8038. /** Gets or sets current rotation (in local space) */
  8039. rotation: Vector3;
  8040. /** Gets or sets current rotation quaternion (in local space) */
  8041. rotationQuaternion: Quaternion;
  8042. /** Gets or sets current scaling (in local space) */
  8043. scaling: Vector3;
  8044. /**
  8045. * Gets the animation properties override
  8046. */
  8047. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8048. private _decompose;
  8049. private _compose;
  8050. /**
  8051. * Update the base and local matrices
  8052. * @param matrix defines the new base or local matrix
  8053. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8054. * @param updateLocalMatrix defines if the local matrix should be updated
  8055. */
  8056. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8057. /** @hidden */
  8058. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8059. /**
  8060. * Flag the bone as dirty (Forcing it to update everything)
  8061. */
  8062. markAsDirty(): void;
  8063. private _markAsDirtyAndCompose;
  8064. private _markAsDirtyAndDecompose;
  8065. /**
  8066. * Translate the bone in local or world space
  8067. * @param vec The amount to translate the bone
  8068. * @param space The space that the translation is in
  8069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8070. */
  8071. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8072. /**
  8073. * Set the postion of the bone in local or world space
  8074. * @param position The position to set the bone
  8075. * @param space The space that the position is in
  8076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8077. */
  8078. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8079. /**
  8080. * Set the absolute position of the bone (world space)
  8081. * @param position The position to set the bone
  8082. * @param mesh The mesh that this bone is attached to
  8083. */
  8084. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8085. /**
  8086. * Scale the bone on the x, y and z axes (in local space)
  8087. * @param x The amount to scale the bone on the x axis
  8088. * @param y The amount to scale the bone on the y axis
  8089. * @param z The amount to scale the bone on the z axis
  8090. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8091. */
  8092. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8093. /**
  8094. * Set the bone scaling in local space
  8095. * @param scale defines the scaling vector
  8096. */
  8097. setScale(scale: Vector3): void;
  8098. /**
  8099. * Gets the current scaling in local space
  8100. * @returns the current scaling vector
  8101. */
  8102. getScale(): Vector3;
  8103. /**
  8104. * Gets the current scaling in local space and stores it in a target vector
  8105. * @param result defines the target vector
  8106. */
  8107. getScaleToRef(result: Vector3): void;
  8108. /**
  8109. * Set the yaw, pitch, and roll of the bone in local or world space
  8110. * @param yaw The rotation of the bone on the y axis
  8111. * @param pitch The rotation of the bone on the x axis
  8112. * @param roll The rotation of the bone on the z axis
  8113. * @param space The space that the axes of rotation are in
  8114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8115. */
  8116. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8117. /**
  8118. * Add a rotation to the bone on an axis in local or world space
  8119. * @param axis The axis to rotate the bone on
  8120. * @param amount The amount to rotate the bone
  8121. * @param space The space that the axis is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. */
  8124. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8125. /**
  8126. * Set the rotation of the bone to a particular axis angle in local or world space
  8127. * @param axis The axis to rotate the bone on
  8128. * @param angle The angle that the bone should be rotated to
  8129. * @param space The space that the axis is in
  8130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8131. */
  8132. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8133. /**
  8134. * Set the euler rotation of the bone in local of world space
  8135. * @param rotation The euler rotation that the bone should be set to
  8136. * @param space The space that the rotation is in
  8137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8138. */
  8139. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Set the quaternion rotation of the bone in local of world space
  8142. * @param quat The quaternion rotation that the bone should be set to
  8143. * @param space The space that the rotation is in
  8144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8145. */
  8146. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8147. /**
  8148. * Set the rotation matrix of the bone in local of world space
  8149. * @param rotMat The rotation matrix that the bone should be set to
  8150. * @param space The space that the rotation is in
  8151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8152. */
  8153. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8154. private _rotateWithMatrix;
  8155. private _getNegativeRotationToRef;
  8156. /**
  8157. * Get the position of the bone in local or world space
  8158. * @param space The space that the returned position is in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @returns The position of the bone
  8161. */
  8162. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8163. /**
  8164. * Copy the position of the bone to a vector3 in local or world space
  8165. * @param space The space that the returned position is in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. * @param result The vector3 to copy the position to
  8168. */
  8169. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8170. /**
  8171. * Get the absolute position of the bone (world space)
  8172. * @param mesh The mesh that this bone is attached to
  8173. * @returns The absolute position of the bone
  8174. */
  8175. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8176. /**
  8177. * Copy the absolute position of the bone (world space) to the result param
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 to copy the absolute position to
  8180. */
  8181. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8182. /**
  8183. * Compute the absolute transforms of this bone and its children
  8184. */
  8185. computeAbsoluteTransforms(): void;
  8186. /**
  8187. * Get the world direction from an axis that is in the local space of the bone
  8188. * @param localAxis The local direction that is used to compute the world direction
  8189. * @param mesh The mesh that this bone is attached to
  8190. * @returns The world direction
  8191. */
  8192. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8193. /**
  8194. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8195. * @param localAxis The local direction that is used to compute the world direction
  8196. * @param mesh The mesh that this bone is attached to
  8197. * @param result The vector3 that the world direction will be copied to
  8198. */
  8199. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8200. /**
  8201. * Get the euler rotation of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The euler rotation
  8205. */
  8206. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8207. /**
  8208. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The vector3 that the rotation should be copied to
  8212. */
  8213. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8214. /**
  8215. * Get the quaternion rotation of the bone in either local or world space
  8216. * @param space The space that the rotation should be in
  8217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8218. * @returns The quaternion rotation
  8219. */
  8220. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8221. /**
  8222. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8223. * @param space The space that the rotation should be in
  8224. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8225. * @param result The quaternion that the rotation should be copied to
  8226. */
  8227. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8228. /**
  8229. * Get the rotation matrix of the bone in local or world space
  8230. * @param space The space that the rotation should be in
  8231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8232. * @returns The rotation matrix
  8233. */
  8234. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8235. /**
  8236. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8237. * @param space The space that the rotation should be in
  8238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8239. * @param result The quaternion that the rotation should be copied to
  8240. */
  8241. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8242. /**
  8243. * Get the world position of a point that is in the local space of the bone
  8244. * @param position The local position
  8245. * @param mesh The mesh that this bone is attached to
  8246. * @returns The world position
  8247. */
  8248. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8249. /**
  8250. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8251. * @param position The local position
  8252. * @param mesh The mesh that this bone is attached to
  8253. * @param result The vector3 that the world position should be copied to
  8254. */
  8255. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8256. /**
  8257. * Get the local position of a point that is in world space
  8258. * @param position The world position
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @returns The local position
  8261. */
  8262. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8263. /**
  8264. * Get the local position of a point that is in world space and copy it to the result param
  8265. * @param position The world position
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @param result The vector3 that the local position should be copied to
  8268. */
  8269. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8270. }
  8271. }
  8272. declare module BABYLON {
  8273. /**
  8274. * Enum that determines the text-wrapping mode to use.
  8275. */
  8276. export enum InspectableType {
  8277. /**
  8278. * Checkbox for booleans
  8279. */
  8280. Checkbox = 0,
  8281. /**
  8282. * Sliders for numbers
  8283. */
  8284. Slider = 1,
  8285. /**
  8286. * Vector3
  8287. */
  8288. Vector3 = 2,
  8289. /**
  8290. * Quaternions
  8291. */
  8292. Quaternion = 3,
  8293. /**
  8294. * Color3
  8295. */
  8296. Color3 = 4
  8297. }
  8298. /**
  8299. * Interface used to define custom inspectable properties.
  8300. * This interface is used by the inspector to display custom property grids
  8301. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8302. */
  8303. export interface IInspectable {
  8304. /**
  8305. * Gets the label to display
  8306. */
  8307. label: string;
  8308. /**
  8309. * Gets the name of the property to edit
  8310. */
  8311. propertyName: string;
  8312. /**
  8313. * Gets the type of the editor to use
  8314. */
  8315. type: InspectableType;
  8316. /**
  8317. * Gets the minimum value of the property when using in "slider" mode
  8318. */
  8319. min?: number;
  8320. /**
  8321. * Gets the maximum value of the property when using in "slider" mode
  8322. */
  8323. max?: number;
  8324. /**
  8325. * Gets the setp to use when using in "slider" mode
  8326. */
  8327. step?: number;
  8328. }
  8329. }
  8330. declare module BABYLON {
  8331. /**
  8332. * Class for creating a cube texture
  8333. */
  8334. export class CubeTexture extends BaseTexture {
  8335. private _delayedOnLoad;
  8336. /**
  8337. * The url of the texture
  8338. */
  8339. url: string;
  8340. /**
  8341. * Gets or sets the center of the bounding box associated with the cube texture.
  8342. * It must define where the camera used to render the texture was set
  8343. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8344. */
  8345. boundingBoxPosition: Vector3;
  8346. private _boundingBoxSize;
  8347. /**
  8348. * Gets or sets the size of the bounding box associated with the cube texture
  8349. * When defined, the cubemap will switch to local mode
  8350. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8351. * @example https://www.babylonjs-playground.com/#RNASML
  8352. */
  8353. /**
  8354. * Returns the bounding box size
  8355. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8356. */
  8357. boundingBoxSize: Vector3;
  8358. protected _rotationY: number;
  8359. /**
  8360. * Sets texture matrix rotation angle around Y axis in radians.
  8361. */
  8362. /**
  8363. * Gets texture matrix rotation angle around Y axis radians.
  8364. */
  8365. rotationY: number;
  8366. /**
  8367. * Are mip maps generated for this texture or not.
  8368. */
  8369. readonly noMipmap: boolean;
  8370. private _noMipmap;
  8371. private _files;
  8372. private _extensions;
  8373. private _textureMatrix;
  8374. private _format;
  8375. private _createPolynomials;
  8376. /** @hidden */
  8377. _prefiltered: boolean;
  8378. /**
  8379. * Creates a cube texture from an array of image urls
  8380. * @param files defines an array of image urls
  8381. * @param scene defines the hosting scene
  8382. * @param noMipmap specifies if mip maps are not used
  8383. * @returns a cube texture
  8384. */
  8385. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8386. /**
  8387. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8388. * @param url defines the url of the prefiltered texture
  8389. * @param scene defines the scene the texture is attached to
  8390. * @param forcedExtension defines the extension of the file if different from the url
  8391. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8392. * @return the prefiltered texture
  8393. */
  8394. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8395. /**
  8396. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8397. * as prefiltered data.
  8398. * @param rootUrl defines the url of the texture or the root name of the six images
  8399. * @param scene defines the scene the texture is attached to
  8400. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8401. * @param noMipmap defines if mipmaps should be created or not
  8402. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8403. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8404. * @param onError defines a callback triggered in case of error during load
  8405. * @param format defines the internal format to use for the texture once loaded
  8406. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8407. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8408. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8409. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8410. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8411. * @return the cube texture
  8412. */
  8413. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8414. /**
  8415. * Get the current class name of the texture useful for serialization or dynamic coding.
  8416. * @returns "CubeTexture"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Update the url (and optional buffer) of this texture if url was null during construction.
  8421. * @param url the url of the texture
  8422. * @param forcedExtension defines the extension to use
  8423. * @param onLoad callback called when the texture is loaded (defaults to null)
  8424. */
  8425. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8426. /**
  8427. * Delays loading of the cube texture
  8428. * @param forcedExtension defines the extension to use
  8429. */
  8430. delayLoad(forcedExtension?: string): void;
  8431. /**
  8432. * Returns the reflection texture matrix
  8433. * @returns the reflection texture matrix
  8434. */
  8435. getReflectionTextureMatrix(): Matrix;
  8436. /**
  8437. * Sets the reflection texture matrix
  8438. * @param value Reflection texture matrix
  8439. */
  8440. setReflectionTextureMatrix(value: Matrix): void;
  8441. /**
  8442. * Parses text to create a cube texture
  8443. * @param parsedTexture define the serialized text to read from
  8444. * @param scene defines the hosting scene
  8445. * @param rootUrl defines the root url of the cube texture
  8446. * @returns a cube texture
  8447. */
  8448. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8449. /**
  8450. * Makes a clone, or deep copy, of the cube texture
  8451. * @returns a new cube texture
  8452. */
  8453. clone(): CubeTexture;
  8454. }
  8455. }
  8456. declare module BABYLON {
  8457. /** @hidden */
  8458. export var postprocessVertexShader: {
  8459. name: string;
  8460. shader: string;
  8461. };
  8462. }
  8463. declare module BABYLON {
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * This will automatically adapt alpha beta and radius to fit within the new target.
  8571. * @param target Defines the new target as a Vector or a mesh
  8572. */
  8573. setTarget(target: Vector3): void;
  8574. /**
  8575. * Return the current target position of the camera. This value is expressed in local space.
  8576. * @returns the target position
  8577. */
  8578. getTarget(): Vector3;
  8579. /** @hidden */
  8580. _decideIfNeedsToMove(): boolean;
  8581. /** @hidden */
  8582. _updatePosition(): void;
  8583. /** @hidden */
  8584. _checkInputs(): void;
  8585. protected _updateCameraRotationMatrix(): void;
  8586. /**
  8587. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8588. * @returns the current camera
  8589. */
  8590. private _rotateUpVectorWithCameraRotationMatrix;
  8591. private _cachedRotationZ;
  8592. private _cachedQuaternionRotationZ;
  8593. /** @hidden */
  8594. _getViewMatrix(): Matrix;
  8595. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8596. /**
  8597. * @hidden
  8598. */
  8599. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8600. /**
  8601. * @hidden
  8602. */
  8603. _updateRigCameras(): void;
  8604. private _getRigCamPositionAndTarget;
  8605. /**
  8606. * Gets the current object class name.
  8607. * @return the class name
  8608. */
  8609. getClassName(): string;
  8610. }
  8611. }
  8612. declare module BABYLON {
  8613. /**
  8614. * @ignore
  8615. * This is a list of all the different input types that are available in the application.
  8616. * Fo instance: ArcRotateCameraGamepadInput...
  8617. */
  8618. export var CameraInputTypes: {};
  8619. /**
  8620. * This is the contract to implement in order to create a new input class.
  8621. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8622. */
  8623. export interface ICameraInput<TCamera extends Camera> {
  8624. /**
  8625. * Defines the camera the input is attached to.
  8626. */
  8627. camera: Nullable<TCamera>;
  8628. /**
  8629. * Gets the class name of the current intput.
  8630. * @returns the class name
  8631. */
  8632. getClassName(): string;
  8633. /**
  8634. * Get the friendly name associated with the input class.
  8635. * @returns the input friendly name
  8636. */
  8637. getSimpleName(): string;
  8638. /**
  8639. * Attach the input controls to a specific dom element to get the input from.
  8640. * @param element Defines the element the controls should be listened from
  8641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8642. */
  8643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8644. /**
  8645. * Detach the current controls from the specified dom element.
  8646. * @param element Defines the element to stop listening the inputs from
  8647. */
  8648. detachControl(element: Nullable<HTMLElement>): void;
  8649. /**
  8650. * Update the current camera state depending on the inputs that have been used this frame.
  8651. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8652. */
  8653. checkInputs?: () => void;
  8654. }
  8655. /**
  8656. * Represents a map of input types to input instance or input index to input instance.
  8657. */
  8658. export interface CameraInputsMap<TCamera extends Camera> {
  8659. /**
  8660. * Accessor to the input by input type.
  8661. */
  8662. [name: string]: ICameraInput<TCamera>;
  8663. /**
  8664. * Accessor to the input by input index.
  8665. */
  8666. [idx: number]: ICameraInput<TCamera>;
  8667. }
  8668. /**
  8669. * This represents the input manager used within a camera.
  8670. * It helps dealing with all the different kind of input attached to a camera.
  8671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8672. */
  8673. export class CameraInputsManager<TCamera extends Camera> {
  8674. /**
  8675. * Defines the list of inputs attahed to the camera.
  8676. */
  8677. attached: CameraInputsMap<TCamera>;
  8678. /**
  8679. * Defines the dom element the camera is collecting inputs from.
  8680. * This is null if the controls have not been attached.
  8681. */
  8682. attachedElement: Nullable<HTMLElement>;
  8683. /**
  8684. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8685. */
  8686. noPreventDefault: boolean;
  8687. /**
  8688. * Defined the camera the input manager belongs to.
  8689. */
  8690. camera: TCamera;
  8691. /**
  8692. * Update the current camera state depending on the inputs that have been used this frame.
  8693. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8694. */
  8695. checkInputs: () => void;
  8696. /**
  8697. * Instantiate a new Camera Input Manager.
  8698. * @param camera Defines the camera the input manager blongs to
  8699. */
  8700. constructor(camera: TCamera);
  8701. /**
  8702. * Add an input method to a camera
  8703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8704. * @param input camera input method
  8705. */
  8706. add(input: ICameraInput<TCamera>): void;
  8707. /**
  8708. * Remove a specific input method from a camera
  8709. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8710. * @param inputToRemove camera input method
  8711. */
  8712. remove(inputToRemove: ICameraInput<TCamera>): void;
  8713. /**
  8714. * Remove a specific input type from a camera
  8715. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8716. * @param inputType the type of the input to remove
  8717. */
  8718. removeByType(inputType: string): void;
  8719. private _addCheckInputs;
  8720. /**
  8721. * Attach the input controls to the currently attached dom element to listen the events from.
  8722. * @param input Defines the input to attach
  8723. */
  8724. attachInput(input: ICameraInput<TCamera>): void;
  8725. /**
  8726. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8727. * @param element Defines the dom element to collect the events from
  8728. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8729. */
  8730. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8731. /**
  8732. * Detach the current manager inputs controls from a specific dom element.
  8733. * @param element Defines the dom element to collect the events from
  8734. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8735. */
  8736. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8737. /**
  8738. * Rebuild the dynamic inputCheck function from the current list of
  8739. * defined inputs in the manager.
  8740. */
  8741. rebuildInputCheck(): void;
  8742. /**
  8743. * Remove all attached input methods from a camera
  8744. */
  8745. clear(): void;
  8746. /**
  8747. * Serialize the current input manager attached to a camera.
  8748. * This ensures than once parsed,
  8749. * the input associated to the camera will be identical to the current ones
  8750. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8751. */
  8752. serialize(serializedCamera: any): void;
  8753. /**
  8754. * Parses an input manager serialized JSON to restore the previous list of inputs
  8755. * and states associated to a camera.
  8756. * @param parsedCamera Defines the JSON to parse
  8757. */
  8758. parse(parsedCamera: any): void;
  8759. }
  8760. }
  8761. declare module BABYLON {
  8762. /**
  8763. * Gather the list of keyboard event types as constants.
  8764. */
  8765. export class KeyboardEventTypes {
  8766. /**
  8767. * The keydown event is fired when a key becomes active (pressed).
  8768. */
  8769. static readonly KEYDOWN: number;
  8770. /**
  8771. * The keyup event is fired when a key has been released.
  8772. */
  8773. static readonly KEYUP: number;
  8774. }
  8775. /**
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. */
  8778. export class KeyboardInfo {
  8779. /**
  8780. * Defines the type of event (KeyboardEventTypes)
  8781. */
  8782. type: number;
  8783. /**
  8784. * Defines the related dom event
  8785. */
  8786. event: KeyboardEvent;
  8787. /**
  8788. * Instantiates a new keyboard info.
  8789. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8790. * @param type Defines the type of event (KeyboardEventTypes)
  8791. * @param event Defines the related dom event
  8792. */
  8793. constructor(
  8794. /**
  8795. * Defines the type of event (KeyboardEventTypes)
  8796. */
  8797. type: number,
  8798. /**
  8799. * Defines the related dom event
  8800. */
  8801. event: KeyboardEvent);
  8802. }
  8803. /**
  8804. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8805. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8806. */
  8807. export class KeyboardInfoPre extends KeyboardInfo {
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number;
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent;
  8816. /**
  8817. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8818. */
  8819. skipOnPointerObservable: boolean;
  8820. /**
  8821. * Instantiates a new keyboard pre info.
  8822. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8823. * @param type Defines the type of event (KeyboardEventTypes)
  8824. * @param event Defines the related dom event
  8825. */
  8826. constructor(
  8827. /**
  8828. * Defines the type of event (KeyboardEventTypes)
  8829. */
  8830. type: number,
  8831. /**
  8832. * Defines the related dom event
  8833. */
  8834. event: KeyboardEvent);
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Manage the keyboard inputs to control the movement of a free camera.
  8840. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8841. */
  8842. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8843. /**
  8844. * Defines the camera the input is attached to.
  8845. */
  8846. camera: FreeCamera;
  8847. /**
  8848. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8849. */
  8850. keysUp: number[];
  8851. /**
  8852. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8853. */
  8854. keysDown: number[];
  8855. /**
  8856. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8857. */
  8858. keysLeft: number[];
  8859. /**
  8860. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8861. */
  8862. keysRight: number[];
  8863. private _keys;
  8864. private _onCanvasBlurObserver;
  8865. private _onKeyboardObserver;
  8866. private _engine;
  8867. private _scene;
  8868. /**
  8869. * Attach the input controls to a specific dom element to get the input from.
  8870. * @param element Defines the element the controls should be listened from
  8871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8872. */
  8873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8874. /**
  8875. * Detach the current controls from the specified dom element.
  8876. * @param element Defines the element to stop listening the inputs from
  8877. */
  8878. detachControl(element: Nullable<HTMLElement>): void;
  8879. /**
  8880. * Update the current camera state depending on the inputs that have been used this frame.
  8881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8882. */
  8883. checkInputs(): void;
  8884. /**
  8885. * Gets the class name of the current intput.
  8886. * @returns the class name
  8887. */
  8888. getClassName(): string;
  8889. /** @hidden */
  8890. _onLostFocus(): void;
  8891. /**
  8892. * Get the friendly name associated with the input class.
  8893. * @returns the input friendly name
  8894. */
  8895. getSimpleName(): string;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * Interface describing all the common properties and methods a shadow light needs to implement.
  8901. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8902. * as well as binding the different shadow properties to the effects.
  8903. */
  8904. export interface IShadowLight extends Light {
  8905. /**
  8906. * The light id in the scene (used in scene.findLighById for instance)
  8907. */
  8908. id: string;
  8909. /**
  8910. * The position the shdow will be casted from.
  8911. */
  8912. position: Vector3;
  8913. /**
  8914. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8915. */
  8916. direction: Vector3;
  8917. /**
  8918. * The transformed position. Position of the light in world space taking parenting in account.
  8919. */
  8920. transformedPosition: Vector3;
  8921. /**
  8922. * The transformed direction. Direction of the light in world space taking parenting in account.
  8923. */
  8924. transformedDirection: Vector3;
  8925. /**
  8926. * The friendly name of the light in the scene.
  8927. */
  8928. name: string;
  8929. /**
  8930. * Defines the shadow projection clipping minimum z value.
  8931. */
  8932. shadowMinZ: number;
  8933. /**
  8934. * Defines the shadow projection clipping maximum z value.
  8935. */
  8936. shadowMaxZ: number;
  8937. /**
  8938. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8939. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8940. */
  8941. computeTransformedInformation(): boolean;
  8942. /**
  8943. * Gets the scene the light belongs to.
  8944. * @returns The scene
  8945. */
  8946. getScene(): Scene;
  8947. /**
  8948. * Callback defining a custom Projection Matrix Builder.
  8949. * This can be used to override the default projection matrix computation.
  8950. */
  8951. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8952. /**
  8953. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8954. * @param matrix The materix to updated with the projection information
  8955. * @param viewMatrix The transform matrix of the light
  8956. * @param renderList The list of mesh to render in the map
  8957. * @returns The current light
  8958. */
  8959. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8960. /**
  8961. * Gets the current depth scale used in ESM.
  8962. * @returns The scale
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8967. * @returns true if a cube texture needs to be use
  8968. */
  8969. needCube(): boolean;
  8970. /**
  8971. * Detects if the projection matrix requires to be recomputed this frame.
  8972. * @returns true if it requires to be recomputed otherwise, false.
  8973. */
  8974. needProjectionMatrixCompute(): boolean;
  8975. /**
  8976. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8977. */
  8978. forceProjectionMatrixCompute(): void;
  8979. /**
  8980. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8981. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8982. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8983. */
  8984. getShadowDirection(faceIndex?: number): Vector3;
  8985. /**
  8986. * Gets the minZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the min for
  8988. * @returns the depth min z
  8989. */
  8990. getDepthMinZ(activeCamera: Camera): number;
  8991. /**
  8992. * Gets the maxZ used for shadow according to both the scene and the light.
  8993. * @param activeCamera The camera we are returning the max for
  8994. * @returns the depth max z
  8995. */
  8996. getDepthMaxZ(activeCamera: Camera): number;
  8997. }
  8998. /**
  8999. * Base implementation IShadowLight
  9000. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9001. */
  9002. export abstract class ShadowLight extends Light implements IShadowLight {
  9003. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9004. protected _position: Vector3;
  9005. protected _setPosition(value: Vector3): void;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. /**
  9011. * Sets the position the shadow will be casted from. Also use as the light position for both
  9012. * point and spot lights.
  9013. */
  9014. position: Vector3;
  9015. protected _direction: Vector3;
  9016. protected _setDirection(value: Vector3): void;
  9017. /**
  9018. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. /**
  9022. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9023. * Also use as the light direction on spot and directional lights.
  9024. */
  9025. direction: Vector3;
  9026. private _shadowMinZ;
  9027. /**
  9028. * Gets the shadow projection clipping minimum z value.
  9029. */
  9030. /**
  9031. * Sets the shadow projection clipping minimum z value.
  9032. */
  9033. shadowMinZ: number;
  9034. private _shadowMaxZ;
  9035. /**
  9036. * Sets the shadow projection clipping maximum z value.
  9037. */
  9038. /**
  9039. * Gets the shadow projection clipping maximum z value.
  9040. */
  9041. shadowMaxZ: number;
  9042. /**
  9043. * Callback defining a custom Projection Matrix Builder.
  9044. * This can be used to override the default projection matrix computation.
  9045. */
  9046. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9047. /**
  9048. * The transformed position. Position of the light in world space taking parenting in account.
  9049. */
  9050. transformedPosition: Vector3;
  9051. /**
  9052. * The transformed direction. Direction of the light in world space taking parenting in account.
  9053. */
  9054. transformedDirection: Vector3;
  9055. private _needProjectionMatrixCompute;
  9056. /**
  9057. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9058. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9059. */
  9060. computeTransformedInformation(): boolean;
  9061. /**
  9062. * Return the depth scale used for the shadow map.
  9063. * @returns the depth scale.
  9064. */
  9065. getDepthScale(): number;
  9066. /**
  9067. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9068. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9069. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9070. */
  9071. getShadowDirection(faceIndex?: number): Vector3;
  9072. /**
  9073. * Returns the ShadowLight absolute position in the World.
  9074. * @returns the position vector in world space
  9075. */
  9076. getAbsolutePosition(): Vector3;
  9077. /**
  9078. * Sets the ShadowLight direction toward the passed target.
  9079. * @param target The point to target in local space
  9080. * @returns the updated ShadowLight direction
  9081. */
  9082. setDirectionToTarget(target: Vector3): Vector3;
  9083. /**
  9084. * Returns the light rotation in euler definition.
  9085. * @returns the x y z rotation in local space.
  9086. */
  9087. getRotation(): Vector3;
  9088. /**
  9089. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9090. * @returns true if a cube texture needs to be use
  9091. */
  9092. needCube(): boolean;
  9093. /**
  9094. * Detects if the projection matrix requires to be recomputed this frame.
  9095. * @returns true if it requires to be recomputed otherwise, false.
  9096. */
  9097. needProjectionMatrixCompute(): boolean;
  9098. /**
  9099. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9100. */
  9101. forceProjectionMatrixCompute(): void;
  9102. /** @hidden */
  9103. _initCache(): void;
  9104. /** @hidden */
  9105. _isSynchronized(): boolean;
  9106. /**
  9107. * Computes the world matrix of the node
  9108. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9109. * @returns the world matrix
  9110. */
  9111. computeWorldMatrix(force?: boolean): Matrix;
  9112. /**
  9113. * Gets the minZ used for shadow according to both the scene and the light.
  9114. * @param activeCamera The camera we are returning the min for
  9115. * @returns the depth min z
  9116. */
  9117. getDepthMinZ(activeCamera: Camera): number;
  9118. /**
  9119. * Gets the maxZ used for shadow according to both the scene and the light.
  9120. * @param activeCamera The camera we are returning the max for
  9121. * @returns the depth max z
  9122. */
  9123. getDepthMaxZ(activeCamera: Camera): number;
  9124. /**
  9125. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9126. * @param matrix The materix to updated with the projection information
  9127. * @param viewMatrix The transform matrix of the light
  9128. * @param renderList The list of mesh to render in the map
  9129. * @returns The current light
  9130. */
  9131. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9132. }
  9133. }
  9134. declare module BABYLON {
  9135. /**
  9136. * "Static Class" containing the most commonly used helper while dealing with material for
  9137. * rendering purpose.
  9138. *
  9139. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9140. *
  9141. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9142. */
  9143. export class MaterialHelper {
  9144. /**
  9145. * Bind the current view position to an effect.
  9146. * @param effect The effect to be bound
  9147. * @param scene The scene the eyes position is used from
  9148. */
  9149. static BindEyePosition(effect: Effect, scene: Scene): void;
  9150. /**
  9151. * Helps preparing the defines values about the UVs in used in the effect.
  9152. * UVs are shared as much as we can accross channels in the shaders.
  9153. * @param texture The texture we are preparing the UVs for
  9154. * @param defines The defines to update
  9155. * @param key The channel key "diffuse", "specular"... used in the shader
  9156. */
  9157. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9158. /**
  9159. * Binds a texture matrix value to its corrsponding uniform
  9160. * @param texture The texture to bind the matrix for
  9161. * @param uniformBuffer The uniform buffer receivin the data
  9162. * @param key The channel key "diffuse", "specular"... used in the shader
  9163. */
  9164. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9165. /**
  9166. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9167. * @param mesh defines the current mesh
  9168. * @param scene defines the current scene
  9169. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9170. * @param pointsCloud defines if point cloud rendering has to be turned on
  9171. * @param fogEnabled defines if fog has to be turned on
  9172. * @param alphaTest defines if alpha testing has to be turned on
  9173. * @param defines defines the current list of defines
  9174. */
  9175. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9176. /**
  9177. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9178. * @param scene defines the current scene
  9179. * @param engine defines the current engine
  9180. * @param defines specifies the list of active defines
  9181. * @param useInstances defines if instances have to be turned on
  9182. * @param useClipPlane defines if clip plane have to be turned on
  9183. */
  9184. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9185. /**
  9186. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9187. * @param mesh The mesh containing the geometry data we will draw
  9188. * @param defines The defines to update
  9189. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9190. * @param useBones Precise whether bones should be used or not (override mesh info)
  9191. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9192. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9193. * @returns false if defines are considered not dirty and have not been checked
  9194. */
  9195. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9196. /**
  9197. * Prepares the defines related to the light information passed in parameter
  9198. * @param scene The scene we are intending to draw
  9199. * @param mesh The mesh the effect is compiling for
  9200. * @param defines The defines to update
  9201. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9202. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9203. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9204. * @returns true if normals will be required for the rest of the effect
  9205. */
  9206. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9207. /**
  9208. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9209. * that won t be acctive due to defines being turned off.
  9210. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9211. * @param samplersList The samplers list
  9212. * @param defines The defines helping in the list generation
  9213. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9214. */
  9215. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9216. /**
  9217. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9218. * @param defines The defines to update while falling back
  9219. * @param fallbacks The authorized effect fallbacks
  9220. * @param maxSimultaneousLights The maximum number of lights allowed
  9221. * @param rank the current rank of the Effect
  9222. * @returns The newly affected rank
  9223. */
  9224. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9225. /**
  9226. * Prepares the list of attributes required for morph targets according to the effect defines.
  9227. * @param attribs The current list of supported attribs
  9228. * @param mesh The mesh to prepare the morph targets attributes for
  9229. * @param defines The current Defines of the effect
  9230. */
  9231. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9232. /**
  9233. * Prepares the list of attributes required for bones according to the effect defines.
  9234. * @param attribs The current list of supported attribs
  9235. * @param mesh The mesh to prepare the bones attributes for
  9236. * @param defines The current Defines of the effect
  9237. * @param fallbacks The current efffect fallback strategy
  9238. */
  9239. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9240. /**
  9241. * Prepares the list of attributes required for instances according to the effect defines.
  9242. * @param attribs The current list of supported attribs
  9243. * @param defines The current Defines of the effect
  9244. */
  9245. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9246. /**
  9247. * Binds the light shadow information to the effect for the given mesh.
  9248. * @param light The light containing the generator
  9249. * @param scene The scene the lights belongs to
  9250. * @param mesh The mesh we are binding the information to render
  9251. * @param lightIndex The light index in the effect used to render the mesh
  9252. * @param effect The effect we are binding the data to
  9253. */
  9254. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9255. /**
  9256. * Binds the light information to the effect.
  9257. * @param light The light containing the generator
  9258. * @param effect The effect we are binding the data to
  9259. * @param lightIndex The light index in the effect used to render
  9260. */
  9261. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9262. /**
  9263. * Binds the lights information from the scene to the effect for the given mesh.
  9264. * @param scene The scene the lights belongs to
  9265. * @param mesh The mesh we are binding the information to render
  9266. * @param effect The effect we are binding the data to
  9267. * @param defines The generated defines for the effect
  9268. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9269. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9270. */
  9271. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9272. private static _tempFogColor;
  9273. /**
  9274. * Binds the fog information from the scene to the effect for the given mesh.
  9275. * @param scene The scene the lights belongs to
  9276. * @param mesh The mesh we are binding the information to render
  9277. * @param effect The effect we are binding the data to
  9278. * @param linearSpace Defines if the fog effect is applied in linear space
  9279. */
  9280. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9281. /**
  9282. * Binds the bones information from the mesh to the effect.
  9283. * @param mesh The mesh we are binding the information to render
  9284. * @param effect The effect we are binding the data to
  9285. */
  9286. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9287. /**
  9288. * Binds the morph targets information from the mesh to the effect.
  9289. * @param abstractMesh The mesh we are binding the information to render
  9290. * @param effect The effect we are binding the data to
  9291. */
  9292. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9293. /**
  9294. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9295. * @param defines The generated defines used in the effect
  9296. * @param effect The effect we are binding the data to
  9297. * @param scene The scene we are willing to render with logarithmic scale for
  9298. */
  9299. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9300. /**
  9301. * Binds the clip plane information from the scene to the effect.
  9302. * @param scene The scene the clip plane information are extracted from
  9303. * @param effect The effect we are binding the data to
  9304. */
  9305. static BindClipPlane(effect: Effect, scene: Scene): void;
  9306. }
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var kernelBlurVaryingDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var kernelBlurFragment: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var kernelBlurFragment2: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var kernelBlurPixelShader: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var kernelBlurVertex: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var kernelBlurVertexShader: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /**
  9352. * The Blur Post Process which blurs an image based on a kernel and direction.
  9353. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9354. */
  9355. export class BlurPostProcess extends PostProcess {
  9356. /** The direction in which to blur the image. */
  9357. direction: Vector2;
  9358. private blockCompilation;
  9359. protected _kernel: number;
  9360. protected _idealKernel: number;
  9361. protected _packedFloat: boolean;
  9362. private _staticDefines;
  9363. /**
  9364. * Sets the length in pixels of the blur sample region
  9365. */
  9366. /**
  9367. * Gets the length in pixels of the blur sample region
  9368. */
  9369. kernel: number;
  9370. /**
  9371. * Sets wether or not the blur needs to unpack/repack floats
  9372. */
  9373. /**
  9374. * Gets wether or not the blur is unpacking/repacking floats
  9375. */
  9376. packedFloat: boolean;
  9377. /**
  9378. * Creates a new instance BlurPostProcess
  9379. * @param name The name of the effect.
  9380. * @param direction The direction in which to blur the image.
  9381. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9383. * @param camera The camera to apply the render pass to.
  9384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9385. * @param engine The engine which the post process will be applied. (default: current engine)
  9386. * @param reusable If the post process can be reused on the same frame. (default: false)
  9387. * @param textureType Type of textures used when performing the post process. (default: 0)
  9388. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9389. */
  9390. constructor(name: string,
  9391. /** The direction in which to blur the image. */
  9392. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9393. /**
  9394. * Updates the effect with the current post process compile time values and recompiles the shader.
  9395. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9396. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9397. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9398. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9399. * @param onCompiled Called when the shader has been compiled.
  9400. * @param onError Called if there is an error when compiling a shader.
  9401. */
  9402. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9403. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9404. /**
  9405. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9406. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9407. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9408. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9409. * The gaps between physical kernels are compensated for in the weighting of the samples
  9410. * @param idealKernel Ideal blur kernel.
  9411. * @return Nearest best kernel.
  9412. */
  9413. protected _nearestBestKernel(idealKernel: number): number;
  9414. /**
  9415. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9416. * @param x The point on the Gaussian distribution to sample.
  9417. * @return the value of the Gaussian function at x.
  9418. */
  9419. protected _gaussianWeight(x: number): number;
  9420. /**
  9421. * Generates a string that can be used as a floating point number in GLSL.
  9422. * @param x Value to print.
  9423. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9424. * @return GLSL float string.
  9425. */
  9426. protected _glslFloat(x: number, decimalFigures?: number): string;
  9427. }
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var shadowMapPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var bonesDeclaration: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var morphTargetsVertexGlobalDeclaration: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /** @hidden */
  9452. export var morphTargetsVertexDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module BABYLON {
  9458. /** @hidden */
  9459. export var instancesDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module BABYLON {
  9465. /** @hidden */
  9466. export var helperFunctions: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module BABYLON {
  9472. /** @hidden */
  9473. export var morphTargetsVertex: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module BABYLON {
  9479. /** @hidden */
  9480. export var instancesVertex: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module BABYLON {
  9486. /** @hidden */
  9487. export var bonesVertex: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module BABYLON {
  9493. /** @hidden */
  9494. export var shadowMapVertexShader: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module BABYLON {
  9500. /** @hidden */
  9501. export var depthBoxBlurPixelShader: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module BABYLON {
  9507. /**
  9508. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9509. */
  9510. export interface ICustomShaderOptions {
  9511. /**
  9512. * Gets or sets the custom shader name to use
  9513. */
  9514. shaderName: string;
  9515. /**
  9516. * The list of attribute names used in the shader
  9517. */
  9518. attributes?: string[];
  9519. /**
  9520. * The list of unifrom names used in the shader
  9521. */
  9522. uniforms?: string[];
  9523. /**
  9524. * The list of sampler names used in the shader
  9525. */
  9526. samplers?: string[];
  9527. /**
  9528. * The list of defines used in the shader
  9529. */
  9530. defines?: string[];
  9531. }
  9532. /**
  9533. * Interface to implement to create a shadow generator compatible with BJS.
  9534. */
  9535. export interface IShadowGenerator {
  9536. /**
  9537. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9538. * @returns The render target texture if present otherwise, null
  9539. */
  9540. getShadowMap(): Nullable<RenderTargetTexture>;
  9541. /**
  9542. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9543. * @returns The render target texture if the shadow map is present otherwise, null
  9544. */
  9545. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9546. /**
  9547. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9548. * @param subMesh The submesh we want to render in the shadow map
  9549. * @param useInstances Defines wether will draw in the map using instances
  9550. * @returns true if ready otherwise, false
  9551. */
  9552. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9553. /**
  9554. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9555. * @param defines Defines of the material we want to update
  9556. * @param lightIndex Index of the light in the enabled light list of the material
  9557. */
  9558. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9559. /**
  9560. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9561. * defined in the generator but impacting the effect).
  9562. * It implies the unifroms available on the materials are the standard BJS ones.
  9563. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9564. * @param effect The effect we are binfing the information for
  9565. */
  9566. bindShadowLight(lightIndex: string, effect: Effect): void;
  9567. /**
  9568. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9569. * (eq to shadow prjection matrix * light transform matrix)
  9570. * @returns The transform matrix used to create the shadow map
  9571. */
  9572. getTransformMatrix(): Matrix;
  9573. /**
  9574. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9575. * Cube and 2D textures for instance.
  9576. */
  9577. recreateShadowMap(): void;
  9578. /**
  9579. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9580. * @param onCompiled Callback triggered at the and of the effects compilation
  9581. * @param options Sets of optional options forcing the compilation with different modes
  9582. */
  9583. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9584. useInstances: boolean;
  9585. }>): void;
  9586. /**
  9587. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9588. * @param options Sets of optional options forcing the compilation with different modes
  9589. * @returns A promise that resolves when the compilation completes
  9590. */
  9591. forceCompilationAsync(options?: Partial<{
  9592. useInstances: boolean;
  9593. }>): Promise<void>;
  9594. /**
  9595. * Serializes the shadow generator setup to a json object.
  9596. * @returns The serialized JSON object
  9597. */
  9598. serialize(): any;
  9599. /**
  9600. * Disposes the Shadow map and related Textures and effects.
  9601. */
  9602. dispose(): void;
  9603. }
  9604. /**
  9605. * Default implementation IShadowGenerator.
  9606. * This is the main object responsible of generating shadows in the framework.
  9607. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9608. */
  9609. export class ShadowGenerator implements IShadowGenerator {
  9610. /**
  9611. * Shadow generator mode None: no filtering applied.
  9612. */
  9613. static readonly FILTER_NONE: number;
  9614. /**
  9615. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9616. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9617. */
  9618. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9619. /**
  9620. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9621. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9622. */
  9623. static readonly FILTER_POISSONSAMPLING: number;
  9624. /**
  9625. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9626. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9627. */
  9628. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9629. /**
  9630. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9631. * edge artifacts on steep falloff.
  9632. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9633. */
  9634. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9635. /**
  9636. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9637. * edge artifacts on steep falloff.
  9638. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9639. */
  9640. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9641. /**
  9642. * Shadow generator mode PCF: Percentage Closer Filtering
  9643. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9644. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9645. */
  9646. static readonly FILTER_PCF: number;
  9647. /**
  9648. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9649. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9650. * Contact Hardening
  9651. */
  9652. static readonly FILTER_PCSS: number;
  9653. /**
  9654. * Reserved for PCF and PCSS
  9655. * Highest Quality.
  9656. *
  9657. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9658. *
  9659. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9660. */
  9661. static readonly QUALITY_HIGH: number;
  9662. /**
  9663. * Reserved for PCF and PCSS
  9664. * Good tradeoff for quality/perf cross devices
  9665. *
  9666. * Execute PCF on a 3*3 kernel.
  9667. *
  9668. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9669. */
  9670. static readonly QUALITY_MEDIUM: number;
  9671. /**
  9672. * Reserved for PCF and PCSS
  9673. * The lowest quality but the fastest.
  9674. *
  9675. * Execute PCF on a 1*1 kernel.
  9676. *
  9677. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9678. */
  9679. static readonly QUALITY_LOW: number;
  9680. /** Gets or sets the custom shader name to use */
  9681. customShaderOptions: ICustomShaderOptions;
  9682. /**
  9683. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9684. */
  9685. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9686. /**
  9687. * Observable triggered before a mesh is rendered in the shadow map.
  9688. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9689. */
  9690. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9691. private _bias;
  9692. /**
  9693. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9694. */
  9695. /**
  9696. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9697. */
  9698. bias: number;
  9699. private _normalBias;
  9700. /**
  9701. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9702. */
  9703. /**
  9704. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9705. */
  9706. normalBias: number;
  9707. private _blurBoxOffset;
  9708. /**
  9709. * Gets the blur box offset: offset applied during the blur pass.
  9710. * Only useful if useKernelBlur = false
  9711. */
  9712. /**
  9713. * Sets the blur box offset: offset applied during the blur pass.
  9714. * Only useful if useKernelBlur = false
  9715. */
  9716. blurBoxOffset: number;
  9717. private _blurScale;
  9718. /**
  9719. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9720. * 2 means half of the size.
  9721. */
  9722. /**
  9723. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9724. * 2 means half of the size.
  9725. */
  9726. blurScale: number;
  9727. private _blurKernel;
  9728. /**
  9729. * Gets the blur kernel: kernel size of the blur pass.
  9730. * Only useful if useKernelBlur = true
  9731. */
  9732. /**
  9733. * Sets the blur kernel: kernel size of the blur pass.
  9734. * Only useful if useKernelBlur = true
  9735. */
  9736. blurKernel: number;
  9737. private _useKernelBlur;
  9738. /**
  9739. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9740. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9741. */
  9742. /**
  9743. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9744. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9745. */
  9746. useKernelBlur: boolean;
  9747. private _depthScale;
  9748. /**
  9749. * Gets the depth scale used in ESM mode.
  9750. */
  9751. /**
  9752. * Sets the depth scale used in ESM mode.
  9753. * This can override the scale stored on the light.
  9754. */
  9755. depthScale: number;
  9756. private _filter;
  9757. /**
  9758. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9759. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9760. */
  9761. /**
  9762. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9763. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9764. */
  9765. filter: number;
  9766. /**
  9767. * Gets if the current filter is set to Poisson Sampling.
  9768. */
  9769. /**
  9770. * Sets the current filter to Poisson Sampling.
  9771. */
  9772. usePoissonSampling: boolean;
  9773. /**
  9774. * Gets if the current filter is set to ESM.
  9775. */
  9776. /**
  9777. * Sets the current filter is to ESM.
  9778. */
  9779. useExponentialShadowMap: boolean;
  9780. /**
  9781. * Gets if the current filter is set to filtered ESM.
  9782. */
  9783. /**
  9784. * Gets if the current filter is set to filtered ESM.
  9785. */
  9786. useBlurExponentialShadowMap: boolean;
  9787. /**
  9788. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9789. * exponential to prevent steep falloff artifacts).
  9790. */
  9791. /**
  9792. * Sets the current filter to "close ESM" (using the inverse of the
  9793. * exponential to prevent steep falloff artifacts).
  9794. */
  9795. useCloseExponentialShadowMap: boolean;
  9796. /**
  9797. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9798. * exponential to prevent steep falloff artifacts).
  9799. */
  9800. /**
  9801. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9802. * exponential to prevent steep falloff artifacts).
  9803. */
  9804. useBlurCloseExponentialShadowMap: boolean;
  9805. /**
  9806. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9807. */
  9808. /**
  9809. * Sets the current filter to "PCF" (percentage closer filtering).
  9810. */
  9811. usePercentageCloserFiltering: boolean;
  9812. private _filteringQuality;
  9813. /**
  9814. * Gets the PCF or PCSS Quality.
  9815. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9816. */
  9817. /**
  9818. * Sets the PCF or PCSS Quality.
  9819. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9820. */
  9821. filteringQuality: number;
  9822. /**
  9823. * Gets if the current filter is set to "PCSS" (contact hardening).
  9824. */
  9825. /**
  9826. * Sets the current filter to "PCSS" (contact hardening).
  9827. */
  9828. useContactHardeningShadow: boolean;
  9829. private _contactHardeningLightSizeUVRatio;
  9830. /**
  9831. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9832. * Using a ratio helps keeping shape stability independently of the map size.
  9833. *
  9834. * It does not account for the light projection as it was having too much
  9835. * instability during the light setup or during light position changes.
  9836. *
  9837. * Only valid if useContactHardeningShadow is true.
  9838. */
  9839. /**
  9840. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9841. * Using a ratio helps keeping shape stability independently of the map size.
  9842. *
  9843. * It does not account for the light projection as it was having too much
  9844. * instability during the light setup or during light position changes.
  9845. *
  9846. * Only valid if useContactHardeningShadow is true.
  9847. */
  9848. contactHardeningLightSizeUVRatio: number;
  9849. private _darkness;
  9850. /**
  9851. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9852. * 0 means strongest and 1 would means no shadow.
  9853. * @returns the darkness.
  9854. */
  9855. getDarkness(): number;
  9856. /**
  9857. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9858. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9859. * @returns the shadow generator allowing fluent coding.
  9860. */
  9861. setDarkness(darkness: number): ShadowGenerator;
  9862. private _transparencyShadow;
  9863. /**
  9864. * Sets the ability to have transparent shadow (boolean).
  9865. * @param transparent True if transparent else False
  9866. * @returns the shadow generator allowing fluent coding
  9867. */
  9868. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9869. private _shadowMap;
  9870. private _shadowMap2;
  9871. /**
  9872. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9873. * @returns The render target texture if present otherwise, null
  9874. */
  9875. getShadowMap(): Nullable<RenderTargetTexture>;
  9876. /**
  9877. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9878. * @returns The render target texture if the shadow map is present otherwise, null
  9879. */
  9880. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9881. /**
  9882. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9883. * @param mesh Mesh to add
  9884. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9885. * @returns the Shadow Generator itself
  9886. */
  9887. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9888. /**
  9889. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9890. * @param mesh Mesh to remove
  9891. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9892. * @returns the Shadow Generator itself
  9893. */
  9894. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9895. /**
  9896. * Controls the extent to which the shadows fade out at the edge of the frustum
  9897. * Used only by directionals and spots
  9898. */
  9899. frustumEdgeFalloff: number;
  9900. private _light;
  9901. /**
  9902. * Returns the associated light object.
  9903. * @returns the light generating the shadow
  9904. */
  9905. getLight(): IShadowLight;
  9906. /**
  9907. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9908. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9909. * It might on the other hand introduce peter panning.
  9910. */
  9911. forceBackFacesOnly: boolean;
  9912. private _scene;
  9913. private _lightDirection;
  9914. private _effect;
  9915. private _viewMatrix;
  9916. private _projectionMatrix;
  9917. private _transformMatrix;
  9918. private _cachedPosition;
  9919. private _cachedDirection;
  9920. private _cachedDefines;
  9921. private _currentRenderID;
  9922. private _boxBlurPostprocess;
  9923. private _kernelBlurXPostprocess;
  9924. private _kernelBlurYPostprocess;
  9925. private _blurPostProcesses;
  9926. private _mapSize;
  9927. private _currentFaceIndex;
  9928. private _currentFaceIndexCache;
  9929. private _textureType;
  9930. private _defaultTextureMatrix;
  9931. /** @hidden */
  9932. static _SceneComponentInitialization: (scene: Scene) => void;
  9933. /**
  9934. * Creates a ShadowGenerator object.
  9935. * A ShadowGenerator is the required tool to use the shadows.
  9936. * Each light casting shadows needs to use its own ShadowGenerator.
  9937. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9938. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9939. * @param light The light object generating the shadows.
  9940. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9941. */
  9942. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9943. private _initializeGenerator;
  9944. private _initializeShadowMap;
  9945. private _initializeBlurRTTAndPostProcesses;
  9946. private _renderForShadowMap;
  9947. private _renderSubMeshForShadowMap;
  9948. private _applyFilterValues;
  9949. /**
  9950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9951. * @param onCompiled Callback triggered at the and of the effects compilation
  9952. * @param options Sets of optional options forcing the compilation with different modes
  9953. */
  9954. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9955. useInstances: boolean;
  9956. }>): void;
  9957. /**
  9958. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9959. * @param options Sets of optional options forcing the compilation with different modes
  9960. * @returns A promise that resolves when the compilation completes
  9961. */
  9962. forceCompilationAsync(options?: Partial<{
  9963. useInstances: boolean;
  9964. }>): Promise<void>;
  9965. /**
  9966. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9967. * @param subMesh The submesh we want to render in the shadow map
  9968. * @param useInstances Defines wether will draw in the map using instances
  9969. * @returns true if ready otherwise, false
  9970. */
  9971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9972. /**
  9973. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9974. * @param defines Defines of the material we want to update
  9975. * @param lightIndex Index of the light in the enabled light list of the material
  9976. */
  9977. prepareDefines(defines: any, lightIndex: number): void;
  9978. /**
  9979. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9980. * defined in the generator but impacting the effect).
  9981. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9982. * @param effect The effect we are binfing the information for
  9983. */
  9984. bindShadowLight(lightIndex: string, effect: Effect): void;
  9985. /**
  9986. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9987. * (eq to shadow prjection matrix * light transform matrix)
  9988. * @returns The transform matrix used to create the shadow map
  9989. */
  9990. getTransformMatrix(): Matrix;
  9991. /**
  9992. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9993. * Cube and 2D textures for instance.
  9994. */
  9995. recreateShadowMap(): void;
  9996. private _disposeBlurPostProcesses;
  9997. private _disposeRTTandPostProcesses;
  9998. /**
  9999. * Disposes the ShadowGenerator.
  10000. * Returns nothing.
  10001. */
  10002. dispose(): void;
  10003. /**
  10004. * Serializes the shadow generator setup to a json object.
  10005. * @returns The serialized JSON object
  10006. */
  10007. serialize(): any;
  10008. /**
  10009. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10010. * @param parsedShadowGenerator The JSON object to parse
  10011. * @param scene The scene to create the shadow map for
  10012. * @returns The parsed shadow generator
  10013. */
  10014. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10015. }
  10016. }
  10017. declare module BABYLON {
  10018. /**
  10019. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10020. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10021. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10022. */
  10023. export abstract class Light extends Node {
  10024. /**
  10025. * Falloff Default: light is falling off following the material specification:
  10026. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10027. */
  10028. static readonly FALLOFF_DEFAULT: number;
  10029. /**
  10030. * Falloff Physical: light is falling off following the inverse squared distance law.
  10031. */
  10032. static readonly FALLOFF_PHYSICAL: number;
  10033. /**
  10034. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10035. * to enhance interoperability with other engines.
  10036. */
  10037. static readonly FALLOFF_GLTF: number;
  10038. /**
  10039. * Falloff Standard: light is falling off like in the standard material
  10040. * to enhance interoperability with other materials.
  10041. */
  10042. static readonly FALLOFF_STANDARD: number;
  10043. /**
  10044. * If every light affecting the material is in this lightmapMode,
  10045. * material.lightmapTexture adds or multiplies
  10046. * (depends on material.useLightmapAsShadowmap)
  10047. * after every other light calculations.
  10048. */
  10049. static readonly LIGHTMAP_DEFAULT: number;
  10050. /**
  10051. * material.lightmapTexture as only diffuse lighting from this light
  10052. * adds only specular lighting from this light
  10053. * adds dynamic shadows
  10054. */
  10055. static readonly LIGHTMAP_SPECULAR: number;
  10056. /**
  10057. * material.lightmapTexture as only lighting
  10058. * no light calculation from this light
  10059. * only adds dynamic shadows from this light
  10060. */
  10061. static readonly LIGHTMAP_SHADOWSONLY: number;
  10062. /**
  10063. * Each light type uses the default quantity according to its type:
  10064. * point/spot lights use luminous intensity
  10065. * directional lights use illuminance
  10066. */
  10067. static readonly INTENSITYMODE_AUTOMATIC: number;
  10068. /**
  10069. * lumen (lm)
  10070. */
  10071. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10072. /**
  10073. * candela (lm/sr)
  10074. */
  10075. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10076. /**
  10077. * lux (lm/m^2)
  10078. */
  10079. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10080. /**
  10081. * nit (cd/m^2)
  10082. */
  10083. static readonly INTENSITYMODE_LUMINANCE: number;
  10084. /**
  10085. * Light type const id of the point light.
  10086. */
  10087. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10088. /**
  10089. * Light type const id of the directional light.
  10090. */
  10091. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10092. /**
  10093. * Light type const id of the spot light.
  10094. */
  10095. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10096. /**
  10097. * Light type const id of the hemispheric light.
  10098. */
  10099. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10100. /**
  10101. * Diffuse gives the basic color to an object.
  10102. */
  10103. diffuse: Color3;
  10104. /**
  10105. * Specular produces a highlight color on an object.
  10106. * Note: This is note affecting PBR materials.
  10107. */
  10108. specular: Color3;
  10109. /**
  10110. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10111. * falling off base on range or angle.
  10112. * This can be set to any values in Light.FALLOFF_x.
  10113. *
  10114. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10115. * other types of materials.
  10116. */
  10117. falloffType: number;
  10118. /**
  10119. * Strength of the light.
  10120. * Note: By default it is define in the framework own unit.
  10121. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10122. */
  10123. intensity: number;
  10124. private _range;
  10125. protected _inverseSquaredRange: number;
  10126. /**
  10127. * Defines how far from the source the light is impacting in scene units.
  10128. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10129. */
  10130. /**
  10131. * Defines how far from the source the light is impacting in scene units.
  10132. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10133. */
  10134. range: number;
  10135. /**
  10136. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10137. * of light.
  10138. */
  10139. private _photometricScale;
  10140. private _intensityMode;
  10141. /**
  10142. * Gets the photometric scale used to interpret the intensity.
  10143. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10144. */
  10145. /**
  10146. * Sets the photometric scale used to interpret the intensity.
  10147. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10148. */
  10149. intensityMode: number;
  10150. private _radius;
  10151. /**
  10152. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10153. */
  10154. /**
  10155. * sets the light radius used by PBR Materials to simulate soft area lights.
  10156. */
  10157. radius: number;
  10158. private _renderPriority;
  10159. /**
  10160. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10161. * exceeding the number allowed of the materials.
  10162. */
  10163. renderPriority: number;
  10164. private _shadowEnabled;
  10165. /**
  10166. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10167. * the current shadow generator.
  10168. */
  10169. /**
  10170. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10171. * the current shadow generator.
  10172. */
  10173. shadowEnabled: boolean;
  10174. private _includedOnlyMeshes;
  10175. /**
  10176. * Gets the only meshes impacted by this light.
  10177. */
  10178. /**
  10179. * Sets the only meshes impacted by this light.
  10180. */
  10181. includedOnlyMeshes: AbstractMesh[];
  10182. private _excludedMeshes;
  10183. /**
  10184. * Gets the meshes not impacted by this light.
  10185. */
  10186. /**
  10187. * Sets the meshes not impacted by this light.
  10188. */
  10189. excludedMeshes: AbstractMesh[];
  10190. private _excludeWithLayerMask;
  10191. /**
  10192. * Gets the layer id use to find what meshes are not impacted by the light.
  10193. * Inactive if 0
  10194. */
  10195. /**
  10196. * Sets the layer id use to find what meshes are not impacted by the light.
  10197. * Inactive if 0
  10198. */
  10199. excludeWithLayerMask: number;
  10200. private _includeOnlyWithLayerMask;
  10201. /**
  10202. * Gets the layer id use to find what meshes are impacted by the light.
  10203. * Inactive if 0
  10204. */
  10205. /**
  10206. * Sets the layer id use to find what meshes are impacted by the light.
  10207. * Inactive if 0
  10208. */
  10209. includeOnlyWithLayerMask: number;
  10210. private _lightmapMode;
  10211. /**
  10212. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10213. */
  10214. /**
  10215. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10216. */
  10217. lightmapMode: number;
  10218. /**
  10219. * Shadow generator associted to the light.
  10220. * @hidden Internal use only.
  10221. */
  10222. _shadowGenerator: Nullable<IShadowGenerator>;
  10223. /**
  10224. * @hidden Internal use only.
  10225. */
  10226. _excludedMeshesIds: string[];
  10227. /**
  10228. * @hidden Internal use only.
  10229. */
  10230. _includedOnlyMeshesIds: string[];
  10231. /**
  10232. * The current light unifom buffer.
  10233. * @hidden Internal use only.
  10234. */
  10235. _uniformBuffer: UniformBuffer;
  10236. /**
  10237. * Creates a Light object in the scene.
  10238. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10239. * @param name The firendly name of the light
  10240. * @param scene The scene the light belongs too
  10241. */
  10242. constructor(name: string, scene: Scene);
  10243. protected abstract _buildUniformLayout(): void;
  10244. /**
  10245. * Sets the passed Effect "effect" with the Light information.
  10246. * @param effect The effect to update
  10247. * @param lightIndex The index of the light in the effect to update
  10248. * @returns The light
  10249. */
  10250. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10251. /**
  10252. * Returns the string "Light".
  10253. * @returns the class name
  10254. */
  10255. getClassName(): string;
  10256. /** @hidden */
  10257. readonly _isLight: boolean;
  10258. /**
  10259. * Converts the light information to a readable string for debug purpose.
  10260. * @param fullDetails Supports for multiple levels of logging within scene loading
  10261. * @returns the human readable light info
  10262. */
  10263. toString(fullDetails?: boolean): string;
  10264. /** @hidden */
  10265. protected _syncParentEnabledState(): void;
  10266. /**
  10267. * Set the enabled state of this node.
  10268. * @param value - the new enabled state
  10269. */
  10270. setEnabled(value: boolean): void;
  10271. /**
  10272. * Returns the Light associated shadow generator if any.
  10273. * @return the associated shadow generator.
  10274. */
  10275. getShadowGenerator(): Nullable<IShadowGenerator>;
  10276. /**
  10277. * Returns a Vector3, the absolute light position in the World.
  10278. * @returns the world space position of the light
  10279. */
  10280. getAbsolutePosition(): Vector3;
  10281. /**
  10282. * Specifies if the light will affect the passed mesh.
  10283. * @param mesh The mesh to test against the light
  10284. * @return true the mesh is affected otherwise, false.
  10285. */
  10286. canAffectMesh(mesh: AbstractMesh): boolean;
  10287. /**
  10288. * Sort function to order lights for rendering.
  10289. * @param a First Light object to compare to second.
  10290. * @param b Second Light object to compare first.
  10291. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10292. */
  10293. static CompareLightsPriority(a: Light, b: Light): number;
  10294. /**
  10295. * Releases resources associated with this node.
  10296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10298. */
  10299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10300. /**
  10301. * Returns the light type ID (integer).
  10302. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10303. */
  10304. getTypeID(): number;
  10305. /**
  10306. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10307. * @returns the scaled intensity in intensity mode unit
  10308. */
  10309. getScaledIntensity(): number;
  10310. /**
  10311. * Returns a new Light object, named "name", from the current one.
  10312. * @param name The name of the cloned light
  10313. * @returns the new created light
  10314. */
  10315. clone(name: string): Nullable<Light>;
  10316. /**
  10317. * Serializes the current light into a Serialization object.
  10318. * @returns the serialized object.
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10323. * This new light is named "name" and added to the passed scene.
  10324. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10325. * @param name The friendly name of the light
  10326. * @param scene The scene the new light will belong to
  10327. * @returns the constructor function
  10328. */
  10329. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10330. /**
  10331. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10332. * @param parsedLight The JSON representation of the light
  10333. * @param scene The scene to create the parsed light in
  10334. * @returns the created light after parsing
  10335. */
  10336. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10337. private _hookArrayForExcluded;
  10338. private _hookArrayForIncludedOnly;
  10339. private _resyncMeshes;
  10340. /**
  10341. * Forces the meshes to update their light related information in their rendering used effects
  10342. * @hidden Internal Use Only
  10343. */
  10344. _markMeshesAsLightDirty(): void;
  10345. /**
  10346. * Recomputes the cached photometric scale if needed.
  10347. */
  10348. private _computePhotometricScale;
  10349. /**
  10350. * Returns the Photometric Scale according to the light type and intensity mode.
  10351. */
  10352. private _getPhotometricScale;
  10353. /**
  10354. * Reorder the light in the scene according to their defined priority.
  10355. * @hidden Internal Use Only
  10356. */
  10357. _reorderLightsInScene(): void;
  10358. /**
  10359. * Prepares the list of defines specific to the light type.
  10360. * @param defines the list of defines
  10361. * @param lightIndex defines the index of the light for the effect
  10362. */
  10363. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10364. }
  10365. }
  10366. declare module BABYLON {
  10367. /**
  10368. * Interface used to define Action
  10369. */
  10370. export interface IAction {
  10371. /**
  10372. * Trigger for the action
  10373. */
  10374. trigger: number;
  10375. /** Options of the trigger */
  10376. triggerOptions: any;
  10377. /**
  10378. * Gets the trigger parameters
  10379. * @returns the trigger parameters
  10380. */
  10381. getTriggerParameter(): any;
  10382. /**
  10383. * Internal only - executes current action event
  10384. * @hidden
  10385. */
  10386. _executeCurrent(evt?: ActionEvent): void;
  10387. /**
  10388. * Serialize placeholder for child classes
  10389. * @param parent of child
  10390. * @returns the serialized object
  10391. */
  10392. serialize(parent: any): any;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. _prepare(): void;
  10398. /**
  10399. * Internal only - manager for action
  10400. * @hidden
  10401. */
  10402. _actionManager: AbstractActionManager;
  10403. }
  10404. /**
  10405. * The action to be carried out following a trigger
  10406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10407. */
  10408. export class Action implements IAction {
  10409. /** the trigger, with or without parameters, for the action */
  10410. triggerOptions: any;
  10411. /**
  10412. * Trigger for the action
  10413. */
  10414. trigger: number;
  10415. /**
  10416. * Internal only - manager for action
  10417. * @hidden
  10418. */
  10419. _actionManager: ActionManager;
  10420. private _nextActiveAction;
  10421. private _child;
  10422. private _condition?;
  10423. private _triggerParameter;
  10424. /**
  10425. * An event triggered prior to action being executed.
  10426. */
  10427. onBeforeExecuteObservable: Observable<Action>;
  10428. /**
  10429. * Creates a new Action
  10430. * @param triggerOptions the trigger, with or without parameters, for the action
  10431. * @param condition an optional determinant of action
  10432. */
  10433. constructor(
  10434. /** the trigger, with or without parameters, for the action */
  10435. triggerOptions: any, condition?: Condition);
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. _prepare(): void;
  10441. /**
  10442. * Gets the trigger parameters
  10443. * @returns the trigger parameters
  10444. */
  10445. getTriggerParameter(): any;
  10446. /**
  10447. * Internal only - executes current action event
  10448. * @hidden
  10449. */
  10450. _executeCurrent(evt?: ActionEvent): void;
  10451. /**
  10452. * Execute placeholder for child classes
  10453. * @param evt optional action event
  10454. */
  10455. execute(evt?: ActionEvent): void;
  10456. /**
  10457. * Skips to next active action
  10458. */
  10459. skipToNextActiveAction(): void;
  10460. /**
  10461. * Adds action to chain of actions, may be a DoNothingAction
  10462. * @param action defines the next action to execute
  10463. * @returns The action passed in
  10464. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10465. */
  10466. then(action: Action): Action;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. _getProperty(propertyPath: string): string;
  10472. /**
  10473. * Internal only
  10474. * @hidden
  10475. */
  10476. _getEffectiveTarget(target: any, propertyPath: string): any;
  10477. /**
  10478. * Serialize placeholder for child classes
  10479. * @param parent of child
  10480. * @returns the serialized object
  10481. */
  10482. serialize(parent: any): any;
  10483. /**
  10484. * Internal only called by serialize
  10485. * @hidden
  10486. */
  10487. protected _serialize(serializedAction: any, parent?: any): any;
  10488. /**
  10489. * Internal only
  10490. * @hidden
  10491. */
  10492. static _SerializeValueAsString: (value: any) => string;
  10493. /**
  10494. * Internal only
  10495. * @hidden
  10496. */
  10497. static _GetTargetProperty: (target: Scene | Node) => {
  10498. name: string;
  10499. targetType: string;
  10500. value: string;
  10501. };
  10502. }
  10503. }
  10504. declare module BABYLON {
  10505. /**
  10506. * A Condition applied to an Action
  10507. */
  10508. export class Condition {
  10509. /**
  10510. * Internal only - manager for action
  10511. * @hidden
  10512. */
  10513. _actionManager: ActionManager;
  10514. /**
  10515. * Internal only
  10516. * @hidden
  10517. */
  10518. _evaluationId: number;
  10519. /**
  10520. * Internal only
  10521. * @hidden
  10522. */
  10523. _currentResult: boolean;
  10524. /**
  10525. * Creates a new Condition
  10526. * @param actionManager the manager of the action the condition is applied to
  10527. */
  10528. constructor(actionManager: ActionManager);
  10529. /**
  10530. * Check if the current condition is valid
  10531. * @returns a boolean
  10532. */
  10533. isValid(): boolean;
  10534. /**
  10535. * Internal only
  10536. * @hidden
  10537. */
  10538. _getProperty(propertyPath: string): string;
  10539. /**
  10540. * Internal only
  10541. * @hidden
  10542. */
  10543. _getEffectiveTarget(target: any, propertyPath: string): any;
  10544. /**
  10545. * Serialize placeholder for child classes
  10546. * @returns the serialized object
  10547. */
  10548. serialize(): any;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. protected _serialize(serializedCondition: any): any;
  10554. }
  10555. /**
  10556. * Defines specific conditional operators as extensions of Condition
  10557. */
  10558. export class ValueCondition extends Condition {
  10559. /** path to specify the property of the target the conditional operator uses */
  10560. propertyPath: string;
  10561. /** the value compared by the conditional operator against the current value of the property */
  10562. value: any;
  10563. /** the conditional operator, default ValueCondition.IsEqual */
  10564. operator: number;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. private static _IsEqual;
  10570. /**
  10571. * Internal only
  10572. * @hidden
  10573. */
  10574. private static _IsDifferent;
  10575. /**
  10576. * Internal only
  10577. * @hidden
  10578. */
  10579. private static _IsGreater;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. private static _IsLesser;
  10585. /**
  10586. * returns the number for IsEqual
  10587. */
  10588. static readonly IsEqual: number;
  10589. /**
  10590. * Returns the number for IsDifferent
  10591. */
  10592. static readonly IsDifferent: number;
  10593. /**
  10594. * Returns the number for IsGreater
  10595. */
  10596. static readonly IsGreater: number;
  10597. /**
  10598. * Returns the number for IsLesser
  10599. */
  10600. static readonly IsLesser: number;
  10601. /**
  10602. * Internal only The action manager for the condition
  10603. * @hidden
  10604. */
  10605. _actionManager: ActionManager;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. private _target;
  10611. /**
  10612. * Internal only
  10613. * @hidden
  10614. */
  10615. private _effectiveTarget;
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. private _property;
  10621. /**
  10622. * Creates a new ValueCondition
  10623. * @param actionManager manager for the action the condition applies to
  10624. * @param target for the action
  10625. * @param propertyPath path to specify the property of the target the conditional operator uses
  10626. * @param value the value compared by the conditional operator against the current value of the property
  10627. * @param operator the conditional operator, default ValueCondition.IsEqual
  10628. */
  10629. constructor(actionManager: ActionManager, target: any,
  10630. /** path to specify the property of the target the conditional operator uses */
  10631. propertyPath: string,
  10632. /** the value compared by the conditional operator against the current value of the property */
  10633. value: any,
  10634. /** the conditional operator, default ValueCondition.IsEqual */
  10635. operator?: number);
  10636. /**
  10637. * Compares the given value with the property value for the specified conditional operator
  10638. * @returns the result of the comparison
  10639. */
  10640. isValid(): boolean;
  10641. /**
  10642. * Serialize the ValueCondition into a JSON compatible object
  10643. * @returns serialization object
  10644. */
  10645. serialize(): any;
  10646. /**
  10647. * Gets the name of the conditional operator for the ValueCondition
  10648. * @param operator the conditional operator
  10649. * @returns the name
  10650. */
  10651. static GetOperatorName(operator: number): string;
  10652. }
  10653. /**
  10654. * Defines a predicate condition as an extension of Condition
  10655. */
  10656. export class PredicateCondition extends Condition {
  10657. /** defines the predicate function used to validate the condition */
  10658. predicate: () => boolean;
  10659. /**
  10660. * Internal only - manager for action
  10661. * @hidden
  10662. */
  10663. _actionManager: ActionManager;
  10664. /**
  10665. * Creates a new PredicateCondition
  10666. * @param actionManager manager for the action the condition applies to
  10667. * @param predicate defines the predicate function used to validate the condition
  10668. */
  10669. constructor(actionManager: ActionManager,
  10670. /** defines the predicate function used to validate the condition */
  10671. predicate: () => boolean);
  10672. /**
  10673. * @returns the validity of the predicate condition
  10674. */
  10675. isValid(): boolean;
  10676. }
  10677. /**
  10678. * Defines a state condition as an extension of Condition
  10679. */
  10680. export class StateCondition extends Condition {
  10681. /** Value to compare with target state */
  10682. value: string;
  10683. /**
  10684. * Internal only - manager for action
  10685. * @hidden
  10686. */
  10687. _actionManager: ActionManager;
  10688. /**
  10689. * Internal only
  10690. * @hidden
  10691. */
  10692. private _target;
  10693. /**
  10694. * Creates a new StateCondition
  10695. * @param actionManager manager for the action the condition applies to
  10696. * @param target of the condition
  10697. * @param value to compare with target state
  10698. */
  10699. constructor(actionManager: ActionManager, target: any,
  10700. /** Value to compare with target state */
  10701. value: string);
  10702. /**
  10703. * Gets a boolean indicating if the current condition is met
  10704. * @returns the validity of the state
  10705. */
  10706. isValid(): boolean;
  10707. /**
  10708. * Serialize the StateCondition into a JSON compatible object
  10709. * @returns serialization object
  10710. */
  10711. serialize(): any;
  10712. }
  10713. }
  10714. declare module BABYLON {
  10715. /**
  10716. * This defines an action responsible to toggle a boolean once triggered.
  10717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10718. */
  10719. export class SwitchBooleanAction extends Action {
  10720. /**
  10721. * The path to the boolean property in the target object
  10722. */
  10723. propertyPath: string;
  10724. private _target;
  10725. private _effectiveTarget;
  10726. private _property;
  10727. /**
  10728. * Instantiate the action
  10729. * @param triggerOptions defines the trigger options
  10730. * @param target defines the object containing the boolean
  10731. * @param propertyPath defines the path to the boolean property in the target object
  10732. * @param condition defines the trigger related conditions
  10733. */
  10734. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10735. /** @hidden */
  10736. _prepare(): void;
  10737. /**
  10738. * Execute the action toggle the boolean value.
  10739. */
  10740. execute(): void;
  10741. /**
  10742. * Serializes the actions and its related information.
  10743. * @param parent defines the object to serialize in
  10744. * @returns the serialized object
  10745. */
  10746. serialize(parent: any): any;
  10747. }
  10748. /**
  10749. * This defines an action responsible to set a the state field of the target
  10750. * to a desired value once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class SetStateAction extends Action {
  10754. /**
  10755. * The value to store in the state field.
  10756. */
  10757. value: string;
  10758. private _target;
  10759. /**
  10760. * Instantiate the action
  10761. * @param triggerOptions defines the trigger options
  10762. * @param target defines the object containing the state property
  10763. * @param value defines the value to store in the state field
  10764. * @param condition defines the trigger related conditions
  10765. */
  10766. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10767. /**
  10768. * Execute the action and store the value on the target state property.
  10769. */
  10770. execute(): void;
  10771. /**
  10772. * Serializes the actions and its related information.
  10773. * @param parent defines the object to serialize in
  10774. * @returns the serialized object
  10775. */
  10776. serialize(parent: any): any;
  10777. }
  10778. /**
  10779. * This defines an action responsible to set a property of the target
  10780. * to a desired value once triggered.
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10782. */
  10783. export class SetValueAction extends Action {
  10784. /**
  10785. * The path of the property to set in the target.
  10786. */
  10787. propertyPath: string;
  10788. /**
  10789. * The value to set in the property
  10790. */
  10791. value: any;
  10792. private _target;
  10793. private _effectiveTarget;
  10794. private _property;
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param target defines the object containing the property
  10799. * @param propertyPath defines the path of the property to set in the target
  10800. * @param value defines the value to set in the property
  10801. * @param condition defines the trigger related conditions
  10802. */
  10803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10804. /** @hidden */
  10805. _prepare(): void;
  10806. /**
  10807. * Execute the action and set the targetted property to the desired value.
  10808. */
  10809. execute(): void;
  10810. /**
  10811. * Serializes the actions and its related information.
  10812. * @param parent defines the object to serialize in
  10813. * @returns the serialized object
  10814. */
  10815. serialize(parent: any): any;
  10816. }
  10817. /**
  10818. * This defines an action responsible to increment the target value
  10819. * to a desired value once triggered.
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10821. */
  10822. export class IncrementValueAction extends Action {
  10823. /**
  10824. * The path of the property to increment in the target.
  10825. */
  10826. propertyPath: string;
  10827. /**
  10828. * The value we should increment the property by.
  10829. */
  10830. value: any;
  10831. private _target;
  10832. private _effectiveTarget;
  10833. private _property;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the object containing the property
  10838. * @param propertyPath defines the path of the property to increment in the target
  10839. * @param value defines the value value we should increment the property by
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action and increment the target of the value amount.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. /**
  10857. * This defines an action responsible to start an animation once triggered.
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10859. */
  10860. export class PlayAnimationAction extends Action {
  10861. /**
  10862. * Where the animation should start (animation frame)
  10863. */
  10864. from: number;
  10865. /**
  10866. * Where the animation should stop (animation frame)
  10867. */
  10868. to: number;
  10869. /**
  10870. * Define if the animation should loop or stop after the first play.
  10871. */
  10872. loop?: boolean;
  10873. private _target;
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param target defines the target animation or animation name
  10878. * @param from defines from where the animation should start (animation frame)
  10879. * @param end defines where the animation should stop (animation frame)
  10880. * @param loop defines if the animation should loop or stop after the first play
  10881. * @param condition defines the trigger related conditions
  10882. */
  10883. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10884. /** @hidden */
  10885. _prepare(): void;
  10886. /**
  10887. * Execute the action and play the animation.
  10888. */
  10889. execute(): void;
  10890. /**
  10891. * Serializes the actions and its related information.
  10892. * @param parent defines the object to serialize in
  10893. * @returns the serialized object
  10894. */
  10895. serialize(parent: any): any;
  10896. }
  10897. /**
  10898. * This defines an action responsible to stop an animation once triggered.
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10900. */
  10901. export class StopAnimationAction extends Action {
  10902. private _target;
  10903. /**
  10904. * Instantiate the action
  10905. * @param triggerOptions defines the trigger options
  10906. * @param target defines the target animation or animation name
  10907. * @param condition defines the trigger related conditions
  10908. */
  10909. constructor(triggerOptions: any, target: any, condition?: Condition);
  10910. /** @hidden */
  10911. _prepare(): void;
  10912. /**
  10913. * Execute the action and stop the animation.
  10914. */
  10915. execute(): void;
  10916. /**
  10917. * Serializes the actions and its related information.
  10918. * @param parent defines the object to serialize in
  10919. * @returns the serialized object
  10920. */
  10921. serialize(parent: any): any;
  10922. }
  10923. /**
  10924. * This defines an action responsible that does nothing once triggered.
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10926. */
  10927. export class DoNothingAction extends Action {
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions?: any, condition?: Condition);
  10934. /**
  10935. * Execute the action and do nothing.
  10936. */
  10937. execute(): void;
  10938. /**
  10939. * Serializes the actions and its related information.
  10940. * @param parent defines the object to serialize in
  10941. * @returns the serialized object
  10942. */
  10943. serialize(parent: any): any;
  10944. }
  10945. /**
  10946. * This defines an action responsible to trigger several actions once triggered.
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10948. */
  10949. export class CombineAction extends Action {
  10950. /**
  10951. * The list of aggregated animations to run.
  10952. */
  10953. children: Action[];
  10954. /**
  10955. * Instantiate the action
  10956. * @param triggerOptions defines the trigger options
  10957. * @param children defines the list of aggregated animations to run
  10958. * @param condition defines the trigger related conditions
  10959. */
  10960. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10961. /** @hidden */
  10962. _prepare(): void;
  10963. /**
  10964. * Execute the action and executes all the aggregated actions.
  10965. */
  10966. execute(evt: ActionEvent): void;
  10967. /**
  10968. * Serializes the actions and its related information.
  10969. * @param parent defines the object to serialize in
  10970. * @returns the serialized object
  10971. */
  10972. serialize(parent: any): any;
  10973. }
  10974. /**
  10975. * This defines an action responsible to run code (external event) once triggered.
  10976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10977. */
  10978. export class ExecuteCodeAction extends Action {
  10979. /**
  10980. * The callback function to run.
  10981. */
  10982. func: (evt: ActionEvent) => void;
  10983. /**
  10984. * Instantiate the action
  10985. * @param triggerOptions defines the trigger options
  10986. * @param func defines the callback function to run
  10987. * @param condition defines the trigger related conditions
  10988. */
  10989. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10990. /**
  10991. * Execute the action and run the attached code.
  10992. */
  10993. execute(evt: ActionEvent): void;
  10994. }
  10995. /**
  10996. * This defines an action responsible to set the parent property of the target once triggered.
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10998. */
  10999. export class SetParentAction extends Action {
  11000. private _parent;
  11001. private _target;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param target defines the target containing the parent property
  11006. * @param parent defines from where the animation should start (animation frame)
  11007. * @param condition defines the trigger related conditions
  11008. */
  11009. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11010. /** @hidden */
  11011. _prepare(): void;
  11012. /**
  11013. * Execute the action and set the parent property.
  11014. */
  11015. execute(): void;
  11016. /**
  11017. * Serializes the actions and its related information.
  11018. * @param parent defines the object to serialize in
  11019. * @returns the serialized object
  11020. */
  11021. serialize(parent: any): any;
  11022. }
  11023. }
  11024. declare module BABYLON {
  11025. /**
  11026. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11027. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11029. */
  11030. export class ActionManager extends AbstractActionManager {
  11031. /**
  11032. * Nothing
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11034. */
  11035. static readonly NothingTrigger: number;
  11036. /**
  11037. * On pick
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11039. */
  11040. static readonly OnPickTrigger: number;
  11041. /**
  11042. * On left pick
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11044. */
  11045. static readonly OnLeftPickTrigger: number;
  11046. /**
  11047. * On right pick
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11049. */
  11050. static readonly OnRightPickTrigger: number;
  11051. /**
  11052. * On center pick
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly OnCenterPickTrigger: number;
  11056. /**
  11057. * On pick down
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickDownTrigger: number;
  11061. /**
  11062. * On double pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnDoublePickTrigger: number;
  11066. /**
  11067. * On pick up
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnPickUpTrigger: number;
  11071. /**
  11072. * On pick out.
  11073. * This trigger will only be raised if you also declared a OnPickDown
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11075. */
  11076. static readonly OnPickOutTrigger: number;
  11077. /**
  11078. * On long press
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11080. */
  11081. static readonly OnLongPressTrigger: number;
  11082. /**
  11083. * On pointer over
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11085. */
  11086. static readonly OnPointerOverTrigger: number;
  11087. /**
  11088. * On pointer out
  11089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11090. */
  11091. static readonly OnPointerOutTrigger: number;
  11092. /**
  11093. * On every frame
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnEveryFrameTrigger: number;
  11097. /**
  11098. * On intersection enter
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnIntersectionEnterTrigger: number;
  11102. /**
  11103. * On intersection exit
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnIntersectionExitTrigger: number;
  11107. /**
  11108. * On key down
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnKeyDownTrigger: number;
  11112. /**
  11113. * On key up
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnKeyUpTrigger: number;
  11117. private _scene;
  11118. /**
  11119. * Creates a new action manager
  11120. * @param scene defines the hosting scene
  11121. */
  11122. constructor(scene: Scene);
  11123. /**
  11124. * Releases all associated resources
  11125. */
  11126. dispose(): void;
  11127. /**
  11128. * Gets hosting scene
  11129. * @returns the hosting scene
  11130. */
  11131. getScene(): Scene;
  11132. /**
  11133. * Does this action manager handles actions of any of the given triggers
  11134. * @param triggers defines the triggers to be tested
  11135. * @return a boolean indicating whether one (or more) of the triggers is handled
  11136. */
  11137. hasSpecificTriggers(triggers: number[]): boolean;
  11138. /**
  11139. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11140. * speed.
  11141. * @param triggerA defines the trigger to be tested
  11142. * @param triggerB defines the trigger to be tested
  11143. * @return a boolean indicating whether one (or more) of the triggers is handled
  11144. */
  11145. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11146. /**
  11147. * Does this action manager handles actions of a given trigger
  11148. * @param trigger defines the trigger to be tested
  11149. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11150. * @return whether the trigger is handled
  11151. */
  11152. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11153. /**
  11154. * Does this action manager has pointer triggers
  11155. */
  11156. readonly hasPointerTriggers: boolean;
  11157. /**
  11158. * Does this action manager has pick triggers
  11159. */
  11160. readonly hasPickTriggers: boolean;
  11161. /**
  11162. * Registers an action to this action manager
  11163. * @param action defines the action to be registered
  11164. * @return the action amended (prepared) after registration
  11165. */
  11166. registerAction(action: IAction): Nullable<IAction>;
  11167. /**
  11168. * Unregisters an action to this action manager
  11169. * @param action defines the action to be unregistered
  11170. * @return a boolean indicating whether the action has been unregistered
  11171. */
  11172. unregisterAction(action: IAction): Boolean;
  11173. /**
  11174. * Process a specific trigger
  11175. * @param trigger defines the trigger to process
  11176. * @param evt defines the event details to be processed
  11177. */
  11178. processTrigger(trigger: number, evt?: IActionEvent): void;
  11179. /** @hidden */
  11180. _getEffectiveTarget(target: any, propertyPath: string): any;
  11181. /** @hidden */
  11182. _getProperty(propertyPath: string): string;
  11183. /**
  11184. * Serialize this manager to a JSON object
  11185. * @param name defines the property name to store this manager
  11186. * @returns a JSON representation of this manager
  11187. */
  11188. serialize(name: string): any;
  11189. /**
  11190. * Creates a new ActionManager from a JSON data
  11191. * @param parsedActions defines the JSON data to read from
  11192. * @param object defines the hosting mesh
  11193. * @param scene defines the hosting scene
  11194. */
  11195. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11196. /**
  11197. * Get a trigger name by index
  11198. * @param trigger defines the trigger index
  11199. * @returns a trigger name
  11200. */
  11201. static GetTriggerName(trigger: number): string;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /**
  11206. * Class representing a ray with position and direction
  11207. */
  11208. export class Ray {
  11209. /** origin point */
  11210. origin: Vector3;
  11211. /** direction */
  11212. direction: Vector3;
  11213. /** length of the ray */
  11214. length: number;
  11215. private static readonly TmpVector3;
  11216. private _tmpRay;
  11217. /**
  11218. * Creates a new ray
  11219. * @param origin origin point
  11220. * @param direction direction
  11221. * @param length length of the ray
  11222. */
  11223. constructor(
  11224. /** origin point */
  11225. origin: Vector3,
  11226. /** direction */
  11227. direction: Vector3,
  11228. /** length of the ray */
  11229. length?: number);
  11230. /**
  11231. * Checks if the ray intersects a box
  11232. * @param minimum bound of the box
  11233. * @param maximum bound of the box
  11234. * @param intersectionTreshold extra extend to be added to the box in all direction
  11235. * @returns if the box was hit
  11236. */
  11237. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11238. /**
  11239. * Checks if the ray intersects a box
  11240. * @param box the bounding box to check
  11241. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11242. * @returns if the box was hit
  11243. */
  11244. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11245. /**
  11246. * If the ray hits a sphere
  11247. * @param sphere the bounding sphere to check
  11248. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11249. * @returns true if it hits the sphere
  11250. */
  11251. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11252. /**
  11253. * If the ray hits a triange
  11254. * @param vertex0 triangle vertex
  11255. * @param vertex1 triangle vertex
  11256. * @param vertex2 triangle vertex
  11257. * @returns intersection information if hit
  11258. */
  11259. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11260. /**
  11261. * Checks if ray intersects a plane
  11262. * @param plane the plane to check
  11263. * @returns the distance away it was hit
  11264. */
  11265. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11266. /**
  11267. * Checks if ray intersects a mesh
  11268. * @param mesh the mesh to check
  11269. * @param fastCheck if only the bounding box should checked
  11270. * @returns picking info of the intersecton
  11271. */
  11272. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11273. /**
  11274. * Checks if ray intersects a mesh
  11275. * @param meshes the meshes to check
  11276. * @param fastCheck if only the bounding box should checked
  11277. * @param results array to store result in
  11278. * @returns Array of picking infos
  11279. */
  11280. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11281. private _comparePickingInfo;
  11282. private static smallnum;
  11283. private static rayl;
  11284. /**
  11285. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11286. * @param sega the first point of the segment to test the intersection against
  11287. * @param segb the second point of the segment to test the intersection against
  11288. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11289. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11290. */
  11291. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11292. /**
  11293. * Update the ray from viewport position
  11294. * @param x position
  11295. * @param y y position
  11296. * @param viewportWidth viewport width
  11297. * @param viewportHeight viewport height
  11298. * @param world world matrix
  11299. * @param view view matrix
  11300. * @param projection projection matrix
  11301. * @returns this ray updated
  11302. */
  11303. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11304. /**
  11305. * Creates a ray with origin and direction of 0,0,0
  11306. * @returns the new ray
  11307. */
  11308. static Zero(): Ray;
  11309. /**
  11310. * Creates a new ray from screen space and viewport
  11311. * @param x position
  11312. * @param y y position
  11313. * @param viewportWidth viewport width
  11314. * @param viewportHeight viewport height
  11315. * @param world world matrix
  11316. * @param view view matrix
  11317. * @param projection projection matrix
  11318. * @returns new ray
  11319. */
  11320. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11321. /**
  11322. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11323. * transformed to the given world matrix.
  11324. * @param origin The origin point
  11325. * @param end The end point
  11326. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11327. * @returns the new ray
  11328. */
  11329. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11330. /**
  11331. * Transforms a ray by a matrix
  11332. * @param ray ray to transform
  11333. * @param matrix matrix to apply
  11334. * @returns the resulting new ray
  11335. */
  11336. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11337. /**
  11338. * Transforms a ray by a matrix
  11339. * @param ray ray to transform
  11340. * @param matrix matrix to apply
  11341. * @param result ray to store result in
  11342. */
  11343. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11344. /**
  11345. * Unproject a ray from screen space to object space
  11346. * @param sourceX defines the screen space x coordinate to use
  11347. * @param sourceY defines the screen space y coordinate to use
  11348. * @param viewportWidth defines the current width of the viewport
  11349. * @param viewportHeight defines the current height of the viewport
  11350. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11351. * @param view defines the view matrix to use
  11352. * @param projection defines the projection matrix to use
  11353. */
  11354. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11355. }
  11356. /**
  11357. * Type used to define predicate used to select faces when a mesh intersection is detected
  11358. */
  11359. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11360. interface Scene {
  11361. /** @hidden */
  11362. _tempPickingRay: Nullable<Ray>;
  11363. /** @hidden */
  11364. _cachedRayForTransform: Ray;
  11365. /** @hidden */
  11366. _pickWithRayInverseMatrix: Matrix;
  11367. /** @hidden */
  11368. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11369. /** @hidden */
  11370. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11371. }
  11372. }
  11373. declare module BABYLON {
  11374. /**
  11375. * Groups all the scene component constants in one place to ease maintenance.
  11376. * @hidden
  11377. */
  11378. export class SceneComponentConstants {
  11379. static readonly NAME_EFFECTLAYER: string;
  11380. static readonly NAME_LAYER: string;
  11381. static readonly NAME_LENSFLARESYSTEM: string;
  11382. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11383. static readonly NAME_PARTICLESYSTEM: string;
  11384. static readonly NAME_GAMEPAD: string;
  11385. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11386. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11387. static readonly NAME_DEPTHRENDERER: string;
  11388. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11389. static readonly NAME_SPRITE: string;
  11390. static readonly NAME_OUTLINERENDERER: string;
  11391. static readonly NAME_PROCEDURALTEXTURE: string;
  11392. static readonly NAME_SHADOWGENERATOR: string;
  11393. static readonly NAME_OCTREE: string;
  11394. static readonly NAME_PHYSICSENGINE: string;
  11395. static readonly NAME_AUDIO: string;
  11396. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11397. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11400. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11402. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11404. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11407. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11409. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11410. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11411. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11413. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11414. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11415. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11416. static readonly STEP_AFTERRENDER_AUDIO: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11420. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11421. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11422. static readonly STEP_POINTERMOVE_SPRITE: number;
  11423. static readonly STEP_POINTERDOWN_SPRITE: number;
  11424. static readonly STEP_POINTERUP_SPRITE: number;
  11425. }
  11426. /**
  11427. * This represents a scene component.
  11428. *
  11429. * This is used to decouple the dependency the scene is having on the different workloads like
  11430. * layers, post processes...
  11431. */
  11432. export interface ISceneComponent {
  11433. /**
  11434. * The name of the component. Each component must have a unique name.
  11435. */
  11436. name: string;
  11437. /**
  11438. * The scene the component belongs to.
  11439. */
  11440. scene: Scene;
  11441. /**
  11442. * Register the component to one instance of a scene.
  11443. */
  11444. register(): void;
  11445. /**
  11446. * Rebuilds the elements related to this component in case of
  11447. * context lost for instance.
  11448. */
  11449. rebuild(): void;
  11450. /**
  11451. * Disposes the component and the associated ressources.
  11452. */
  11453. dispose(): void;
  11454. }
  11455. /**
  11456. * This represents a SERIALIZABLE scene component.
  11457. *
  11458. * This extends Scene Component to add Serialization methods on top.
  11459. */
  11460. export interface ISceneSerializableComponent extends ISceneComponent {
  11461. /**
  11462. * Adds all the element from the container to the scene
  11463. * @param container the container holding the elements
  11464. */
  11465. addFromContainer(container: AbstractScene): void;
  11466. /**
  11467. * Removes all the elements in the container from the scene
  11468. * @param container contains the elements to remove
  11469. * @param dispose if the removed element should be disposed (default: false)
  11470. */
  11471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11472. /**
  11473. * Serializes the component data to the specified json object
  11474. * @param serializationObject The object to serialize to
  11475. */
  11476. serialize(serializationObject: any): void;
  11477. }
  11478. /**
  11479. * Strong typing of a Mesh related stage step action
  11480. */
  11481. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11482. /**
  11483. * Strong typing of a Evaluate Sub Mesh related stage step action
  11484. */
  11485. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11486. /**
  11487. * Strong typing of a Active Mesh related stage step action
  11488. */
  11489. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11490. /**
  11491. * Strong typing of a Camera related stage step action
  11492. */
  11493. export type CameraStageAction = (camera: Camera) => void;
  11494. /**
  11495. * Strong typing of a Render Target related stage step action
  11496. */
  11497. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11498. /**
  11499. * Strong typing of a RenderingGroup related stage step action
  11500. */
  11501. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11502. /**
  11503. * Strong typing of a Mesh Render related stage step action
  11504. */
  11505. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11506. /**
  11507. * Strong typing of a simple stage step action
  11508. */
  11509. export type SimpleStageAction = () => void;
  11510. /**
  11511. * Strong typing of a render target action.
  11512. */
  11513. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11514. /**
  11515. * Strong typing of a pointer move action.
  11516. */
  11517. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11518. /**
  11519. * Strong typing of a pointer up/down action.
  11520. */
  11521. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11522. /**
  11523. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11524. * @hidden
  11525. */
  11526. export class Stage<T extends Function> extends Array<{
  11527. index: number;
  11528. component: ISceneComponent;
  11529. action: T;
  11530. }> {
  11531. /**
  11532. * Hide ctor from the rest of the world.
  11533. * @param items The items to add.
  11534. */
  11535. private constructor();
  11536. /**
  11537. * Creates a new Stage.
  11538. * @returns A new instance of a Stage
  11539. */
  11540. static Create<T extends Function>(): Stage<T>;
  11541. /**
  11542. * Registers a step in an ordered way in the targeted stage.
  11543. * @param index Defines the position to register the step in
  11544. * @param component Defines the component attached to the step
  11545. * @param action Defines the action to launch during the step
  11546. */
  11547. registerStep(index: number, component: ISceneComponent, action: T): void;
  11548. /**
  11549. * Clears all the steps from the stage.
  11550. */
  11551. clear(): void;
  11552. }
  11553. }
  11554. declare module BABYLON {
  11555. interface Scene {
  11556. /** @hidden */
  11557. _pointerOverSprite: Nullable<Sprite>;
  11558. /** @hidden */
  11559. _pickedDownSprite: Nullable<Sprite>;
  11560. /** @hidden */
  11561. _tempSpritePickingRay: Nullable<Ray>;
  11562. /**
  11563. * All of the sprite managers added to this scene
  11564. * @see http://doc.babylonjs.com/babylon101/sprites
  11565. */
  11566. spriteManagers: Array<ISpriteManager>;
  11567. /**
  11568. * An event triggered when sprites rendering is about to start
  11569. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11570. */
  11571. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11572. /**
  11573. * An event triggered when sprites rendering is done
  11574. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11575. */
  11576. onAfterSpritesRenderingObservable: Observable<Scene>;
  11577. /** @hidden */
  11578. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Launch a ray to try to pick a sprite in the scene
  11580. * @param x position on screen
  11581. * @param y position on screen
  11582. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11584. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11585. * @returns a PickingInfo
  11586. */
  11587. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11588. /** Use the given ray to pick a sprite in the scene
  11589. * @param ray The ray (in world space) to use to pick meshes
  11590. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11592. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11593. * @returns a PickingInfo
  11594. */
  11595. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11596. /**
  11597. * Force the sprite under the pointer
  11598. * @param sprite defines the sprite to use
  11599. */
  11600. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11601. /**
  11602. * Gets the sprite under the pointer
  11603. * @returns a Sprite or null if no sprite is under the pointer
  11604. */
  11605. getPointerOverSprite(): Nullable<Sprite>;
  11606. }
  11607. /**
  11608. * Defines the sprite scene component responsible to manage sprites
  11609. * in a given scene.
  11610. */
  11611. export class SpriteSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /** @hidden */
  11621. private _spritePredicate;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _pickSpriteButKeepRay;
  11641. private _pointerMove;
  11642. private _pointerDown;
  11643. private _pointerUp;
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /** @hidden */
  11648. export var fogFragmentDeclaration: {
  11649. name: string;
  11650. shader: string;
  11651. };
  11652. }
  11653. declare module BABYLON {
  11654. /** @hidden */
  11655. export var fogFragment: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module BABYLON {
  11661. /** @hidden */
  11662. export var spritesPixelShader: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module BABYLON {
  11668. /** @hidden */
  11669. export var fogVertexDeclaration: {
  11670. name: string;
  11671. shader: string;
  11672. };
  11673. }
  11674. declare module BABYLON {
  11675. /** @hidden */
  11676. export var spritesVertexShader: {
  11677. name: string;
  11678. shader: string;
  11679. };
  11680. }
  11681. declare module BABYLON {
  11682. /**
  11683. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11684. */
  11685. export interface ISpriteManager extends IDisposable {
  11686. /**
  11687. * Restricts the camera to viewing objects with the same layerMask.
  11688. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11689. */
  11690. layerMask: number;
  11691. /**
  11692. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11693. */
  11694. isPickable: boolean;
  11695. /**
  11696. * Specifies the rendering group id for this mesh (0 by default)
  11697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11698. */
  11699. renderingGroupId: number;
  11700. /**
  11701. * Defines the list of sprites managed by the manager.
  11702. */
  11703. sprites: Array<Sprite>;
  11704. /**
  11705. * Tests the intersection of a sprite with a specific ray.
  11706. * @param ray The ray we are sending to test the collision
  11707. * @param camera The camera space we are sending rays in
  11708. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11709. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11710. * @returns picking info or null.
  11711. */
  11712. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11713. /**
  11714. * Renders the list of sprites on screen.
  11715. */
  11716. render(): void;
  11717. }
  11718. /**
  11719. * Class used to manage multiple sprites on the same spritesheet
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class SpriteManager implements ISpriteManager {
  11723. /** defines the manager's name */
  11724. name: string;
  11725. /** Gets the list of sprites */
  11726. sprites: Sprite[];
  11727. /** Gets or sets the rendering group id (0 by default) */
  11728. renderingGroupId: number;
  11729. /** Gets or sets camera layer mask */
  11730. layerMask: number;
  11731. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11732. fogEnabled: boolean;
  11733. /** Gets or sets a boolean indicating if the sprites are pickable */
  11734. isPickable: boolean;
  11735. /** Defines the default width of a cell in the spritesheet */
  11736. cellWidth: number;
  11737. /** Defines the default height of a cell in the spritesheet */
  11738. cellHeight: number;
  11739. /**
  11740. * An event triggered when the manager is disposed.
  11741. */
  11742. onDisposeObservable: Observable<SpriteManager>;
  11743. private _onDisposeObserver;
  11744. /**
  11745. * Callback called when the manager is disposed
  11746. */
  11747. onDispose: () => void;
  11748. private _capacity;
  11749. private _spriteTexture;
  11750. private _epsilon;
  11751. private _scene;
  11752. private _vertexData;
  11753. private _buffer;
  11754. private _vertexBuffers;
  11755. private _indexBuffer;
  11756. private _effectBase;
  11757. private _effectFog;
  11758. /**
  11759. * Gets or sets the spritesheet texture
  11760. */
  11761. texture: Texture;
  11762. /**
  11763. * Creates a new sprite manager
  11764. * @param name defines the manager's name
  11765. * @param imgUrl defines the sprite sheet url
  11766. * @param capacity defines the maximum allowed number of sprites
  11767. * @param cellSize defines the size of a sprite cell
  11768. * @param scene defines the hosting scene
  11769. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11770. * @param samplingMode defines the smapling mode to use with spritesheet
  11771. */
  11772. constructor(
  11773. /** defines the manager's name */
  11774. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11775. private _appendSpriteVertex;
  11776. /**
  11777. * Intersects the sprites with a ray
  11778. * @param ray defines the ray to intersect with
  11779. * @param camera defines the current active camera
  11780. * @param predicate defines a predicate used to select candidate sprites
  11781. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11782. * @returns null if no hit or a PickingInfo
  11783. */
  11784. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11785. /**
  11786. * Render all child sprites
  11787. */
  11788. render(): void;
  11789. /**
  11790. * Release associated resources
  11791. */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module BABYLON {
  11796. /**
  11797. * Class used to represent a sprite
  11798. * @see http://doc.babylonjs.com/babylon101/sprites
  11799. */
  11800. export class Sprite {
  11801. /** defines the name */
  11802. name: string;
  11803. /** Gets or sets the current world position */
  11804. position: Vector3;
  11805. /** Gets or sets the main color */
  11806. color: Color4;
  11807. /** Gets or sets the width */
  11808. width: number;
  11809. /** Gets or sets the height */
  11810. height: number;
  11811. /** Gets or sets rotation angle */
  11812. angle: number;
  11813. /** Gets or sets the cell index in the sprite sheet */
  11814. cellIndex: number;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module BABYLON {
  11872. /**
  11873. * Information about the result of picking within a scene
  11874. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11875. */
  11876. export class PickingInfo {
  11877. /** @hidden */
  11878. _pickingUnavailable: boolean;
  11879. /**
  11880. * If the pick collided with an object
  11881. */
  11882. hit: boolean;
  11883. /**
  11884. * Distance away where the pick collided
  11885. */
  11886. distance: number;
  11887. /**
  11888. * The location of pick collision
  11889. */
  11890. pickedPoint: Nullable<Vector3>;
  11891. /**
  11892. * The mesh corresponding the the pick collision
  11893. */
  11894. pickedMesh: Nullable<AbstractMesh>;
  11895. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11896. bu: number;
  11897. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11898. bv: number;
  11899. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11900. faceId: number;
  11901. /** Id of the the submesh that was picked */
  11902. subMeshId: number;
  11903. /** If a sprite was picked, this will be the sprite the pick collided with */
  11904. pickedSprite: Nullable<Sprite>;
  11905. /**
  11906. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11907. */
  11908. originMesh: Nullable<AbstractMesh>;
  11909. /**
  11910. * The ray that was used to perform the picking.
  11911. */
  11912. ray: Nullable<Ray>;
  11913. /**
  11914. * Gets the normal correspodning to the face the pick collided with
  11915. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11916. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11917. * @returns The normal correspodning to the face the pick collided with
  11918. */
  11919. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11920. /**
  11921. * Gets the texture coordinates of where the pick occured
  11922. * @returns the vector containing the coordnates of the texture
  11923. */
  11924. getTextureCoordinates(): Nullable<Vector2>;
  11925. }
  11926. }
  11927. declare module BABYLON {
  11928. /**
  11929. * Gather the list of pointer event types as constants.
  11930. */
  11931. export class PointerEventTypes {
  11932. /**
  11933. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11934. */
  11935. static readonly POINTERDOWN: number;
  11936. /**
  11937. * The pointerup event is fired when a pointer is no longer active.
  11938. */
  11939. static readonly POINTERUP: number;
  11940. /**
  11941. * The pointermove event is fired when a pointer changes coordinates.
  11942. */
  11943. static readonly POINTERMOVE: number;
  11944. /**
  11945. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11946. */
  11947. static readonly POINTERWHEEL: number;
  11948. /**
  11949. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11950. */
  11951. static readonly POINTERPICK: number;
  11952. /**
  11953. * The pointertap event is fired when a the object has been touched and released without drag.
  11954. */
  11955. static readonly POINTERTAP: number;
  11956. /**
  11957. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11958. */
  11959. static readonly POINTERDOUBLETAP: number;
  11960. }
  11961. /**
  11962. * Base class of pointer info types.
  11963. */
  11964. export class PointerInfoBase {
  11965. /**
  11966. * Defines the type of event (PointerEventTypes)
  11967. */
  11968. type: number;
  11969. /**
  11970. * Defines the related dom event
  11971. */
  11972. event: PointerEvent | MouseWheelEvent;
  11973. /**
  11974. * Instantiates the base class of pointers info.
  11975. * @param type Defines the type of event (PointerEventTypes)
  11976. * @param event Defines the related dom event
  11977. */
  11978. constructor(
  11979. /**
  11980. * Defines the type of event (PointerEventTypes)
  11981. */
  11982. type: number,
  11983. /**
  11984. * Defines the related dom event
  11985. */
  11986. event: PointerEvent | MouseWheelEvent);
  11987. }
  11988. /**
  11989. * This class is used to store pointer related info for the onPrePointerObservable event.
  11990. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11991. */
  11992. export class PointerInfoPre extends PointerInfoBase {
  11993. /**
  11994. * Ray from a pointer if availible (eg. 6dof controller)
  11995. */
  11996. ray: Nullable<Ray>;
  11997. /**
  11998. * Defines the local position of the pointer on the canvas.
  11999. */
  12000. localPosition: Vector2;
  12001. /**
  12002. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12003. */
  12004. skipOnPointerObservable: boolean;
  12005. /**
  12006. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12007. * @param type Defines the type of event (PointerEventTypes)
  12008. * @param event Defines the related dom event
  12009. * @param localX Defines the local x coordinates of the pointer when the event occured
  12010. * @param localY Defines the local y coordinates of the pointer when the event occured
  12011. */
  12012. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12013. }
  12014. /**
  12015. * This type contains all the data related to a pointer event in Babylon.js.
  12016. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12017. */
  12018. export class PointerInfo extends PointerInfoBase {
  12019. /**
  12020. * Defines the picking info associated to the info (if any)\
  12021. */
  12022. pickInfo: Nullable<PickingInfo>;
  12023. /**
  12024. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12025. * @param type Defines the type of event (PointerEventTypes)
  12026. * @param event Defines the related dom event
  12027. * @param pickInfo Defines the picking info associated to the info (if any)\
  12028. */
  12029. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12030. /**
  12031. * Defines the picking info associated to the info (if any)\
  12032. */
  12033. pickInfo: Nullable<PickingInfo>);
  12034. }
  12035. /**
  12036. * Data relating to a touch event on the screen.
  12037. */
  12038. export interface PointerTouch {
  12039. /**
  12040. * X coordinate of touch.
  12041. */
  12042. x: number;
  12043. /**
  12044. * Y coordinate of touch.
  12045. */
  12046. y: number;
  12047. /**
  12048. * Id of touch. Unique for each finger.
  12049. */
  12050. pointerId: number;
  12051. /**
  12052. * Event type passed from DOM.
  12053. */
  12054. type: any;
  12055. }
  12056. }
  12057. declare module BABYLON {
  12058. /**
  12059. * Manage the mouse inputs to control the movement of a free camera.
  12060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12061. */
  12062. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12063. /**
  12064. * Define if touch is enabled in the mouse input
  12065. */
  12066. touchEnabled: boolean;
  12067. /**
  12068. * Defines the camera the input is attached to.
  12069. */
  12070. camera: FreeCamera;
  12071. /**
  12072. * Defines the buttons associated with the input to handle camera move.
  12073. */
  12074. buttons: number[];
  12075. /**
  12076. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12077. */
  12078. angularSensibility: number;
  12079. private _pointerInput;
  12080. private _onMouseMove;
  12081. private _observer;
  12082. private previousPosition;
  12083. /**
  12084. * Observable for when a pointer move event occurs containing the move offset
  12085. */
  12086. onPointerMovedObservable: Observable<{
  12087. offsetX: number;
  12088. offsetY: number;
  12089. }>;
  12090. /**
  12091. * @hidden
  12092. * If the camera should be rotated automatically based on pointer movement
  12093. */
  12094. _allowCameraRotation: boolean;
  12095. /**
  12096. * Manage the mouse inputs to control the movement of a free camera.
  12097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12098. * @param touchEnabled Defines if touch is enabled or not
  12099. */
  12100. constructor(
  12101. /**
  12102. * Define if touch is enabled in the mouse input
  12103. */
  12104. touchEnabled?: boolean);
  12105. /**
  12106. * Attach the input controls to a specific dom element to get the input from.
  12107. * @param element Defines the element the controls should be listened from
  12108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12109. */
  12110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12111. /**
  12112. * Called on JS contextmenu event.
  12113. * Override this method to provide functionality.
  12114. */
  12115. protected onContextMenu(evt: PointerEvent): void;
  12116. /**
  12117. * Detach the current controls from the specified dom element.
  12118. * @param element Defines the element to stop listening the inputs from
  12119. */
  12120. detachControl(element: Nullable<HTMLElement>): void;
  12121. /**
  12122. * Gets the class name of the current intput.
  12123. * @returns the class name
  12124. */
  12125. getClassName(): string;
  12126. /**
  12127. * Get the friendly name associated with the input class.
  12128. * @returns the input friendly name
  12129. */
  12130. getSimpleName(): string;
  12131. }
  12132. }
  12133. declare module BABYLON {
  12134. /**
  12135. * Manage the touch inputs to control the movement of a free camera.
  12136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12137. */
  12138. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12139. /**
  12140. * Defines the camera the input is attached to.
  12141. */
  12142. camera: FreeCamera;
  12143. /**
  12144. * Defines the touch sensibility for rotation.
  12145. * The higher the faster.
  12146. */
  12147. touchAngularSensibility: number;
  12148. /**
  12149. * Defines the touch sensibility for move.
  12150. * The higher the faster.
  12151. */
  12152. touchMoveSensibility: number;
  12153. private _offsetX;
  12154. private _offsetY;
  12155. private _pointerPressed;
  12156. private _pointerInput;
  12157. private _observer;
  12158. private _onLostFocus;
  12159. /**
  12160. * Attach the input controls to a specific dom element to get the input from.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the specified dom element.
  12167. * @param element Defines the element to stop listening the inputs from
  12168. */
  12169. detachControl(element: Nullable<HTMLElement>): void;
  12170. /**
  12171. * Update the current camera state depending on the inputs that have been used this frame.
  12172. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12173. */
  12174. checkInputs(): void;
  12175. /**
  12176. * Gets the class name of the current intput.
  12177. * @returns the class name
  12178. */
  12179. getClassName(): string;
  12180. /**
  12181. * Get the friendly name associated with the input class.
  12182. * @returns the input friendly name
  12183. */
  12184. getSimpleName(): string;
  12185. }
  12186. }
  12187. declare module BABYLON {
  12188. /**
  12189. * Default Inputs manager for the FreeCamera.
  12190. * It groups all the default supported inputs for ease of use.
  12191. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12192. */
  12193. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12194. /**
  12195. * @hidden
  12196. */
  12197. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12198. /**
  12199. * @hidden
  12200. */
  12201. _mouseInput: Nullable<FreeCameraMouseInput>;
  12202. /**
  12203. * Instantiates a new FreeCameraInputsManager.
  12204. * @param camera Defines the camera the inputs belong to
  12205. */
  12206. constructor(camera: FreeCamera);
  12207. /**
  12208. * Add keyboard input support to the input manager.
  12209. * @returns the current input manager
  12210. */
  12211. addKeyboard(): FreeCameraInputsManager;
  12212. /**
  12213. * Add mouse input support to the input manager.
  12214. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12215. * @returns the current input manager
  12216. */
  12217. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12218. /**
  12219. * Removes the mouse input support from the manager
  12220. * @returns the current input manager
  12221. */
  12222. removeMouse(): FreeCameraInputsManager;
  12223. /**
  12224. * Add touch input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addTouch(): FreeCameraInputsManager;
  12228. }
  12229. }
  12230. declare module BABYLON {
  12231. /**
  12232. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12233. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12235. */
  12236. export class FreeCamera extends TargetCamera {
  12237. /**
  12238. * Define the collision ellipsoid of the camera.
  12239. * This is helpful to simulate a camera body like the player body around the camera
  12240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12241. */
  12242. ellipsoid: Vector3;
  12243. /**
  12244. * Define an offset for the position of the ellipsoid around the camera.
  12245. * This can be helpful to determine the center of the body near the gravity center of the body
  12246. * instead of its head.
  12247. */
  12248. ellipsoidOffset: Vector3;
  12249. /**
  12250. * Enable or disable collisions of the camera with the rest of the scene objects.
  12251. */
  12252. checkCollisions: boolean;
  12253. /**
  12254. * Enable or disable gravity on the camera.
  12255. */
  12256. applyGravity: boolean;
  12257. /**
  12258. * Define the input manager associated to the camera.
  12259. */
  12260. inputs: FreeCameraInputsManager;
  12261. /**
  12262. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12263. * Higher values reduce sensitivity.
  12264. */
  12265. /**
  12266. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12267. * Higher values reduce sensitivity.
  12268. */
  12269. angularSensibility: number;
  12270. /**
  12271. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12272. */
  12273. keysUp: number[];
  12274. /**
  12275. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12276. */
  12277. keysDown: number[];
  12278. /**
  12279. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12280. */
  12281. keysLeft: number[];
  12282. /**
  12283. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12284. */
  12285. keysRight: number[];
  12286. /**
  12287. * Event raised when the camera collide with a mesh in the scene.
  12288. */
  12289. onCollide: (collidedMesh: AbstractMesh) => void;
  12290. private _collider;
  12291. private _needMoveForGravity;
  12292. private _oldPosition;
  12293. private _diffPosition;
  12294. private _newPosition;
  12295. /** @hidden */
  12296. _localDirection: Vector3;
  12297. /** @hidden */
  12298. _transformedDirection: Vector3;
  12299. /**
  12300. * Instantiates a Free Camera.
  12301. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12302. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12304. * @param name Define the name of the camera in the scene
  12305. * @param position Define the start position of the camera in the scene
  12306. * @param scene Define the scene the camera belongs to
  12307. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12308. */
  12309. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12310. /**
  12311. * Attached controls to the current camera.
  12312. * @param element Defines the element the controls should be listened from
  12313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12314. */
  12315. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12316. /**
  12317. * Detach the current controls from the camera.
  12318. * The camera will stop reacting to inputs.
  12319. * @param element Defines the element to stop listening the inputs from
  12320. */
  12321. detachControl(element: HTMLElement): void;
  12322. private _collisionMask;
  12323. /**
  12324. * Define a collision mask to limit the list of object the camera can collide with
  12325. */
  12326. collisionMask: number;
  12327. /** @hidden */
  12328. _collideWithWorld(displacement: Vector3): void;
  12329. private _onCollisionPositionChange;
  12330. /** @hidden */
  12331. _checkInputs(): void;
  12332. /** @hidden */
  12333. _decideIfNeedsToMove(): boolean;
  12334. /** @hidden */
  12335. _updatePosition(): void;
  12336. /**
  12337. * Destroy the camera and release the current resources hold by it.
  12338. */
  12339. dispose(): void;
  12340. /**
  12341. * Gets the current object class name.
  12342. * @return the class name
  12343. */
  12344. getClassName(): string;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Represents a gamepad control stick position
  12350. */
  12351. export class StickValues {
  12352. /**
  12353. * The x component of the control stick
  12354. */
  12355. x: number;
  12356. /**
  12357. * The y component of the control stick
  12358. */
  12359. y: number;
  12360. /**
  12361. * Initializes the gamepad x and y control stick values
  12362. * @param x The x component of the gamepad control stick value
  12363. * @param y The y component of the gamepad control stick value
  12364. */
  12365. constructor(
  12366. /**
  12367. * The x component of the control stick
  12368. */
  12369. x: number,
  12370. /**
  12371. * The y component of the control stick
  12372. */
  12373. y: number);
  12374. }
  12375. /**
  12376. * An interface which manages callbacks for gamepad button changes
  12377. */
  12378. export interface GamepadButtonChanges {
  12379. /**
  12380. * Called when a gamepad has been changed
  12381. */
  12382. changed: boolean;
  12383. /**
  12384. * Called when a gamepad press event has been triggered
  12385. */
  12386. pressChanged: boolean;
  12387. /**
  12388. * Called when a touch event has been triggered
  12389. */
  12390. touchChanged: boolean;
  12391. /**
  12392. * Called when a value has changed
  12393. */
  12394. valueChanged: boolean;
  12395. }
  12396. /**
  12397. * Represents a gamepad
  12398. */
  12399. export class Gamepad {
  12400. /**
  12401. * The id of the gamepad
  12402. */
  12403. id: string;
  12404. /**
  12405. * The index of the gamepad
  12406. */
  12407. index: number;
  12408. /**
  12409. * The browser gamepad
  12410. */
  12411. browserGamepad: any;
  12412. /**
  12413. * Specifies what type of gamepad this represents
  12414. */
  12415. type: number;
  12416. private _leftStick;
  12417. private _rightStick;
  12418. /** @hidden */
  12419. _isConnected: boolean;
  12420. private _leftStickAxisX;
  12421. private _leftStickAxisY;
  12422. private _rightStickAxisX;
  12423. private _rightStickAxisY;
  12424. /**
  12425. * Triggered when the left control stick has been changed
  12426. */
  12427. private _onleftstickchanged;
  12428. /**
  12429. * Triggered when the right control stick has been changed
  12430. */
  12431. private _onrightstickchanged;
  12432. /**
  12433. * Represents a gamepad controller
  12434. */
  12435. static GAMEPAD: number;
  12436. /**
  12437. * Represents a generic controller
  12438. */
  12439. static GENERIC: number;
  12440. /**
  12441. * Represents an XBox controller
  12442. */
  12443. static XBOX: number;
  12444. /**
  12445. * Represents a pose-enabled controller
  12446. */
  12447. static POSE_ENABLED: number;
  12448. /**
  12449. * Specifies whether the left control stick should be Y-inverted
  12450. */
  12451. protected _invertLeftStickY: boolean;
  12452. /**
  12453. * Specifies if the gamepad has been connected
  12454. */
  12455. readonly isConnected: boolean;
  12456. /**
  12457. * Initializes the gamepad
  12458. * @param id The id of the gamepad
  12459. * @param index The index of the gamepad
  12460. * @param browserGamepad The browser gamepad
  12461. * @param leftStickX The x component of the left joystick
  12462. * @param leftStickY The y component of the left joystick
  12463. * @param rightStickX The x component of the right joystick
  12464. * @param rightStickY The y component of the right joystick
  12465. */
  12466. constructor(
  12467. /**
  12468. * The id of the gamepad
  12469. */
  12470. id: string,
  12471. /**
  12472. * The index of the gamepad
  12473. */
  12474. index: number,
  12475. /**
  12476. * The browser gamepad
  12477. */
  12478. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12479. /**
  12480. * Callback triggered when the left joystick has changed
  12481. * @param callback
  12482. */
  12483. onleftstickchanged(callback: (values: StickValues) => void): void;
  12484. /**
  12485. * Callback triggered when the right joystick has changed
  12486. * @param callback
  12487. */
  12488. onrightstickchanged(callback: (values: StickValues) => void): void;
  12489. /**
  12490. * Gets the left joystick
  12491. */
  12492. /**
  12493. * Sets the left joystick values
  12494. */
  12495. leftStick: StickValues;
  12496. /**
  12497. * Gets the right joystick
  12498. */
  12499. /**
  12500. * Sets the right joystick value
  12501. */
  12502. rightStick: StickValues;
  12503. /**
  12504. * Updates the gamepad joystick positions
  12505. */
  12506. update(): void;
  12507. /**
  12508. * Disposes the gamepad
  12509. */
  12510. dispose(): void;
  12511. }
  12512. /**
  12513. * Represents a generic gamepad
  12514. */
  12515. export class GenericPad extends Gamepad {
  12516. private _buttons;
  12517. private _onbuttondown;
  12518. private _onbuttonup;
  12519. /**
  12520. * Observable triggered when a button has been pressed
  12521. */
  12522. onButtonDownObservable: Observable<number>;
  12523. /**
  12524. * Observable triggered when a button has been released
  12525. */
  12526. onButtonUpObservable: Observable<number>;
  12527. /**
  12528. * Callback triggered when a button has been pressed
  12529. * @param callback Called when a button has been pressed
  12530. */
  12531. onbuttondown(callback: (buttonPressed: number) => void): void;
  12532. /**
  12533. * Callback triggered when a button has been released
  12534. * @param callback Called when a button has been released
  12535. */
  12536. onbuttonup(callback: (buttonReleased: number) => void): void;
  12537. /**
  12538. * Initializes the generic gamepad
  12539. * @param id The id of the generic gamepad
  12540. * @param index The index of the generic gamepad
  12541. * @param browserGamepad The browser gamepad
  12542. */
  12543. constructor(id: string, index: number, browserGamepad: any);
  12544. private _setButtonValue;
  12545. /**
  12546. * Updates the generic gamepad
  12547. */
  12548. update(): void;
  12549. /**
  12550. * Disposes the generic gamepad
  12551. */
  12552. dispose(): void;
  12553. }
  12554. }
  12555. declare module BABYLON {
  12556. /**
  12557. * Defines the types of pose enabled controllers that are supported
  12558. */
  12559. export enum PoseEnabledControllerType {
  12560. /**
  12561. * HTC Vive
  12562. */
  12563. VIVE = 0,
  12564. /**
  12565. * Oculus Rift
  12566. */
  12567. OCULUS = 1,
  12568. /**
  12569. * Windows mixed reality
  12570. */
  12571. WINDOWS = 2,
  12572. /**
  12573. * Samsung gear VR
  12574. */
  12575. GEAR_VR = 3,
  12576. /**
  12577. * Google Daydream
  12578. */
  12579. DAYDREAM = 4,
  12580. /**
  12581. * Generic
  12582. */
  12583. GENERIC = 5
  12584. }
  12585. /**
  12586. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12587. */
  12588. export interface MutableGamepadButton {
  12589. /**
  12590. * Value of the button/trigger
  12591. */
  12592. value: number;
  12593. /**
  12594. * If the button/trigger is currently touched
  12595. */
  12596. touched: boolean;
  12597. /**
  12598. * If the button/trigger is currently pressed
  12599. */
  12600. pressed: boolean;
  12601. }
  12602. /**
  12603. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12604. * @hidden
  12605. */
  12606. export interface ExtendedGamepadButton extends GamepadButton {
  12607. /**
  12608. * If the button/trigger is currently pressed
  12609. */
  12610. readonly pressed: boolean;
  12611. /**
  12612. * If the button/trigger is currently touched
  12613. */
  12614. readonly touched: boolean;
  12615. /**
  12616. * Value of the button/trigger
  12617. */
  12618. readonly value: number;
  12619. }
  12620. /** @hidden */
  12621. export interface _GamePadFactory {
  12622. /**
  12623. * Returns wether or not the current gamepad can be created for this type of controller.
  12624. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12625. * @returns true if it can be created, otherwise false
  12626. */
  12627. canCreate(gamepadInfo: any): boolean;
  12628. /**
  12629. * Creates a new instance of the Gamepad.
  12630. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12631. * @returns the new gamepad instance
  12632. */
  12633. create(gamepadInfo: any): Gamepad;
  12634. }
  12635. /**
  12636. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12637. */
  12638. export class PoseEnabledControllerHelper {
  12639. /** @hidden */
  12640. static _ControllerFactories: _GamePadFactory[];
  12641. /** @hidden */
  12642. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12643. /**
  12644. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12645. * @param vrGamepad the gamepad to initialized
  12646. * @returns a vr controller of the type the gamepad identified as
  12647. */
  12648. static InitiateController(vrGamepad: any): Gamepad;
  12649. }
  12650. /**
  12651. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12652. */
  12653. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12654. private _deviceRoomPosition;
  12655. private _deviceRoomRotationQuaternion;
  12656. /**
  12657. * The device position in babylon space
  12658. */
  12659. devicePosition: Vector3;
  12660. /**
  12661. * The device rotation in babylon space
  12662. */
  12663. deviceRotationQuaternion: Quaternion;
  12664. /**
  12665. * The scale factor of the device in babylon space
  12666. */
  12667. deviceScaleFactor: number;
  12668. /**
  12669. * (Likely devicePosition should be used instead) The device position in its room space
  12670. */
  12671. position: Vector3;
  12672. /**
  12673. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12674. */
  12675. rotationQuaternion: Quaternion;
  12676. /**
  12677. * The type of controller (Eg. Windows mixed reality)
  12678. */
  12679. controllerType: PoseEnabledControllerType;
  12680. protected _calculatedPosition: Vector3;
  12681. private _calculatedRotation;
  12682. /**
  12683. * The raw pose from the device
  12684. */
  12685. rawPose: DevicePose;
  12686. private _trackPosition;
  12687. private _maxRotationDistFromHeadset;
  12688. private _draggedRoomRotation;
  12689. /**
  12690. * @hidden
  12691. */
  12692. _disableTrackPosition(fixedPosition: Vector3): void;
  12693. /**
  12694. * Internal, the mesh attached to the controller
  12695. * @hidden
  12696. */
  12697. _mesh: Nullable<AbstractMesh>;
  12698. private _poseControlledCamera;
  12699. private _leftHandSystemQuaternion;
  12700. /**
  12701. * Internal, matrix used to convert room space to babylon space
  12702. * @hidden
  12703. */
  12704. _deviceToWorld: Matrix;
  12705. /**
  12706. * Node to be used when casting a ray from the controller
  12707. * @hidden
  12708. */
  12709. _pointingPoseNode: Nullable<TransformNode>;
  12710. /**
  12711. * Name of the child mesh that can be used to cast a ray from the controller
  12712. */
  12713. static readonly POINTING_POSE: string;
  12714. /**
  12715. * Creates a new PoseEnabledController from a gamepad
  12716. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12717. */
  12718. constructor(browserGamepad: any);
  12719. private _workingMatrix;
  12720. /**
  12721. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12722. */
  12723. update(): void;
  12724. /**
  12725. * Updates only the pose device and mesh without doing any button event checking
  12726. */
  12727. protected _updatePoseAndMesh(): void;
  12728. /**
  12729. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12730. * @param poseData raw pose fromthe device
  12731. */
  12732. updateFromDevice(poseData: DevicePose): void;
  12733. /**
  12734. * @hidden
  12735. */
  12736. _meshAttachedObservable: Observable<AbstractMesh>;
  12737. /**
  12738. * Attaches a mesh to the controller
  12739. * @param mesh the mesh to be attached
  12740. */
  12741. attachToMesh(mesh: AbstractMesh): void;
  12742. /**
  12743. * Attaches the controllers mesh to a camera
  12744. * @param camera the camera the mesh should be attached to
  12745. */
  12746. attachToPoseControlledCamera(camera: TargetCamera): void;
  12747. /**
  12748. * Disposes of the controller
  12749. */
  12750. dispose(): void;
  12751. /**
  12752. * The mesh that is attached to the controller
  12753. */
  12754. readonly mesh: Nullable<AbstractMesh>;
  12755. /**
  12756. * Gets the ray of the controller in the direction the controller is pointing
  12757. * @param length the length the resulting ray should be
  12758. * @returns a ray in the direction the controller is pointing
  12759. */
  12760. getForwardRay(length?: number): Ray;
  12761. }
  12762. }
  12763. declare module BABYLON {
  12764. /**
  12765. * Defines the WebVRController object that represents controllers tracked in 3D space
  12766. */
  12767. export abstract class WebVRController extends PoseEnabledController {
  12768. /**
  12769. * Internal, the default controller model for the controller
  12770. */
  12771. protected _defaultModel: AbstractMesh;
  12772. /**
  12773. * Fired when the trigger state has changed
  12774. */
  12775. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12776. /**
  12777. * Fired when the main button state has changed
  12778. */
  12779. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12780. /**
  12781. * Fired when the secondary button state has changed
  12782. */
  12783. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12784. /**
  12785. * Fired when the pad state has changed
  12786. */
  12787. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12788. /**
  12789. * Fired when controllers stick values have changed
  12790. */
  12791. onPadValuesChangedObservable: Observable<StickValues>;
  12792. /**
  12793. * Array of button availible on the controller
  12794. */
  12795. protected _buttons: Array<MutableGamepadButton>;
  12796. private _onButtonStateChange;
  12797. /**
  12798. * Fired when a controller button's state has changed
  12799. * @param callback the callback containing the button that was modified
  12800. */
  12801. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12802. /**
  12803. * X and Y axis corrisponding to the controllers joystick
  12804. */
  12805. pad: StickValues;
  12806. /**
  12807. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12808. */
  12809. hand: string;
  12810. /**
  12811. * The default controller model for the controller
  12812. */
  12813. readonly defaultModel: AbstractMesh;
  12814. /**
  12815. * Creates a new WebVRController from a gamepad
  12816. * @param vrGamepad the gamepad that the WebVRController should be created from
  12817. */
  12818. constructor(vrGamepad: any);
  12819. /**
  12820. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12821. */
  12822. update(): void;
  12823. /**
  12824. * Function to be called when a button is modified
  12825. */
  12826. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12827. /**
  12828. * Loads a mesh and attaches it to the controller
  12829. * @param scene the scene the mesh should be added to
  12830. * @param meshLoaded callback for when the mesh has been loaded
  12831. */
  12832. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12833. private _setButtonValue;
  12834. private _changes;
  12835. private _checkChanges;
  12836. /**
  12837. * Disposes of th webVRCOntroller
  12838. */
  12839. dispose(): void;
  12840. }
  12841. }
  12842. declare module BABYLON {
  12843. /**
  12844. * The HemisphericLight simulates the ambient environment light,
  12845. * so the passed direction is the light reflection direction, not the incoming direction.
  12846. */
  12847. export class HemisphericLight extends Light {
  12848. /**
  12849. * The groundColor is the light in the opposite direction to the one specified during creation.
  12850. * 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.
  12851. */
  12852. groundColor: Color3;
  12853. /**
  12854. * The light reflection direction, not the incoming direction.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12859. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12860. * The HemisphericLight can't cast shadows.
  12861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12862. * @param name The friendly name of the light
  12863. * @param direction The direction of the light reflection
  12864. * @param scene The scene the light belongs to
  12865. */
  12866. constructor(name: string, direction: Vector3, scene: Scene);
  12867. protected _buildUniformLayout(): void;
  12868. /**
  12869. * Returns the string "HemisphericLight".
  12870. * @return The class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12875. * Returns the updated direction.
  12876. * @param target The target the direction should point to
  12877. * @return The computed direction
  12878. */
  12879. setDirectionToTarget(target: Vector3): Vector3;
  12880. /**
  12881. * Returns the shadow generator associated to the light.
  12882. * @returns Always null for hemispheric lights because it does not support shadows.
  12883. */
  12884. getShadowGenerator(): Nullable<IShadowGenerator>;
  12885. /**
  12886. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12887. * @param effect The effect to update
  12888. * @param lightIndex The index of the light in the effect to update
  12889. * @returns The hemispheric light
  12890. */
  12891. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12892. /**
  12893. * Computes the world matrix of the node
  12894. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12895. * @param useWasUpdatedFlag defines a reserved property
  12896. * @returns the world matrix
  12897. */
  12898. computeWorldMatrix(): Matrix;
  12899. /**
  12900. * Returns the integer 3.
  12901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12902. */
  12903. getTypeID(): number;
  12904. /**
  12905. * Prepares the list of defines specific to the light type.
  12906. * @param defines the list of defines
  12907. * @param lightIndex defines the index of the light for the effect
  12908. */
  12909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12910. }
  12911. }
  12912. declare module BABYLON {
  12913. /**
  12914. * This represents all the required metrics to create a VR camera.
  12915. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  12916. */
  12917. export class VRCameraMetrics {
  12918. /**
  12919. * Define the horizontal resolution off the screen.
  12920. */
  12921. hResolution: number;
  12922. /**
  12923. * Define the vertical resolution off the screen.
  12924. */
  12925. vResolution: number;
  12926. /**
  12927. * Define the horizontal screen size.
  12928. */
  12929. hScreenSize: number;
  12930. /**
  12931. * Define the vertical screen size.
  12932. */
  12933. vScreenSize: number;
  12934. /**
  12935. * Define the vertical screen center position.
  12936. */
  12937. vScreenCenter: number;
  12938. /**
  12939. * Define the distance of the eyes to the screen.
  12940. */
  12941. eyeToScreenDistance: number;
  12942. /**
  12943. * Define the distance between both lenses
  12944. */
  12945. lensSeparationDistance: number;
  12946. /**
  12947. * Define the distance between both viewer's eyes.
  12948. */
  12949. interpupillaryDistance: number;
  12950. /**
  12951. * Define the distortion factor of the VR postprocess.
  12952. * Please, touch with care.
  12953. */
  12954. distortionK: number[];
  12955. /**
  12956. * Define the chromatic aberration correction factors for the VR post process.
  12957. */
  12958. chromaAbCorrection: number[];
  12959. /**
  12960. * Define the scale factor of the post process.
  12961. * The smaller the better but the slower.
  12962. */
  12963. postProcessScaleFactor: number;
  12964. /**
  12965. * Define an offset for the lens center.
  12966. */
  12967. lensCenterOffset: number;
  12968. /**
  12969. * Define if the current vr camera should compensate the distortion of the lense or not.
  12970. */
  12971. compensateDistortion: boolean;
  12972. /**
  12973. * Defines if multiview should be enabled when rendering (Default: false)
  12974. */
  12975. multiviewEnabled: boolean;
  12976. /**
  12977. * Gets the rendering aspect ratio based on the provided resolutions.
  12978. */
  12979. readonly aspectRatio: number;
  12980. /**
  12981. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  12982. */
  12983. readonly aspectRatioFov: number;
  12984. /**
  12985. * @hidden
  12986. */
  12987. readonly leftHMatrix: Matrix;
  12988. /**
  12989. * @hidden
  12990. */
  12991. readonly rightHMatrix: Matrix;
  12992. /**
  12993. * @hidden
  12994. */
  12995. readonly leftPreViewMatrix: Matrix;
  12996. /**
  12997. * @hidden
  12998. */
  12999. readonly rightPreViewMatrix: Matrix;
  13000. /**
  13001. * Get the default VRMetrics based on the most generic setup.
  13002. * @returns the default vr metrics
  13003. */
  13004. static GetDefault(): VRCameraMetrics;
  13005. }
  13006. }
  13007. declare module BABYLON {
  13008. /** @hidden */
  13009. export var vrDistortionCorrectionPixelShader: {
  13010. name: string;
  13011. shader: string;
  13012. };
  13013. }
  13014. declare module BABYLON {
  13015. /** @hidden */
  13016. export var vrMultiviewToSingleviewPixelShader: {
  13017. name: string;
  13018. shader: string;
  13019. };
  13020. }
  13021. declare module BABYLON {
  13022. /**
  13023. * VRDistortionCorrectionPostProcess used for mobile VR
  13024. */
  13025. export class VRDistortionCorrectionPostProcess extends PostProcess {
  13026. private _isRightEye;
  13027. private _distortionFactors;
  13028. private _postProcessScaleFactor;
  13029. private _lensCenterOffset;
  13030. private _scaleIn;
  13031. private _scaleFactor;
  13032. private _lensCenter;
  13033. /**
  13034. * Initializes the VRDistortionCorrectionPostProcess
  13035. * @param name The name of the effect.
  13036. * @param camera The camera to apply the render pass to.
  13037. * @param isRightEye If this is for the right eye distortion
  13038. * @param vrMetrics All the required metrics for the VR camera
  13039. */
  13040. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  13041. }
  13042. /**
  13043. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13044. * This will not be used for webXR as it supports displaying texture arrays directly
  13045. */
  13046. export class VRMultiviewToSingleview extends PostProcess {
  13047. /**
  13048. * Initializes a VRMultiviewToSingleview
  13049. * @param name name of the post process
  13050. * @param camera camera to be applied to
  13051. * @param scaleFactor scaling factor to the size of the output texture
  13052. */
  13053. constructor(name: string, camera: Camera, scaleFactor: number);
  13054. }
  13055. }
  13056. declare module BABYLON {
  13057. /**
  13058. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13059. * IMPORTANT!! The data is right-hand data.
  13060. * @export
  13061. * @interface DevicePose
  13062. */
  13063. export interface DevicePose {
  13064. /**
  13065. * The position of the device, values in array are [x,y,z].
  13066. */
  13067. readonly position: Nullable<Float32Array>;
  13068. /**
  13069. * The linearVelocity of the device, values in array are [x,y,z].
  13070. */
  13071. readonly linearVelocity: Nullable<Float32Array>;
  13072. /**
  13073. * The linearAcceleration of the device, values in array are [x,y,z].
  13074. */
  13075. readonly linearAcceleration: Nullable<Float32Array>;
  13076. /**
  13077. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13078. */
  13079. readonly orientation: Nullable<Float32Array>;
  13080. /**
  13081. * The angularVelocity of the device, values in array are [x,y,z].
  13082. */
  13083. readonly angularVelocity: Nullable<Float32Array>;
  13084. /**
  13085. * The angularAcceleration of the device, values in array are [x,y,z].
  13086. */
  13087. readonly angularAcceleration: Nullable<Float32Array>;
  13088. }
  13089. /**
  13090. * Interface representing a pose controlled object in Babylon.
  13091. * A pose controlled object has both regular pose values as well as pose values
  13092. * from an external device such as a VR head mounted display
  13093. */
  13094. export interface PoseControlled {
  13095. /**
  13096. * The position of the object in babylon space.
  13097. */
  13098. position: Vector3;
  13099. /**
  13100. * The rotation quaternion of the object in babylon space.
  13101. */
  13102. rotationQuaternion: Quaternion;
  13103. /**
  13104. * The position of the device in babylon space.
  13105. */
  13106. devicePosition?: Vector3;
  13107. /**
  13108. * The rotation quaternion of the device in babylon space.
  13109. */
  13110. deviceRotationQuaternion: Quaternion;
  13111. /**
  13112. * The raw pose coming from the device.
  13113. */
  13114. rawPose: Nullable<DevicePose>;
  13115. /**
  13116. * The scale of the device to be used when translating from device space to babylon space.
  13117. */
  13118. deviceScaleFactor: number;
  13119. /**
  13120. * Updates the poseControlled values based on the input device pose.
  13121. * @param poseData the pose data to update the object with
  13122. */
  13123. updateFromDevice(poseData: DevicePose): void;
  13124. }
  13125. /**
  13126. * Set of options to customize the webVRCamera
  13127. */
  13128. export interface WebVROptions {
  13129. /**
  13130. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13131. */
  13132. trackPosition?: boolean;
  13133. /**
  13134. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13135. */
  13136. positionScale?: number;
  13137. /**
  13138. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13139. */
  13140. displayName?: string;
  13141. /**
  13142. * Should the native controller meshes be initialized. (default: true)
  13143. */
  13144. controllerMeshes?: boolean;
  13145. /**
  13146. * Creating a default HemiLight only on controllers. (default: true)
  13147. */
  13148. defaultLightingOnControllers?: boolean;
  13149. /**
  13150. * If you don't want to use the default VR button of the helper. (default: false)
  13151. */
  13152. useCustomVRButton?: boolean;
  13153. /**
  13154. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13155. */
  13156. customVRButton?: HTMLButtonElement;
  13157. /**
  13158. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13159. */
  13160. rayLength?: number;
  13161. /**
  13162. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13163. */
  13164. defaultHeight?: number;
  13165. /**
  13166. * If multiview should be used if availible (default: false)
  13167. */
  13168. useMultiview?: boolean;
  13169. }
  13170. /**
  13171. * This represents a WebVR camera.
  13172. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13173. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13174. */
  13175. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13176. private webVROptions;
  13177. /**
  13178. * @hidden
  13179. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13180. */
  13181. _vrDevice: any;
  13182. /**
  13183. * The rawPose of the vrDevice.
  13184. */
  13185. rawPose: Nullable<DevicePose>;
  13186. private _onVREnabled;
  13187. private _specsVersion;
  13188. private _attached;
  13189. private _frameData;
  13190. protected _descendants: Array<Node>;
  13191. private _deviceRoomPosition;
  13192. /** @hidden */
  13193. _deviceRoomRotationQuaternion: Quaternion;
  13194. private _standingMatrix;
  13195. /**
  13196. * Represents device position in babylon space.
  13197. */
  13198. devicePosition: Vector3;
  13199. /**
  13200. * Represents device rotation in babylon space.
  13201. */
  13202. deviceRotationQuaternion: Quaternion;
  13203. /**
  13204. * The scale of the device to be used when translating from device space to babylon space.
  13205. */
  13206. deviceScaleFactor: number;
  13207. private _deviceToWorld;
  13208. private _worldToDevice;
  13209. /**
  13210. * References to the webVR controllers for the vrDevice.
  13211. */
  13212. controllers: Array<WebVRController>;
  13213. /**
  13214. * Emits an event when a controller is attached.
  13215. */
  13216. onControllersAttachedObservable: Observable<WebVRController[]>;
  13217. /**
  13218. * Emits an event when a controller's mesh has been loaded;
  13219. */
  13220. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13221. /**
  13222. * Emits an event when the HMD's pose has been updated.
  13223. */
  13224. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13225. private _poseSet;
  13226. /**
  13227. * If the rig cameras be used as parent instead of this camera.
  13228. */
  13229. rigParenting: boolean;
  13230. private _lightOnControllers;
  13231. private _defaultHeight?;
  13232. /**
  13233. * Instantiates a WebVRFreeCamera.
  13234. * @param name The name of the WebVRFreeCamera
  13235. * @param position The starting anchor position for the camera
  13236. * @param scene The scene the camera belongs to
  13237. * @param webVROptions a set of customizable options for the webVRCamera
  13238. */
  13239. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13240. /**
  13241. * Gets the device distance from the ground in meters.
  13242. * @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.
  13243. */
  13244. deviceDistanceToRoomGround(): number;
  13245. /**
  13246. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13247. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13248. */
  13249. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13250. /**
  13251. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13252. * @returns A promise with a boolean set to if the standing matrix is supported.
  13253. */
  13254. useStandingMatrixAsync(): Promise<boolean>;
  13255. /**
  13256. * Disposes the camera
  13257. */
  13258. dispose(): void;
  13259. /**
  13260. * Gets a vrController by name.
  13261. * @param name The name of the controller to retreive
  13262. * @returns the controller matching the name specified or null if not found
  13263. */
  13264. getControllerByName(name: string): Nullable<WebVRController>;
  13265. private _leftController;
  13266. /**
  13267. * The controller corrisponding to the users left hand.
  13268. */
  13269. readonly leftController: Nullable<WebVRController>;
  13270. private _rightController;
  13271. /**
  13272. * The controller corrisponding to the users right hand.
  13273. */
  13274. readonly rightController: Nullable<WebVRController>;
  13275. /**
  13276. * Casts a ray forward from the vrCamera's gaze.
  13277. * @param length Length of the ray (default: 100)
  13278. * @returns the ray corrisponding to the gaze
  13279. */
  13280. getForwardRay(length?: number): Ray;
  13281. /**
  13282. * @hidden
  13283. * Updates the camera based on device's frame data
  13284. */
  13285. _checkInputs(): void;
  13286. /**
  13287. * Updates the poseControlled values based on the input device pose.
  13288. * @param poseData Pose coming from the device
  13289. */
  13290. updateFromDevice(poseData: DevicePose): void;
  13291. private _htmlElementAttached;
  13292. private _detachIfAttached;
  13293. /**
  13294. * WebVR's attach control will start broadcasting frames to the device.
  13295. * Note that in certain browsers (chrome for example) this function must be called
  13296. * within a user-interaction callback. Example:
  13297. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13298. *
  13299. * @param element html element to attach the vrDevice to
  13300. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13301. */
  13302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13303. /**
  13304. * Detaches the camera from the html element and disables VR
  13305. *
  13306. * @param element html element to detach from
  13307. */
  13308. detachControl(element: HTMLElement): void;
  13309. /**
  13310. * @returns the name of this class
  13311. */
  13312. getClassName(): string;
  13313. /**
  13314. * Calls resetPose on the vrDisplay
  13315. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13316. */
  13317. resetToCurrentRotation(): void;
  13318. /**
  13319. * @hidden
  13320. * Updates the rig cameras (left and right eye)
  13321. */
  13322. _updateRigCameras(): void;
  13323. private _workingVector;
  13324. private _oneVector;
  13325. private _workingMatrix;
  13326. private updateCacheCalled;
  13327. private _correctPositionIfNotTrackPosition;
  13328. /**
  13329. * @hidden
  13330. * Updates the cached values of the camera
  13331. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13332. */
  13333. _updateCache(ignoreParentClass?: boolean): void;
  13334. /**
  13335. * @hidden
  13336. * Get current device position in babylon world
  13337. */
  13338. _computeDevicePosition(): void;
  13339. /**
  13340. * Updates the current device position and rotation in the babylon world
  13341. */
  13342. update(): void;
  13343. /**
  13344. * @hidden
  13345. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13346. * @returns an identity matrix
  13347. */
  13348. _getViewMatrix(): Matrix;
  13349. private _tmpMatrix;
  13350. /**
  13351. * This function is called by the two RIG cameras.
  13352. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13353. * @hidden
  13354. */
  13355. _getWebVRViewMatrix(): Matrix;
  13356. /** @hidden */
  13357. _getWebVRProjectionMatrix(): Matrix;
  13358. private _onGamepadConnectedObserver;
  13359. private _onGamepadDisconnectedObserver;
  13360. private _updateCacheWhenTrackingDisabledObserver;
  13361. /**
  13362. * Initializes the controllers and their meshes
  13363. */
  13364. initControllers(): void;
  13365. }
  13366. }
  13367. declare module BABYLON {
  13368. /**
  13369. * Size options for a post process
  13370. */
  13371. export type PostProcessOptions = {
  13372. width: number;
  13373. height: number;
  13374. };
  13375. /**
  13376. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13377. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13378. */
  13379. export class PostProcess {
  13380. /** Name of the PostProcess. */
  13381. name: string;
  13382. /**
  13383. * Gets or sets the unique id of the post process
  13384. */
  13385. uniqueId: number;
  13386. /**
  13387. * Width of the texture to apply the post process on
  13388. */
  13389. width: number;
  13390. /**
  13391. * Height of the texture to apply the post process on
  13392. */
  13393. height: number;
  13394. /**
  13395. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13396. * @hidden
  13397. */
  13398. _outputTexture: Nullable<InternalTexture>;
  13399. /**
  13400. * Sampling mode used by the shader
  13401. * See https://doc.babylonjs.com/classes/3.1/texture
  13402. */
  13403. renderTargetSamplingMode: number;
  13404. /**
  13405. * Clear color to use when screen clearing
  13406. */
  13407. clearColor: Color4;
  13408. /**
  13409. * If the buffer needs to be cleared before applying the post process. (default: true)
  13410. * Should be set to false if shader will overwrite all previous pixels.
  13411. */
  13412. autoClear: boolean;
  13413. /**
  13414. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13415. */
  13416. alphaMode: number;
  13417. /**
  13418. * Sets the setAlphaBlendConstants of the babylon engine
  13419. */
  13420. alphaConstants: Color4;
  13421. /**
  13422. * Animations to be used for the post processing
  13423. */
  13424. animations: Animation[];
  13425. /**
  13426. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13427. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13428. */
  13429. enablePixelPerfectMode: boolean;
  13430. /**
  13431. * Force the postprocess to be applied without taking in account viewport
  13432. */
  13433. forceFullscreenViewport: boolean;
  13434. /**
  13435. * List of inspectable custom properties (used by the Inspector)
  13436. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13437. */
  13438. inspectableCustomProperties: IInspectable[];
  13439. /**
  13440. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13441. *
  13442. * | Value | Type | Description |
  13443. * | ----- | ----------------------------------- | ----------- |
  13444. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13445. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13446. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13447. *
  13448. */
  13449. scaleMode: number;
  13450. /**
  13451. * Force textures to be a power of two (default: false)
  13452. */
  13453. alwaysForcePOT: boolean;
  13454. private _samples;
  13455. /**
  13456. * Number of sample textures (default: 1)
  13457. */
  13458. samples: number;
  13459. /**
  13460. * Modify the scale of the post process to be the same as the viewport (default: false)
  13461. */
  13462. adaptScaleToCurrentViewport: boolean;
  13463. private _camera;
  13464. private _scene;
  13465. private _engine;
  13466. private _options;
  13467. private _reusable;
  13468. private _textureType;
  13469. /**
  13470. * Smart array of input and output textures for the post process.
  13471. * @hidden
  13472. */
  13473. _textures: SmartArray<InternalTexture>;
  13474. /**
  13475. * The index in _textures that corresponds to the output texture.
  13476. * @hidden
  13477. */
  13478. _currentRenderTextureInd: number;
  13479. private _effect;
  13480. private _samplers;
  13481. private _fragmentUrl;
  13482. private _vertexUrl;
  13483. private _parameters;
  13484. private _scaleRatio;
  13485. protected _indexParameters: any;
  13486. private _shareOutputWithPostProcess;
  13487. private _texelSize;
  13488. private _forcedOutputTexture;
  13489. /**
  13490. * Returns the fragment url or shader name used in the post process.
  13491. * @returns the fragment url or name in the shader store.
  13492. */
  13493. getEffectName(): string;
  13494. /**
  13495. * An event triggered when the postprocess is activated.
  13496. */
  13497. onActivateObservable: Observable<Camera>;
  13498. private _onActivateObserver;
  13499. /**
  13500. * A function that is added to the onActivateObservable
  13501. */
  13502. onActivate: Nullable<(camera: Camera) => void>;
  13503. /**
  13504. * An event triggered when the postprocess changes its size.
  13505. */
  13506. onSizeChangedObservable: Observable<PostProcess>;
  13507. private _onSizeChangedObserver;
  13508. /**
  13509. * A function that is added to the onSizeChangedObservable
  13510. */
  13511. onSizeChanged: (postProcess: PostProcess) => void;
  13512. /**
  13513. * An event triggered when the postprocess applies its effect.
  13514. */
  13515. onApplyObservable: Observable<Effect>;
  13516. private _onApplyObserver;
  13517. /**
  13518. * A function that is added to the onApplyObservable
  13519. */
  13520. onApply: (effect: Effect) => void;
  13521. /**
  13522. * An event triggered before rendering the postprocess
  13523. */
  13524. onBeforeRenderObservable: Observable<Effect>;
  13525. private _onBeforeRenderObserver;
  13526. /**
  13527. * A function that is added to the onBeforeRenderObservable
  13528. */
  13529. onBeforeRender: (effect: Effect) => void;
  13530. /**
  13531. * An event triggered after rendering the postprocess
  13532. */
  13533. onAfterRenderObservable: Observable<Effect>;
  13534. private _onAfterRenderObserver;
  13535. /**
  13536. * A function that is added to the onAfterRenderObservable
  13537. */
  13538. onAfterRender: (efect: Effect) => void;
  13539. /**
  13540. * 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
  13541. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13542. */
  13543. inputTexture: InternalTexture;
  13544. /**
  13545. * Gets the camera which post process is applied to.
  13546. * @returns The camera the post process is applied to.
  13547. */
  13548. getCamera(): Camera;
  13549. /**
  13550. * Gets the texel size of the postprocess.
  13551. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13552. */
  13553. readonly texelSize: Vector2;
  13554. /**
  13555. * Creates a new instance PostProcess
  13556. * @param name The name of the PostProcess.
  13557. * @param fragmentUrl The url of the fragment shader to be used.
  13558. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13559. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13560. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13561. * @param camera The camera to apply the render pass to.
  13562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13563. * @param engine The engine which the post process will be applied. (default: current engine)
  13564. * @param reusable If the post process can be reused on the same frame. (default: false)
  13565. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13566. * @param textureType Type of textures used when performing the post process. (default: 0)
  13567. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13568. * @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
  13569. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13570. */
  13571. constructor(
  13572. /** Name of the PostProcess. */
  13573. 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);
  13574. /**
  13575. * Gets a string idenfifying the name of the class
  13576. * @returns "PostProcess" string
  13577. */
  13578. getClassName(): string;
  13579. /**
  13580. * Gets the engine which this post process belongs to.
  13581. * @returns The engine the post process was enabled with.
  13582. */
  13583. getEngine(): Engine;
  13584. /**
  13585. * The effect that is created when initializing the post process.
  13586. * @returns The created effect corrisponding the the postprocess.
  13587. */
  13588. getEffect(): Effect;
  13589. /**
  13590. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13591. * @param postProcess The post process to share the output with.
  13592. * @returns This post process.
  13593. */
  13594. shareOutputWith(postProcess: PostProcess): PostProcess;
  13595. /**
  13596. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13597. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13598. */
  13599. useOwnOutput(): void;
  13600. /**
  13601. * Updates the effect with the current post process compile time values and recompiles the shader.
  13602. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13603. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13604. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13605. * @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
  13606. * @param onCompiled Called when the shader has been compiled.
  13607. * @param onError Called if there is an error when compiling a shader.
  13608. */
  13609. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13610. /**
  13611. * The post process is reusable if it can be used multiple times within one frame.
  13612. * @returns If the post process is reusable
  13613. */
  13614. isReusable(): boolean;
  13615. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13616. markTextureDirty(): void;
  13617. /**
  13618. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13619. * 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.
  13620. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13621. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13622. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13623. * @returns The target texture that was bound to be written to.
  13624. */
  13625. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13626. /**
  13627. * If the post process is supported.
  13628. */
  13629. readonly isSupported: boolean;
  13630. /**
  13631. * The aspect ratio of the output texture.
  13632. */
  13633. readonly aspectRatio: number;
  13634. /**
  13635. * Get a value indicating if the post-process is ready to be used
  13636. * @returns true if the post-process is ready (shader is compiled)
  13637. */
  13638. isReady(): boolean;
  13639. /**
  13640. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13641. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13642. */
  13643. apply(): Nullable<Effect>;
  13644. private _disposeTextures;
  13645. /**
  13646. * Disposes the post process.
  13647. * @param camera The camera to dispose the post process on.
  13648. */
  13649. dispose(camera?: Camera): void;
  13650. }
  13651. }
  13652. declare module BABYLON {
  13653. /**
  13654. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13655. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13656. */
  13657. export class PostProcessManager {
  13658. private _scene;
  13659. private _indexBuffer;
  13660. private _vertexBuffers;
  13661. /**
  13662. * Creates a new instance PostProcess
  13663. * @param scene The scene that the post process is associated with.
  13664. */
  13665. constructor(scene: Scene);
  13666. private _prepareBuffers;
  13667. private _buildIndexBuffer;
  13668. /**
  13669. * Rebuilds the vertex buffers of the manager.
  13670. * @hidden
  13671. */
  13672. _rebuild(): void;
  13673. /**
  13674. * Prepares a frame to be run through a post process.
  13675. * @param sourceTexture The input texture to the post procesess. (default: null)
  13676. * @param postProcesses An array of post processes to be run. (default: null)
  13677. * @returns True if the post processes were able to be run.
  13678. * @hidden
  13679. */
  13680. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13681. /**
  13682. * Manually render a set of post processes to a texture.
  13683. * @param postProcesses An array of post processes to be run.
  13684. * @param targetTexture The target texture to render to.
  13685. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13686. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13687. * @param lodLevel defines which lod of the texture to render to
  13688. */
  13689. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13690. /**
  13691. * Finalize the result of the output of the postprocesses.
  13692. * @param doNotPresent If true the result will not be displayed to the screen.
  13693. * @param targetTexture The target texture to render to.
  13694. * @param faceIndex The index of the face to bind the target texture to.
  13695. * @param postProcesses The array of post processes to render.
  13696. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13697. * @hidden
  13698. */
  13699. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13700. /**
  13701. * Disposes of the post process manager.
  13702. */
  13703. dispose(): void;
  13704. }
  13705. }
  13706. declare module BABYLON {
  13707. interface AbstractScene {
  13708. /**
  13709. * The list of layers (background and foreground) of the scene
  13710. */
  13711. layers: Array<Layer>;
  13712. }
  13713. /**
  13714. * Defines the layer scene component responsible to manage any layers
  13715. * in a given scene.
  13716. */
  13717. export class LayerSceneComponent implements ISceneComponent {
  13718. /**
  13719. * The component name helpfull to identify the component in the list of scene components.
  13720. */
  13721. readonly name: string;
  13722. /**
  13723. * The scene the component belongs to.
  13724. */
  13725. scene: Scene;
  13726. private _engine;
  13727. /**
  13728. * Creates a new instance of the component for the given scene
  13729. * @param scene Defines the scene to register the component in
  13730. */
  13731. constructor(scene: Scene);
  13732. /**
  13733. * Registers the component in a given scene
  13734. */
  13735. register(): void;
  13736. /**
  13737. * Rebuilds the elements related to this component in case of
  13738. * context lost for instance.
  13739. */
  13740. rebuild(): void;
  13741. /**
  13742. * Disposes the component and the associated ressources.
  13743. */
  13744. dispose(): void;
  13745. private _draw;
  13746. private _drawCameraPredicate;
  13747. private _drawCameraBackground;
  13748. private _drawCameraForeground;
  13749. private _drawRenderTargetPredicate;
  13750. private _drawRenderTargetBackground;
  13751. private _drawRenderTargetForeground;
  13752. }
  13753. }
  13754. declare module BABYLON {
  13755. /** @hidden */
  13756. export var layerPixelShader: {
  13757. name: string;
  13758. shader: string;
  13759. };
  13760. }
  13761. declare module BABYLON {
  13762. /** @hidden */
  13763. export var layerVertexShader: {
  13764. name: string;
  13765. shader: string;
  13766. };
  13767. }
  13768. declare module BABYLON {
  13769. /**
  13770. * This represents a full screen 2d layer.
  13771. * This can be useful to display a picture in the background of your scene for instance.
  13772. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13773. */
  13774. export class Layer {
  13775. /**
  13776. * Define the name of the layer.
  13777. */
  13778. name: string;
  13779. /**
  13780. * Define the texture the layer should display.
  13781. */
  13782. texture: Nullable<Texture>;
  13783. /**
  13784. * Is the layer in background or foreground.
  13785. */
  13786. isBackground: boolean;
  13787. /**
  13788. * Define the color of the layer (instead of texture).
  13789. */
  13790. color: Color4;
  13791. /**
  13792. * Define the scale of the layer in order to zoom in out of the texture.
  13793. */
  13794. scale: Vector2;
  13795. /**
  13796. * Define an offset for the layer in order to shift the texture.
  13797. */
  13798. offset: Vector2;
  13799. /**
  13800. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13801. */
  13802. alphaBlendingMode: number;
  13803. /**
  13804. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13805. * Alpha test will not mix with the background color in case of transparency.
  13806. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13807. */
  13808. alphaTest: boolean;
  13809. /**
  13810. * Define a mask to restrict the layer to only some of the scene cameras.
  13811. */
  13812. layerMask: number;
  13813. /**
  13814. * Define the list of render target the layer is visible into.
  13815. */
  13816. renderTargetTextures: RenderTargetTexture[];
  13817. /**
  13818. * Define if the layer is only used in renderTarget or if it also
  13819. * renders in the main frame buffer of the canvas.
  13820. */
  13821. renderOnlyInRenderTargetTextures: boolean;
  13822. private _scene;
  13823. private _vertexBuffers;
  13824. private _indexBuffer;
  13825. private _effect;
  13826. private _alphaTestEffect;
  13827. /**
  13828. * An event triggered when the layer is disposed.
  13829. */
  13830. onDisposeObservable: Observable<Layer>;
  13831. private _onDisposeObserver;
  13832. /**
  13833. * Back compatibility with callback before the onDisposeObservable existed.
  13834. * The set callback will be triggered when the layer has been disposed.
  13835. */
  13836. onDispose: () => void;
  13837. /**
  13838. * An event triggered before rendering the scene
  13839. */
  13840. onBeforeRenderObservable: Observable<Layer>;
  13841. private _onBeforeRenderObserver;
  13842. /**
  13843. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13844. * The set callback will be triggered just before rendering the layer.
  13845. */
  13846. onBeforeRender: () => void;
  13847. /**
  13848. * An event triggered after rendering the scene
  13849. */
  13850. onAfterRenderObservable: Observable<Layer>;
  13851. private _onAfterRenderObserver;
  13852. /**
  13853. * Back compatibility with callback before the onAfterRenderObservable existed.
  13854. * The set callback will be triggered just after rendering the layer.
  13855. */
  13856. onAfterRender: () => void;
  13857. /**
  13858. * Instantiates a new layer.
  13859. * This represents a full screen 2d layer.
  13860. * This can be useful to display a picture in the background of your scene for instance.
  13861. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13862. * @param name Define the name of the layer in the scene
  13863. * @param imgUrl Define the url of the texture to display in the layer
  13864. * @param scene Define the scene the layer belongs to
  13865. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13866. * @param color Defines a color for the layer
  13867. */
  13868. constructor(
  13869. /**
  13870. * Define the name of the layer.
  13871. */
  13872. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13873. private _createIndexBuffer;
  13874. /** @hidden */
  13875. _rebuild(): void;
  13876. /**
  13877. * Renders the layer in the scene.
  13878. */
  13879. render(): void;
  13880. /**
  13881. * Disposes and releases the associated ressources.
  13882. */
  13883. dispose(): void;
  13884. }
  13885. }
  13886. declare module BABYLON {
  13887. interface AbstractScene {
  13888. /**
  13889. * The list of procedural textures added to the scene
  13890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13891. */
  13892. proceduralTextures: Array<ProceduralTexture>;
  13893. }
  13894. /**
  13895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13896. * in a given scene.
  13897. */
  13898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13899. /**
  13900. * The component name helpfull to identify the component in the list of scene components.
  13901. */
  13902. readonly name: string;
  13903. /**
  13904. * The scene the component belongs to.
  13905. */
  13906. scene: Scene;
  13907. /**
  13908. * Creates a new instance of the component for the given scene
  13909. * @param scene Defines the scene to register the component in
  13910. */
  13911. constructor(scene: Scene);
  13912. /**
  13913. * Registers the component in a given scene
  13914. */
  13915. register(): void;
  13916. /**
  13917. * Rebuilds the elements related to this component in case of
  13918. * context lost for instance.
  13919. */
  13920. rebuild(): void;
  13921. /**
  13922. * Disposes the component and the associated ressources.
  13923. */
  13924. dispose(): void;
  13925. private _beforeClear;
  13926. }
  13927. }
  13928. declare module BABYLON {
  13929. /** @hidden */
  13930. export var proceduralVertexShader: {
  13931. name: string;
  13932. shader: string;
  13933. };
  13934. }
  13935. declare module BABYLON {
  13936. /**
  13937. * 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.
  13938. * This is the base class of any Procedural texture and contains most of the shareable code.
  13939. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13940. */
  13941. export class ProceduralTexture extends Texture {
  13942. isCube: boolean;
  13943. /**
  13944. * Define if the texture is enabled or not (disabled texture will not render)
  13945. */
  13946. isEnabled: boolean;
  13947. /**
  13948. * Define if the texture must be cleared before rendering (default is true)
  13949. */
  13950. autoClear: boolean;
  13951. /**
  13952. * Callback called when the texture is generated
  13953. */
  13954. onGenerated: () => void;
  13955. /**
  13956. * Event raised when the texture is generated
  13957. */
  13958. onGeneratedObservable: Observable<ProceduralTexture>;
  13959. /** @hidden */
  13960. _generateMipMaps: boolean;
  13961. /** @hidden **/
  13962. _effect: Effect;
  13963. /** @hidden */
  13964. _textures: {
  13965. [key: string]: Texture;
  13966. };
  13967. private _size;
  13968. private _currentRefreshId;
  13969. private _refreshRate;
  13970. private _vertexBuffers;
  13971. private _indexBuffer;
  13972. private _uniforms;
  13973. private _samplers;
  13974. private _fragment;
  13975. private _floats;
  13976. private _ints;
  13977. private _floatsArrays;
  13978. private _colors3;
  13979. private _colors4;
  13980. private _vectors2;
  13981. private _vectors3;
  13982. private _matrices;
  13983. private _fallbackTexture;
  13984. private _fallbackTextureUsed;
  13985. private _engine;
  13986. private _cachedDefines;
  13987. private _contentUpdateId;
  13988. private _contentData;
  13989. /**
  13990. * Instantiates a new procedural texture.
  13991. * 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.
  13992. * This is the base class of any Procedural texture and contains most of the shareable code.
  13993. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13994. * @param name Define the name of the texture
  13995. * @param size Define the size of the texture to create
  13996. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13997. * @param scene Define the scene the texture belongs to
  13998. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13999. * @param generateMipMaps Define if the texture should creates mip maps or not
  14000. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14001. */
  14002. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14003. /**
  14004. * The effect that is created when initializing the post process.
  14005. * @returns The created effect corrisponding the the postprocess.
  14006. */
  14007. getEffect(): Effect;
  14008. /**
  14009. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14010. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14011. */
  14012. getContent(): Nullable<ArrayBufferView>;
  14013. private _createIndexBuffer;
  14014. /** @hidden */
  14015. _rebuild(): void;
  14016. /**
  14017. * Resets the texture in order to recreate its associated resources.
  14018. * This can be called in case of context loss
  14019. */
  14020. reset(): void;
  14021. protected _getDefines(): string;
  14022. /**
  14023. * Is the texture ready to be used ? (rendered at least once)
  14024. * @returns true if ready, otherwise, false.
  14025. */
  14026. isReady(): boolean;
  14027. /**
  14028. * Resets the refresh counter of the texture and start bak from scratch.
  14029. * Could be useful to regenerate the texture if it is setup to render only once.
  14030. */
  14031. resetRefreshCounter(): void;
  14032. /**
  14033. * Set the fragment shader to use in order to render the texture.
  14034. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14035. */
  14036. setFragment(fragment: any): void;
  14037. /**
  14038. * Define the refresh rate of the texture or the rendering frequency.
  14039. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14040. */
  14041. refreshRate: number;
  14042. /** @hidden */
  14043. _shouldRender(): boolean;
  14044. /**
  14045. * Get the size the texture is rendering at.
  14046. * @returns the size (texture is always squared)
  14047. */
  14048. getRenderSize(): number;
  14049. /**
  14050. * Resize the texture to new value.
  14051. * @param size Define the new size the texture should have
  14052. * @param generateMipMaps Define whether the new texture should create mip maps
  14053. */
  14054. resize(size: number, generateMipMaps: boolean): void;
  14055. private _checkUniform;
  14056. /**
  14057. * Set a texture in the shader program used to render.
  14058. * @param name Define the name of the uniform samplers as defined in the shader
  14059. * @param texture Define the texture to bind to this sampler
  14060. * @return the texture itself allowing "fluent" like uniform updates
  14061. */
  14062. setTexture(name: string, texture: Texture): ProceduralTexture;
  14063. /**
  14064. * Set a float in the shader.
  14065. * @param name Define the name of the uniform as defined in the shader
  14066. * @param value Define the value to give to the uniform
  14067. * @return the texture itself allowing "fluent" like uniform updates
  14068. */
  14069. setFloat(name: string, value: number): ProceduralTexture;
  14070. /**
  14071. * Set a int in the shader.
  14072. * @param name Define the name of the uniform as defined in the shader
  14073. * @param value Define the value to give to the uniform
  14074. * @return the texture itself allowing "fluent" like uniform updates
  14075. */
  14076. setInt(name: string, value: number): ProceduralTexture;
  14077. /**
  14078. * Set an array of floats in the shader.
  14079. * @param name Define the name of the uniform as defined in the shader
  14080. * @param value Define the value to give to the uniform
  14081. * @return the texture itself allowing "fluent" like uniform updates
  14082. */
  14083. setFloats(name: string, value: number[]): ProceduralTexture;
  14084. /**
  14085. * Set a vec3 in the shader from a Color3.
  14086. * @param name Define the name of the uniform as defined in the shader
  14087. * @param value Define the value to give to the uniform
  14088. * @return the texture itself allowing "fluent" like uniform updates
  14089. */
  14090. setColor3(name: string, value: Color3): ProceduralTexture;
  14091. /**
  14092. * Set a vec4 in the shader from a Color4.
  14093. * @param name Define the name of the uniform as defined in the shader
  14094. * @param value Define the value to give to the uniform
  14095. * @return the texture itself allowing "fluent" like uniform updates
  14096. */
  14097. setColor4(name: string, value: Color4): ProceduralTexture;
  14098. /**
  14099. * Set a vec2 in the shader from a Vector2.
  14100. * @param name Define the name of the uniform as defined in the shader
  14101. * @param value Define the value to give to the uniform
  14102. * @return the texture itself allowing "fluent" like uniform updates
  14103. */
  14104. setVector2(name: string, value: Vector2): ProceduralTexture;
  14105. /**
  14106. * Set a vec3 in the shader from a Vector3.
  14107. * @param name Define the name of the uniform as defined in the shader
  14108. * @param value Define the value to give to the uniform
  14109. * @return the texture itself allowing "fluent" like uniform updates
  14110. */
  14111. setVector3(name: string, value: Vector3): ProceduralTexture;
  14112. /**
  14113. * Set a mat4 in the shader from a MAtrix.
  14114. * @param name Define the name of the uniform as defined in the shader
  14115. * @param value Define the value to give to the uniform
  14116. * @return the texture itself allowing "fluent" like uniform updates
  14117. */
  14118. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14119. /**
  14120. * Render the texture to its associated render target.
  14121. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14122. */
  14123. render(useCameraPostProcess?: boolean): void;
  14124. /**
  14125. * Clone the texture.
  14126. * @returns the cloned texture
  14127. */
  14128. clone(): ProceduralTexture;
  14129. /**
  14130. * Dispose the texture and release its asoociated resources.
  14131. */
  14132. dispose(): void;
  14133. }
  14134. }
  14135. declare module BABYLON {
  14136. /**
  14137. * This represents the base class for particle system in Babylon.
  14138. * 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.
  14139. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14140. * @example https://doc.babylonjs.com/babylon101/particles
  14141. */
  14142. export class BaseParticleSystem {
  14143. /**
  14144. * Source color is added to the destination color without alpha affecting the result
  14145. */
  14146. static BLENDMODE_ONEONE: number;
  14147. /**
  14148. * Blend current color and particle color using particle’s alpha
  14149. */
  14150. static BLENDMODE_STANDARD: number;
  14151. /**
  14152. * Add current color and particle color multiplied by particle’s alpha
  14153. */
  14154. static BLENDMODE_ADD: number;
  14155. /**
  14156. * Multiply current color with particle color
  14157. */
  14158. static BLENDMODE_MULTIPLY: number;
  14159. /**
  14160. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14161. */
  14162. static BLENDMODE_MULTIPLYADD: number;
  14163. /**
  14164. * List of animations used by the particle system.
  14165. */
  14166. animations: Animation[];
  14167. /**
  14168. * The id of the Particle system.
  14169. */
  14170. id: string;
  14171. /**
  14172. * The friendly name of the Particle system.
  14173. */
  14174. name: string;
  14175. /**
  14176. * The rendering group used by the Particle system to chose when to render.
  14177. */
  14178. renderingGroupId: number;
  14179. /**
  14180. * The emitter represents the Mesh or position we are attaching the particle system to.
  14181. */
  14182. emitter: Nullable<AbstractMesh | Vector3>;
  14183. /**
  14184. * The maximum number of particles to emit per frame
  14185. */
  14186. emitRate: number;
  14187. /**
  14188. * If you want to launch only a few particles at once, that can be done, as well.
  14189. */
  14190. manualEmitCount: number;
  14191. /**
  14192. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14193. */
  14194. updateSpeed: number;
  14195. /**
  14196. * The amount of time the particle system is running (depends of the overall update speed).
  14197. */
  14198. targetStopDuration: number;
  14199. /**
  14200. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14201. */
  14202. disposeOnStop: boolean;
  14203. /**
  14204. * Minimum power of emitting particles.
  14205. */
  14206. minEmitPower: number;
  14207. /**
  14208. * Maximum power of emitting particles.
  14209. */
  14210. maxEmitPower: number;
  14211. /**
  14212. * Minimum life time of emitting particles.
  14213. */
  14214. minLifeTime: number;
  14215. /**
  14216. * Maximum life time of emitting particles.
  14217. */
  14218. maxLifeTime: number;
  14219. /**
  14220. * Minimum Size of emitting particles.
  14221. */
  14222. minSize: number;
  14223. /**
  14224. * Maximum Size of emitting particles.
  14225. */
  14226. maxSize: number;
  14227. /**
  14228. * Minimum scale of emitting particles on X axis.
  14229. */
  14230. minScaleX: number;
  14231. /**
  14232. * Maximum scale of emitting particles on X axis.
  14233. */
  14234. maxScaleX: number;
  14235. /**
  14236. * Minimum scale of emitting particles on Y axis.
  14237. */
  14238. minScaleY: number;
  14239. /**
  14240. * Maximum scale of emitting particles on Y axis.
  14241. */
  14242. maxScaleY: number;
  14243. /**
  14244. * Gets or sets the minimal initial rotation in radians.
  14245. */
  14246. minInitialRotation: number;
  14247. /**
  14248. * Gets or sets the maximal initial rotation in radians.
  14249. */
  14250. maxInitialRotation: number;
  14251. /**
  14252. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14253. */
  14254. minAngularSpeed: number;
  14255. /**
  14256. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14257. */
  14258. maxAngularSpeed: number;
  14259. /**
  14260. * The texture used to render each particle. (this can be a spritesheet)
  14261. */
  14262. particleTexture: Nullable<Texture>;
  14263. /**
  14264. * The layer mask we are rendering the particles through.
  14265. */
  14266. layerMask: number;
  14267. /**
  14268. * This can help using your own shader to render the particle system.
  14269. * The according effect will be created
  14270. */
  14271. customShader: any;
  14272. /**
  14273. * By default particle system starts as soon as they are created. This prevents the
  14274. * automatic start to happen and let you decide when to start emitting particles.
  14275. */
  14276. preventAutoStart: boolean;
  14277. private _noiseTexture;
  14278. /**
  14279. * Gets or sets a texture used to add random noise to particle positions
  14280. */
  14281. noiseTexture: Nullable<ProceduralTexture>;
  14282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14283. noiseStrength: Vector3;
  14284. /**
  14285. * Callback triggered when the particle animation is ending.
  14286. */
  14287. onAnimationEnd: Nullable<() => void>;
  14288. /**
  14289. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14290. */
  14291. blendMode: number;
  14292. /**
  14293. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14294. * to override the particles.
  14295. */
  14296. forceDepthWrite: boolean;
  14297. /** 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 */
  14298. preWarmCycles: number;
  14299. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14300. preWarmStepOffset: number;
  14301. /**
  14302. * 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)
  14303. */
  14304. spriteCellChangeSpeed: number;
  14305. /**
  14306. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14307. */
  14308. startSpriteCellID: number;
  14309. /**
  14310. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14311. */
  14312. endSpriteCellID: number;
  14313. /**
  14314. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14315. */
  14316. spriteCellWidth: number;
  14317. /**
  14318. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14319. */
  14320. spriteCellHeight: number;
  14321. /**
  14322. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14323. */
  14324. spriteRandomStartCell: boolean;
  14325. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14326. translationPivot: Vector2;
  14327. /** @hidden */
  14328. protected _isAnimationSheetEnabled: boolean;
  14329. /**
  14330. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14331. */
  14332. beginAnimationOnStart: boolean;
  14333. /**
  14334. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14335. */
  14336. beginAnimationFrom: number;
  14337. /**
  14338. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14339. */
  14340. beginAnimationTo: number;
  14341. /**
  14342. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14343. */
  14344. beginAnimationLoop: boolean;
  14345. /**
  14346. * Gets or sets a world offset applied to all particles
  14347. */
  14348. worldOffset: Vector3;
  14349. /**
  14350. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14351. */
  14352. isAnimationSheetEnabled: boolean;
  14353. /**
  14354. * Get hosting scene
  14355. * @returns the scene
  14356. */
  14357. getScene(): Scene;
  14358. /**
  14359. * You can use gravity if you want to give an orientation to your particles.
  14360. */
  14361. gravity: Vector3;
  14362. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14363. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14364. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14365. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14366. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14367. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14368. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14369. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14370. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14371. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14372. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14373. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14374. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14375. /**
  14376. * Defines the delay in milliseconds before starting the system (0 by default)
  14377. */
  14378. startDelay: number;
  14379. /**
  14380. * Gets the current list of drag gradients.
  14381. * You must use addDragGradient and removeDragGradient to udpate this list
  14382. * @returns the list of drag gradients
  14383. */
  14384. getDragGradients(): Nullable<Array<FactorGradient>>;
  14385. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14386. limitVelocityDamping: number;
  14387. /**
  14388. * Gets the current list of limit velocity gradients.
  14389. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14390. * @returns the list of limit velocity gradients
  14391. */
  14392. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Gets the current list of size gradients.
  14401. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14402. * @returns the list of size gradients
  14403. */
  14404. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14405. /**
  14406. * Gets the current list of color remap gradients.
  14407. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14408. * @returns the list of color remap gradients
  14409. */
  14410. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14411. /**
  14412. * Gets the current list of alpha remap gradients.
  14413. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14414. * @returns the list of alpha remap gradients
  14415. */
  14416. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14417. /**
  14418. * Gets the current list of life time gradients.
  14419. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14420. * @returns the list of life time gradients
  14421. */
  14422. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14423. /**
  14424. * Gets the current list of angular speed gradients.
  14425. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14426. * @returns the list of angular speed gradients
  14427. */
  14428. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14429. /**
  14430. * Gets the current list of velocity gradients.
  14431. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14432. * @returns the list of velocity gradients
  14433. */
  14434. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14435. /**
  14436. * Gets the current list of start size gradients.
  14437. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14438. * @returns the list of start size gradients
  14439. */
  14440. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Gets the current list of emit rate gradients.
  14443. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14444. * @returns the list of emit rate gradients
  14445. */
  14446. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14447. /**
  14448. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14449. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14450. */
  14451. direction1: Vector3;
  14452. /**
  14453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14454. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14455. */
  14456. direction2: Vector3;
  14457. /**
  14458. * 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.
  14459. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14460. */
  14461. minEmitBox: Vector3;
  14462. /**
  14463. * 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.
  14464. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14465. */
  14466. maxEmitBox: Vector3;
  14467. /**
  14468. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14469. */
  14470. color1: Color4;
  14471. /**
  14472. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14473. */
  14474. color2: Color4;
  14475. /**
  14476. * Color the particle will have at the end of its lifetime
  14477. */
  14478. colorDead: Color4;
  14479. /**
  14480. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14481. */
  14482. textureMask: Color4;
  14483. /**
  14484. * The particle emitter type defines the emitter used by the particle system.
  14485. * It can be for example box, sphere, or cone...
  14486. */
  14487. particleEmitterType: IParticleEmitterType;
  14488. /** @hidden */
  14489. _isSubEmitter: boolean;
  14490. /**
  14491. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14492. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14493. */
  14494. billboardMode: number;
  14495. protected _isBillboardBased: boolean;
  14496. /**
  14497. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14498. */
  14499. isBillboardBased: boolean;
  14500. /**
  14501. * The scene the particle system belongs to.
  14502. */
  14503. protected _scene: Scene;
  14504. /**
  14505. * Local cache of defines for image processing.
  14506. */
  14507. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14508. /**
  14509. * Default configuration related to image processing available in the standard Material.
  14510. */
  14511. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14512. /**
  14513. * Gets the image processing configuration used either in this material.
  14514. */
  14515. /**
  14516. * Sets the Default image processing configuration used either in the this material.
  14517. *
  14518. * If sets to null, the scene one is in use.
  14519. */
  14520. imageProcessingConfiguration: ImageProcessingConfiguration;
  14521. /**
  14522. * Attaches a new image processing configuration to the Standard Material.
  14523. * @param configuration
  14524. */
  14525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14526. /** @hidden */
  14527. protected _reset(): void;
  14528. /** @hidden */
  14529. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14530. /**
  14531. * Instantiates a particle system.
  14532. * 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.
  14533. * @param name The name of the particle system
  14534. */
  14535. constructor(name: string);
  14536. /**
  14537. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14540. * @returns the emitter
  14541. */
  14542. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14543. /**
  14544. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14545. * @param radius The radius of the hemisphere to emit from
  14546. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14547. * @returns the emitter
  14548. */
  14549. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14550. /**
  14551. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14552. * @param radius The radius of the sphere to emit from
  14553. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14554. * @returns the emitter
  14555. */
  14556. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14557. /**
  14558. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14559. * @param radius The radius of the sphere to emit from
  14560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14562. * @returns the emitter
  14563. */
  14564. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14565. /**
  14566. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14567. * @param radius The radius of the emission cylinder
  14568. * @param height The height of the emission cylinder
  14569. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14570. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14571. * @returns the emitter
  14572. */
  14573. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14574. /**
  14575. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14576. * @param radius The radius of the cylinder to emit from
  14577. * @param height The height of the emission cylinder
  14578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14581. * @returns the emitter
  14582. */
  14583. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14584. /**
  14585. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14586. * @param radius The radius of the cone to emit from
  14587. * @param angle The base angle of the cone
  14588. * @returns the emitter
  14589. */
  14590. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14591. /**
  14592. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14595. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14596. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14597. * @returns the emitter
  14598. */
  14599. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14600. }
  14601. }
  14602. declare module BABYLON {
  14603. /**
  14604. * Type of sub emitter
  14605. */
  14606. export enum SubEmitterType {
  14607. /**
  14608. * Attached to the particle over it's lifetime
  14609. */
  14610. ATTACHED = 0,
  14611. /**
  14612. * Created when the particle dies
  14613. */
  14614. END = 1
  14615. }
  14616. /**
  14617. * Sub emitter class used to emit particles from an existing particle
  14618. */
  14619. export class SubEmitter {
  14620. /**
  14621. * the particle system to be used by the sub emitter
  14622. */
  14623. particleSystem: ParticleSystem;
  14624. /**
  14625. * Type of the submitter (Default: END)
  14626. */
  14627. type: SubEmitterType;
  14628. /**
  14629. * 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)
  14630. * Note: This only is supported when using an emitter of type Mesh
  14631. */
  14632. inheritDirection: boolean;
  14633. /**
  14634. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14635. */
  14636. inheritedVelocityAmount: number;
  14637. /**
  14638. * Creates a sub emitter
  14639. * @param particleSystem the particle system to be used by the sub emitter
  14640. */
  14641. constructor(
  14642. /**
  14643. * the particle system to be used by the sub emitter
  14644. */
  14645. particleSystem: ParticleSystem);
  14646. /**
  14647. * Clones the sub emitter
  14648. * @returns the cloned sub emitter
  14649. */
  14650. clone(): SubEmitter;
  14651. /**
  14652. * Serialize current object to a JSON object
  14653. * @returns the serialized object
  14654. */
  14655. serialize(): any;
  14656. /** @hidden */
  14657. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14658. /**
  14659. * Creates a new SubEmitter from a serialized JSON version
  14660. * @param serializationObject defines the JSON object to read from
  14661. * @param scene defines the hosting scene
  14662. * @param rootUrl defines the rootUrl for data loading
  14663. * @returns a new SubEmitter
  14664. */
  14665. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14666. /** Release associated resources */
  14667. dispose(): void;
  14668. }
  14669. }
  14670. declare module BABYLON {
  14671. /** @hidden */
  14672. export var clipPlaneFragmentDeclaration: {
  14673. name: string;
  14674. shader: string;
  14675. };
  14676. }
  14677. declare module BABYLON {
  14678. /** @hidden */
  14679. export var imageProcessingDeclaration: {
  14680. name: string;
  14681. shader: string;
  14682. };
  14683. }
  14684. declare module BABYLON {
  14685. /** @hidden */
  14686. export var imageProcessingFunctions: {
  14687. name: string;
  14688. shader: string;
  14689. };
  14690. }
  14691. declare module BABYLON {
  14692. /** @hidden */
  14693. export var clipPlaneFragment: {
  14694. name: string;
  14695. shader: string;
  14696. };
  14697. }
  14698. declare module BABYLON {
  14699. /** @hidden */
  14700. export var particlesPixelShader: {
  14701. name: string;
  14702. shader: string;
  14703. };
  14704. }
  14705. declare module BABYLON {
  14706. /** @hidden */
  14707. export var clipPlaneVertexDeclaration: {
  14708. name: string;
  14709. shader: string;
  14710. };
  14711. }
  14712. declare module BABYLON {
  14713. /** @hidden */
  14714. export var clipPlaneVertex: {
  14715. name: string;
  14716. shader: string;
  14717. };
  14718. }
  14719. declare module BABYLON {
  14720. /** @hidden */
  14721. export var particlesVertexShader: {
  14722. name: string;
  14723. shader: string;
  14724. };
  14725. }
  14726. declare module BABYLON {
  14727. /**
  14728. * This represents a particle system in Babylon.
  14729. * 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.
  14730. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14731. * @example https://doc.babylonjs.com/babylon101/particles
  14732. */
  14733. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14734. /**
  14735. * Billboard mode will only apply to Y axis
  14736. */
  14737. static readonly BILLBOARDMODE_Y: number;
  14738. /**
  14739. * Billboard mode will apply to all axes
  14740. */
  14741. static readonly BILLBOARDMODE_ALL: number;
  14742. /**
  14743. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14744. */
  14745. static readonly BILLBOARDMODE_STRETCHED: number;
  14746. /**
  14747. * This function can be defined to provide custom update for active particles.
  14748. * This function will be called instead of regular update (age, position, color, etc.).
  14749. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14750. */
  14751. updateFunction: (particles: Particle[]) => void;
  14752. private _emitterWorldMatrix;
  14753. /**
  14754. * This function can be defined to specify initial direction for every new particle.
  14755. * It by default use the emitterType defined function
  14756. */
  14757. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14758. /**
  14759. * This function can be defined to specify initial position for every new particle.
  14760. * It by default use the emitterType defined function
  14761. */
  14762. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14763. /**
  14764. * @hidden
  14765. */
  14766. _inheritedVelocityOffset: Vector3;
  14767. /**
  14768. * An event triggered when the system is disposed
  14769. */
  14770. onDisposeObservable: Observable<ParticleSystem>;
  14771. private _onDisposeObserver;
  14772. /**
  14773. * Sets a callback that will be triggered when the system is disposed
  14774. */
  14775. onDispose: () => void;
  14776. private _particles;
  14777. private _epsilon;
  14778. private _capacity;
  14779. private _stockParticles;
  14780. private _newPartsExcess;
  14781. private _vertexData;
  14782. private _vertexBuffer;
  14783. private _vertexBuffers;
  14784. private _spriteBuffer;
  14785. private _indexBuffer;
  14786. private _effect;
  14787. private _customEffect;
  14788. private _cachedDefines;
  14789. private _scaledColorStep;
  14790. private _colorDiff;
  14791. private _scaledDirection;
  14792. private _scaledGravity;
  14793. private _currentRenderId;
  14794. private _alive;
  14795. private _useInstancing;
  14796. private _started;
  14797. private _stopped;
  14798. private _actualFrame;
  14799. private _scaledUpdateSpeed;
  14800. private _vertexBufferSize;
  14801. /** @hidden */
  14802. _currentEmitRateGradient: Nullable<FactorGradient>;
  14803. /** @hidden */
  14804. _currentEmitRate1: number;
  14805. /** @hidden */
  14806. _currentEmitRate2: number;
  14807. /** @hidden */
  14808. _currentStartSizeGradient: Nullable<FactorGradient>;
  14809. /** @hidden */
  14810. _currentStartSize1: number;
  14811. /** @hidden */
  14812. _currentStartSize2: number;
  14813. private readonly _rawTextureWidth;
  14814. private _rampGradientsTexture;
  14815. private _useRampGradients;
  14816. /** Gets or sets a boolean indicating that ramp gradients must be used
  14817. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14818. */
  14819. useRampGradients: boolean;
  14820. /**
  14821. * 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.
  14822. * 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: [])
  14823. */
  14824. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14825. private _subEmitters;
  14826. /**
  14827. * @hidden
  14828. * If the particle systems emitter should be disposed when the particle system is disposed
  14829. */
  14830. _disposeEmitterOnDispose: boolean;
  14831. /**
  14832. * The current active Sub-systems, this property is used by the root particle system only.
  14833. */
  14834. activeSubSystems: Array<ParticleSystem>;
  14835. private _rootParticleSystem;
  14836. /**
  14837. * Gets the current list of active particles
  14838. */
  14839. readonly particles: Particle[];
  14840. /**
  14841. * Returns the string "ParticleSystem"
  14842. * @returns a string containing the class name
  14843. */
  14844. getClassName(): string;
  14845. /**
  14846. * Instantiates a particle system.
  14847. * 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.
  14848. * @param name The name of the particle system
  14849. * @param capacity The max number of particles alive at the same time
  14850. * @param scene The scene the particle system belongs to
  14851. * @param customEffect a custom effect used to change the way particles are rendered by default
  14852. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14853. * @param epsilon Offset used to render the particles
  14854. */
  14855. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14856. private _addFactorGradient;
  14857. private _removeFactorGradient;
  14858. /**
  14859. * Adds a new life time gradient
  14860. * @param gradient defines the gradient to use (between 0 and 1)
  14861. * @param factor defines the life time factor to affect to the specified gradient
  14862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14863. * @returns the current particle system
  14864. */
  14865. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14866. /**
  14867. * Remove a specific life time gradient
  14868. * @param gradient defines the gradient to remove
  14869. * @returns the current particle system
  14870. */
  14871. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14872. /**
  14873. * Adds a new size gradient
  14874. * @param gradient defines the gradient to use (between 0 and 1)
  14875. * @param factor defines the size factor to affect to the specified gradient
  14876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14877. * @returns the current particle system
  14878. */
  14879. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14880. /**
  14881. * Remove a specific size gradient
  14882. * @param gradient defines the gradient to remove
  14883. * @returns the current particle system
  14884. */
  14885. removeSizeGradient(gradient: number): IParticleSystem;
  14886. /**
  14887. * Adds a new color remap gradient
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param min defines the color remap minimal range
  14890. * @param max defines the color remap maximal range
  14891. * @returns the current particle system
  14892. */
  14893. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific color remap gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeColorRemapGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Adds a new alpha remap gradient
  14902. * @param gradient defines the gradient to use (between 0 and 1)
  14903. * @param min defines the alpha remap minimal range
  14904. * @param max defines the alpha remap maximal range
  14905. * @returns the current particle system
  14906. */
  14907. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14908. /**
  14909. * Remove a specific alpha remap gradient
  14910. * @param gradient defines the gradient to remove
  14911. * @returns the current particle system
  14912. */
  14913. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14914. /**
  14915. * Adds a new angular speed gradient
  14916. * @param gradient defines the gradient to use (between 0 and 1)
  14917. * @param factor defines the angular speed to affect to the specified gradient
  14918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14919. * @returns the current particle system
  14920. */
  14921. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14922. /**
  14923. * Remove a specific angular speed gradient
  14924. * @param gradient defines the gradient to remove
  14925. * @returns the current particle system
  14926. */
  14927. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14928. /**
  14929. * Adds a new velocity gradient
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param factor defines the velocity to affect to the specified gradient
  14932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14933. * @returns the current particle system
  14934. */
  14935. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14936. /**
  14937. * Remove a specific velocity gradient
  14938. * @param gradient defines the gradient to remove
  14939. * @returns the current particle system
  14940. */
  14941. removeVelocityGradient(gradient: number): IParticleSystem;
  14942. /**
  14943. * Adds a new limit velocity gradient
  14944. * @param gradient defines the gradient to use (between 0 and 1)
  14945. * @param factor defines the limit velocity value to affect to the specified gradient
  14946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14947. * @returns the current particle system
  14948. */
  14949. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14950. /**
  14951. * Remove a specific limit velocity gradient
  14952. * @param gradient defines the gradient to remove
  14953. * @returns the current particle system
  14954. */
  14955. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14956. /**
  14957. * Adds a new drag gradient
  14958. * @param gradient defines the gradient to use (between 0 and 1)
  14959. * @param factor defines the drag value to affect to the specified gradient
  14960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14961. * @returns the current particle system
  14962. */
  14963. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14964. /**
  14965. * Remove a specific drag gradient
  14966. * @param gradient defines the gradient to remove
  14967. * @returns the current particle system
  14968. */
  14969. removeDragGradient(gradient: number): IParticleSystem;
  14970. /**
  14971. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14972. * @param gradient defines the gradient to use (between 0 and 1)
  14973. * @param factor defines the emit rate value to affect to the specified gradient
  14974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14975. * @returns the current particle system
  14976. */
  14977. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14978. /**
  14979. * Remove a specific emit rate gradient
  14980. * @param gradient defines the gradient to remove
  14981. * @returns the current particle system
  14982. */
  14983. removeEmitRateGradient(gradient: number): IParticleSystem;
  14984. /**
  14985. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14986. * @param gradient defines the gradient to use (between 0 and 1)
  14987. * @param factor defines the start size value to affect to the specified gradient
  14988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14989. * @returns the current particle system
  14990. */
  14991. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14992. /**
  14993. * Remove a specific start size gradient
  14994. * @param gradient defines the gradient to remove
  14995. * @returns the current particle system
  14996. */
  14997. removeStartSizeGradient(gradient: number): IParticleSystem;
  14998. private _createRampGradientTexture;
  14999. /**
  15000. * Gets the current list of ramp gradients.
  15001. * You must use addRampGradient and removeRampGradient to udpate this list
  15002. * @returns the list of ramp gradients
  15003. */
  15004. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15005. /**
  15006. * Adds a new ramp gradient used to remap particle colors
  15007. * @param gradient defines the gradient to use (between 0 and 1)
  15008. * @param color defines the color to affect to the specified gradient
  15009. * @returns the current particle system
  15010. */
  15011. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15012. /**
  15013. * Remove a specific ramp gradient
  15014. * @param gradient defines the gradient to remove
  15015. * @returns the current particle system
  15016. */
  15017. removeRampGradient(gradient: number): ParticleSystem;
  15018. /**
  15019. * Adds a new color gradient
  15020. * @param gradient defines the gradient to use (between 0 and 1)
  15021. * @param color1 defines the color to affect to the specified gradient
  15022. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15023. * @returns this particle system
  15024. */
  15025. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15026. /**
  15027. * Remove a specific color gradient
  15028. * @param gradient defines the gradient to remove
  15029. * @returns this particle system
  15030. */
  15031. removeColorGradient(gradient: number): IParticleSystem;
  15032. private _fetchR;
  15033. protected _reset(): void;
  15034. private _resetEffect;
  15035. private _createVertexBuffers;
  15036. private _createIndexBuffer;
  15037. /**
  15038. * Gets the maximum number of particles active at the same time.
  15039. * @returns The max number of active particles.
  15040. */
  15041. getCapacity(): number;
  15042. /**
  15043. * Gets whether there are still active particles in the system.
  15044. * @returns True if it is alive, otherwise false.
  15045. */
  15046. isAlive(): boolean;
  15047. /**
  15048. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15049. * @returns True if it has been started, otherwise false.
  15050. */
  15051. isStarted(): boolean;
  15052. private _prepareSubEmitterInternalArray;
  15053. /**
  15054. * Starts the particle system and begins to emit
  15055. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15056. */
  15057. start(delay?: number): void;
  15058. /**
  15059. * Stops the particle system.
  15060. * @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.
  15061. */
  15062. stop(stopSubEmitters?: boolean): void;
  15063. /**
  15064. * Remove all active particles
  15065. */
  15066. reset(): void;
  15067. /**
  15068. * @hidden (for internal use only)
  15069. */
  15070. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15071. /**
  15072. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15073. * Its lifetime will start back at 0.
  15074. */
  15075. recycleParticle: (particle: Particle) => void;
  15076. private _stopSubEmitters;
  15077. private _createParticle;
  15078. private _removeFromRoot;
  15079. private _emitFromParticle;
  15080. private _update;
  15081. /** @hidden */
  15082. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15083. /** @hidden */
  15084. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15085. /** @hidden */
  15086. private _getEffect;
  15087. /**
  15088. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15089. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15090. */
  15091. animate(preWarmOnly?: boolean): void;
  15092. private _appendParticleVertices;
  15093. /**
  15094. * Rebuilds the particle system.
  15095. */
  15096. rebuild(): void;
  15097. /**
  15098. * Is this system ready to be used/rendered
  15099. * @return true if the system is ready
  15100. */
  15101. isReady(): boolean;
  15102. private _render;
  15103. /**
  15104. * Renders the particle system in its current state.
  15105. * @returns the current number of particles
  15106. */
  15107. render(): number;
  15108. /**
  15109. * Disposes the particle system and free the associated resources
  15110. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15111. */
  15112. dispose(disposeTexture?: boolean): void;
  15113. /**
  15114. * Clones the particle system.
  15115. * @param name The name of the cloned object
  15116. * @param newEmitter The new emitter to use
  15117. * @returns the cloned particle system
  15118. */
  15119. clone(name: string, newEmitter: any): ParticleSystem;
  15120. /**
  15121. * Serializes the particle system to a JSON object.
  15122. * @returns the JSON object
  15123. */
  15124. serialize(): any;
  15125. /** @hidden */
  15126. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15127. /** @hidden */
  15128. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15129. /**
  15130. * Parses a JSON object to create a particle system.
  15131. * @param parsedParticleSystem The JSON object to parse
  15132. * @param scene The scene to create the particle system in
  15133. * @param rootUrl The root url to use to load external dependencies like texture
  15134. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15135. * @returns the Parsed particle system
  15136. */
  15137. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15138. }
  15139. }
  15140. declare module BABYLON {
  15141. /**
  15142. * A particle represents one of the element emitted by a particle system.
  15143. * This is mainly define by its coordinates, direction, velocity and age.
  15144. */
  15145. export class Particle {
  15146. /**
  15147. * The particle system the particle belongs to.
  15148. */
  15149. particleSystem: ParticleSystem;
  15150. private static _Count;
  15151. /**
  15152. * Unique ID of the particle
  15153. */
  15154. id: number;
  15155. /**
  15156. * The world position of the particle in the scene.
  15157. */
  15158. position: Vector3;
  15159. /**
  15160. * The world direction of the particle in the scene.
  15161. */
  15162. direction: Vector3;
  15163. /**
  15164. * The color of the particle.
  15165. */
  15166. color: Color4;
  15167. /**
  15168. * The color change of the particle per step.
  15169. */
  15170. colorStep: Color4;
  15171. /**
  15172. * Defines how long will the life of the particle be.
  15173. */
  15174. lifeTime: number;
  15175. /**
  15176. * The current age of the particle.
  15177. */
  15178. age: number;
  15179. /**
  15180. * The current size of the particle.
  15181. */
  15182. size: number;
  15183. /**
  15184. * The current scale of the particle.
  15185. */
  15186. scale: Vector2;
  15187. /**
  15188. * The current angle of the particle.
  15189. */
  15190. angle: number;
  15191. /**
  15192. * Defines how fast is the angle changing.
  15193. */
  15194. angularSpeed: number;
  15195. /**
  15196. * Defines the cell index used by the particle to be rendered from a sprite.
  15197. */
  15198. cellIndex: number;
  15199. /**
  15200. * The information required to support color remapping
  15201. */
  15202. remapData: Vector4;
  15203. /** @hidden */
  15204. _randomCellOffset?: number;
  15205. /** @hidden */
  15206. _initialDirection: Nullable<Vector3>;
  15207. /** @hidden */
  15208. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15209. /** @hidden */
  15210. _initialStartSpriteCellID: number;
  15211. /** @hidden */
  15212. _initialEndSpriteCellID: number;
  15213. /** @hidden */
  15214. _currentColorGradient: Nullable<ColorGradient>;
  15215. /** @hidden */
  15216. _currentColor1: Color4;
  15217. /** @hidden */
  15218. _currentColor2: Color4;
  15219. /** @hidden */
  15220. _currentSizeGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentSize1: number;
  15223. /** @hidden */
  15224. _currentSize2: number;
  15225. /** @hidden */
  15226. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentAngularSpeed1: number;
  15229. /** @hidden */
  15230. _currentAngularSpeed2: number;
  15231. /** @hidden */
  15232. _currentVelocityGradient: Nullable<FactorGradient>;
  15233. /** @hidden */
  15234. _currentVelocity1: number;
  15235. /** @hidden */
  15236. _currentVelocity2: number;
  15237. /** @hidden */
  15238. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15239. /** @hidden */
  15240. _currentLimitVelocity1: number;
  15241. /** @hidden */
  15242. _currentLimitVelocity2: number;
  15243. /** @hidden */
  15244. _currentDragGradient: Nullable<FactorGradient>;
  15245. /** @hidden */
  15246. _currentDrag1: number;
  15247. /** @hidden */
  15248. _currentDrag2: number;
  15249. /** @hidden */
  15250. _randomNoiseCoordinates1: Vector3;
  15251. /** @hidden */
  15252. _randomNoiseCoordinates2: Vector3;
  15253. /**
  15254. * Creates a new instance Particle
  15255. * @param particleSystem the particle system the particle belongs to
  15256. */
  15257. constructor(
  15258. /**
  15259. * The particle system the particle belongs to.
  15260. */
  15261. particleSystem: ParticleSystem);
  15262. private updateCellInfoFromSystem;
  15263. /**
  15264. * Defines how the sprite cell index is updated for the particle
  15265. */
  15266. updateCellIndex(): void;
  15267. /** @hidden */
  15268. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15269. /** @hidden */
  15270. _inheritParticleInfoToSubEmitters(): void;
  15271. /** @hidden */
  15272. _reset(): void;
  15273. /**
  15274. * Copy the properties of particle to another one.
  15275. * @param other the particle to copy the information to.
  15276. */
  15277. copyTo(other: Particle): void;
  15278. }
  15279. }
  15280. declare module BABYLON {
  15281. /**
  15282. * Particle emitter represents a volume emitting particles.
  15283. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15284. */
  15285. export interface IParticleEmitterType {
  15286. /**
  15287. * Called by the particle System when the direction is computed for the created particle.
  15288. * @param worldMatrix is the world matrix of the particle system
  15289. * @param directionToUpdate is the direction vector to update with the result
  15290. * @param particle is the particle we are computed the direction for
  15291. */
  15292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15293. /**
  15294. * Called by the particle System when the position is computed for the created particle.
  15295. * @param worldMatrix is the world matrix of the particle system
  15296. * @param positionToUpdate is the position vector to update with the result
  15297. * @param particle is the particle we are computed the position for
  15298. */
  15299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15300. /**
  15301. * Clones the current emitter and returns a copy of it
  15302. * @returns the new emitter
  15303. */
  15304. clone(): IParticleEmitterType;
  15305. /**
  15306. * Called by the GPUParticleSystem to setup the update shader
  15307. * @param effect defines the update shader
  15308. */
  15309. applyToShader(effect: Effect): void;
  15310. /**
  15311. * Returns a string to use to update the GPU particles update shader
  15312. * @returns the effect defines string
  15313. */
  15314. getEffectDefines(): string;
  15315. /**
  15316. * Returns a string representing the class name
  15317. * @returns a string containing the class name
  15318. */
  15319. getClassName(): string;
  15320. /**
  15321. * Serializes the particle system to a JSON object.
  15322. * @returns the JSON object
  15323. */
  15324. serialize(): any;
  15325. /**
  15326. * Parse properties from a JSON object
  15327. * @param serializationObject defines the JSON object
  15328. */
  15329. parse(serializationObject: any): void;
  15330. }
  15331. }
  15332. declare module BABYLON {
  15333. /**
  15334. * Particle emitter emitting particles from the inside of a box.
  15335. * It emits the particles randomly between 2 given directions.
  15336. */
  15337. export class BoxParticleEmitter implements IParticleEmitterType {
  15338. /**
  15339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15340. */
  15341. direction1: Vector3;
  15342. /**
  15343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15344. */
  15345. direction2: Vector3;
  15346. /**
  15347. * 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.
  15348. */
  15349. minEmitBox: Vector3;
  15350. /**
  15351. * 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.
  15352. */
  15353. maxEmitBox: Vector3;
  15354. /**
  15355. * Creates a new instance BoxParticleEmitter
  15356. */
  15357. constructor();
  15358. /**
  15359. * Called by the particle System when the direction is computed for the created particle.
  15360. * @param worldMatrix is the world matrix of the particle system
  15361. * @param directionToUpdate is the direction vector to update with the result
  15362. * @param particle is the particle we are computed the direction for
  15363. */
  15364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15365. /**
  15366. * Called by the particle System when the position is computed for the created particle.
  15367. * @param worldMatrix is the world matrix of the particle system
  15368. * @param positionToUpdate is the position vector to update with the result
  15369. * @param particle is the particle we are computed the position for
  15370. */
  15371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15372. /**
  15373. * Clones the current emitter and returns a copy of it
  15374. * @returns the new emitter
  15375. */
  15376. clone(): BoxParticleEmitter;
  15377. /**
  15378. * Called by the GPUParticleSystem to setup the update shader
  15379. * @param effect defines the update shader
  15380. */
  15381. applyToShader(effect: Effect): void;
  15382. /**
  15383. * Returns a string to use to update the GPU particles update shader
  15384. * @returns a string containng the defines string
  15385. */
  15386. getEffectDefines(): string;
  15387. /**
  15388. * Returns the string "BoxParticleEmitter"
  15389. * @returns a string containing the class name
  15390. */
  15391. getClassName(): string;
  15392. /**
  15393. * Serializes the particle system to a JSON object.
  15394. * @returns the JSON object
  15395. */
  15396. serialize(): any;
  15397. /**
  15398. * Parse properties from a JSON object
  15399. * @param serializationObject defines the JSON object
  15400. */
  15401. parse(serializationObject: any): void;
  15402. }
  15403. }
  15404. declare module BABYLON {
  15405. /**
  15406. * Particle emitter emitting particles from the inside of a cone.
  15407. * It emits the particles alongside the cone volume from the base to the particle.
  15408. * The emission direction might be randomized.
  15409. */
  15410. export class ConeParticleEmitter implements IParticleEmitterType {
  15411. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15412. directionRandomizer: number;
  15413. private _radius;
  15414. private _angle;
  15415. private _height;
  15416. /**
  15417. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15418. */
  15419. radiusRange: number;
  15420. /**
  15421. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15422. */
  15423. heightRange: number;
  15424. /**
  15425. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15426. */
  15427. emitFromSpawnPointOnly: boolean;
  15428. /**
  15429. * Gets or sets the radius of the emission cone
  15430. */
  15431. radius: number;
  15432. /**
  15433. * Gets or sets the angle of the emission cone
  15434. */
  15435. angle: number;
  15436. private _buildHeight;
  15437. /**
  15438. * Creates a new instance ConeParticleEmitter
  15439. * @param radius the radius of the emission cone (1 by default)
  15440. * @param angle the cone base angle (PI by default)
  15441. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15442. */
  15443. constructor(radius?: number, angle?: number,
  15444. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15445. directionRandomizer?: number);
  15446. /**
  15447. * Called by the particle System when the direction is computed for the created particle.
  15448. * @param worldMatrix is the world matrix of the particle system
  15449. * @param directionToUpdate is the direction vector to update with the result
  15450. * @param particle is the particle we are computed the direction for
  15451. */
  15452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15453. /**
  15454. * Called by the particle System when the position is computed for the created particle.
  15455. * @param worldMatrix is the world matrix of the particle system
  15456. * @param positionToUpdate is the position vector to update with the result
  15457. * @param particle is the particle we are computed the position for
  15458. */
  15459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15460. /**
  15461. * Clones the current emitter and returns a copy of it
  15462. * @returns the new emitter
  15463. */
  15464. clone(): ConeParticleEmitter;
  15465. /**
  15466. * Called by the GPUParticleSystem to setup the update shader
  15467. * @param effect defines the update shader
  15468. */
  15469. applyToShader(effect: Effect): void;
  15470. /**
  15471. * Returns a string to use to update the GPU particles update shader
  15472. * @returns a string containng the defines string
  15473. */
  15474. getEffectDefines(): string;
  15475. /**
  15476. * Returns the string "ConeParticleEmitter"
  15477. * @returns a string containing the class name
  15478. */
  15479. getClassName(): string;
  15480. /**
  15481. * Serializes the particle system to a JSON object.
  15482. * @returns the JSON object
  15483. */
  15484. serialize(): any;
  15485. /**
  15486. * Parse properties from a JSON object
  15487. * @param serializationObject defines the JSON object
  15488. */
  15489. parse(serializationObject: any): void;
  15490. }
  15491. }
  15492. declare module BABYLON {
  15493. /**
  15494. * Particle emitter emitting particles from the inside of a cylinder.
  15495. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15496. */
  15497. export class CylinderParticleEmitter implements IParticleEmitterType {
  15498. /**
  15499. * The radius of the emission cylinder.
  15500. */
  15501. radius: number;
  15502. /**
  15503. * The height of the emission cylinder.
  15504. */
  15505. height: number;
  15506. /**
  15507. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15508. */
  15509. radiusRange: number;
  15510. /**
  15511. * How much to randomize the particle direction [0-1].
  15512. */
  15513. directionRandomizer: number;
  15514. /**
  15515. * Creates a new instance CylinderParticleEmitter
  15516. * @param radius the radius of the emission cylinder (1 by default)
  15517. * @param height the height of the emission cylinder (1 by default)
  15518. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15519. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15520. */
  15521. constructor(
  15522. /**
  15523. * The radius of the emission cylinder.
  15524. */
  15525. radius?: number,
  15526. /**
  15527. * The height of the emission cylinder.
  15528. */
  15529. height?: number,
  15530. /**
  15531. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15532. */
  15533. radiusRange?: number,
  15534. /**
  15535. * How much to randomize the particle direction [0-1].
  15536. */
  15537. directionRandomizer?: number);
  15538. /**
  15539. * Called by the particle System when the direction is computed for the created particle.
  15540. * @param worldMatrix is the world matrix of the particle system
  15541. * @param directionToUpdate is the direction vector to update with the result
  15542. * @param particle is the particle we are computed the direction for
  15543. */
  15544. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15545. /**
  15546. * Called by the particle System when the position is computed for the created particle.
  15547. * @param worldMatrix is the world matrix of the particle system
  15548. * @param positionToUpdate is the position vector to update with the result
  15549. * @param particle is the particle we are computed the position for
  15550. */
  15551. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15552. /**
  15553. * Clones the current emitter and returns a copy of it
  15554. * @returns the new emitter
  15555. */
  15556. clone(): CylinderParticleEmitter;
  15557. /**
  15558. * Called by the GPUParticleSystem to setup the update shader
  15559. * @param effect defines the update shader
  15560. */
  15561. applyToShader(effect: Effect): void;
  15562. /**
  15563. * Returns a string to use to update the GPU particles update shader
  15564. * @returns a string containng the defines string
  15565. */
  15566. getEffectDefines(): string;
  15567. /**
  15568. * Returns the string "CylinderParticleEmitter"
  15569. * @returns a string containing the class name
  15570. */
  15571. getClassName(): string;
  15572. /**
  15573. * Serializes the particle system to a JSON object.
  15574. * @returns the JSON object
  15575. */
  15576. serialize(): any;
  15577. /**
  15578. * Parse properties from a JSON object
  15579. * @param serializationObject defines the JSON object
  15580. */
  15581. parse(serializationObject: any): void;
  15582. }
  15583. /**
  15584. * Particle emitter emitting particles from the inside of a cylinder.
  15585. * It emits the particles randomly between two vectors.
  15586. */
  15587. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15588. /**
  15589. * The min limit of the emission direction.
  15590. */
  15591. direction1: Vector3;
  15592. /**
  15593. * The max limit of the emission direction.
  15594. */
  15595. direction2: Vector3;
  15596. /**
  15597. * Creates a new instance CylinderDirectedParticleEmitter
  15598. * @param radius the radius of the emission cylinder (1 by default)
  15599. * @param height the height of the emission cylinder (1 by default)
  15600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15601. * @param direction1 the min limit of the emission direction (up vector by default)
  15602. * @param direction2 the max limit of the emission direction (up vector by default)
  15603. */
  15604. constructor(radius?: number, height?: number, radiusRange?: number,
  15605. /**
  15606. * The min limit of the emission direction.
  15607. */
  15608. direction1?: Vector3,
  15609. /**
  15610. * The max limit of the emission direction.
  15611. */
  15612. direction2?: Vector3);
  15613. /**
  15614. * Called by the particle System when the direction is computed for the created particle.
  15615. * @param worldMatrix is the world matrix of the particle system
  15616. * @param directionToUpdate is the direction vector to update with the result
  15617. * @param particle is the particle we are computed the direction for
  15618. */
  15619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15620. /**
  15621. * Clones the current emitter and returns a copy of it
  15622. * @returns the new emitter
  15623. */
  15624. clone(): CylinderDirectedParticleEmitter;
  15625. /**
  15626. * Called by the GPUParticleSystem to setup the update shader
  15627. * @param effect defines the update shader
  15628. */
  15629. applyToShader(effect: Effect): void;
  15630. /**
  15631. * Returns a string to use to update the GPU particles update shader
  15632. * @returns a string containng the defines string
  15633. */
  15634. getEffectDefines(): string;
  15635. /**
  15636. * Returns the string "CylinderDirectedParticleEmitter"
  15637. * @returns a string containing the class name
  15638. */
  15639. getClassName(): string;
  15640. /**
  15641. * Serializes the particle system to a JSON object.
  15642. * @returns the JSON object
  15643. */
  15644. serialize(): any;
  15645. /**
  15646. * Parse properties from a JSON object
  15647. * @param serializationObject defines the JSON object
  15648. */
  15649. parse(serializationObject: any): void;
  15650. }
  15651. }
  15652. declare module BABYLON {
  15653. /**
  15654. * Particle emitter emitting particles from the inside of a hemisphere.
  15655. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15656. */
  15657. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15658. /**
  15659. * The radius of the emission hemisphere.
  15660. */
  15661. radius: number;
  15662. /**
  15663. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15664. */
  15665. radiusRange: number;
  15666. /**
  15667. * How much to randomize the particle direction [0-1].
  15668. */
  15669. directionRandomizer: number;
  15670. /**
  15671. * Creates a new instance HemisphericParticleEmitter
  15672. * @param radius the radius of the emission hemisphere (1 by default)
  15673. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15674. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15675. */
  15676. constructor(
  15677. /**
  15678. * The radius of the emission hemisphere.
  15679. */
  15680. radius?: number,
  15681. /**
  15682. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15683. */
  15684. radiusRange?: number,
  15685. /**
  15686. * How much to randomize the particle direction [0-1].
  15687. */
  15688. directionRandomizer?: number);
  15689. /**
  15690. * Called by the particle System when the direction is computed for the created particle.
  15691. * @param worldMatrix is the world matrix of the particle system
  15692. * @param directionToUpdate is the direction vector to update with the result
  15693. * @param particle is the particle we are computed the direction for
  15694. */
  15695. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15696. /**
  15697. * Called by the particle System when the position is computed for the created particle.
  15698. * @param worldMatrix is the world matrix of the particle system
  15699. * @param positionToUpdate is the position vector to update with the result
  15700. * @param particle is the particle we are computed the position for
  15701. */
  15702. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15703. /**
  15704. * Clones the current emitter and returns a copy of it
  15705. * @returns the new emitter
  15706. */
  15707. clone(): HemisphericParticleEmitter;
  15708. /**
  15709. * Called by the GPUParticleSystem to setup the update shader
  15710. * @param effect defines the update shader
  15711. */
  15712. applyToShader(effect: Effect): void;
  15713. /**
  15714. * Returns a string to use to update the GPU particles update shader
  15715. * @returns a string containng the defines string
  15716. */
  15717. getEffectDefines(): string;
  15718. /**
  15719. * Returns the string "HemisphericParticleEmitter"
  15720. * @returns a string containing the class name
  15721. */
  15722. getClassName(): string;
  15723. /**
  15724. * Serializes the particle system to a JSON object.
  15725. * @returns the JSON object
  15726. */
  15727. serialize(): any;
  15728. /**
  15729. * Parse properties from a JSON object
  15730. * @param serializationObject defines the JSON object
  15731. */
  15732. parse(serializationObject: any): void;
  15733. }
  15734. }
  15735. declare module BABYLON {
  15736. /**
  15737. * Particle emitter emitting particles from a point.
  15738. * It emits the particles randomly between 2 given directions.
  15739. */
  15740. export class PointParticleEmitter implements IParticleEmitterType {
  15741. /**
  15742. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15743. */
  15744. direction1: Vector3;
  15745. /**
  15746. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15747. */
  15748. direction2: Vector3;
  15749. /**
  15750. * Creates a new instance PointParticleEmitter
  15751. */
  15752. constructor();
  15753. /**
  15754. * Called by the particle System when the direction is computed for the created particle.
  15755. * @param worldMatrix is the world matrix of the particle system
  15756. * @param directionToUpdate is the direction vector to update with the result
  15757. * @param particle is the particle we are computed the direction for
  15758. */
  15759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15760. /**
  15761. * Called by the particle System when the position is computed for the created particle.
  15762. * @param worldMatrix is the world matrix of the particle system
  15763. * @param positionToUpdate is the position vector to update with the result
  15764. * @param particle is the particle we are computed the position for
  15765. */
  15766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15767. /**
  15768. * Clones the current emitter and returns a copy of it
  15769. * @returns the new emitter
  15770. */
  15771. clone(): PointParticleEmitter;
  15772. /**
  15773. * Called by the GPUParticleSystem to setup the update shader
  15774. * @param effect defines the update shader
  15775. */
  15776. applyToShader(effect: Effect): void;
  15777. /**
  15778. * Returns a string to use to update the GPU particles update shader
  15779. * @returns a string containng the defines string
  15780. */
  15781. getEffectDefines(): string;
  15782. /**
  15783. * Returns the string "PointParticleEmitter"
  15784. * @returns a string containing the class name
  15785. */
  15786. getClassName(): string;
  15787. /**
  15788. * Serializes the particle system to a JSON object.
  15789. * @returns the JSON object
  15790. */
  15791. serialize(): any;
  15792. /**
  15793. * Parse properties from a JSON object
  15794. * @param serializationObject defines the JSON object
  15795. */
  15796. parse(serializationObject: any): void;
  15797. }
  15798. }
  15799. declare module BABYLON {
  15800. /**
  15801. * Particle emitter emitting particles from the inside of a sphere.
  15802. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15803. */
  15804. export class SphereParticleEmitter implements IParticleEmitterType {
  15805. /**
  15806. * The radius of the emission sphere.
  15807. */
  15808. radius: number;
  15809. /**
  15810. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15811. */
  15812. radiusRange: number;
  15813. /**
  15814. * How much to randomize the particle direction [0-1].
  15815. */
  15816. directionRandomizer: number;
  15817. /**
  15818. * Creates a new instance SphereParticleEmitter
  15819. * @param radius the radius of the emission sphere (1 by default)
  15820. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15822. */
  15823. constructor(
  15824. /**
  15825. * The radius of the emission sphere.
  15826. */
  15827. radius?: number,
  15828. /**
  15829. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15830. */
  15831. radiusRange?: number,
  15832. /**
  15833. * How much to randomize the particle direction [0-1].
  15834. */
  15835. directionRandomizer?: number);
  15836. /**
  15837. * Called by the particle System when the direction is computed for the created particle.
  15838. * @param worldMatrix is the world matrix of the particle system
  15839. * @param directionToUpdate is the direction vector to update with the result
  15840. * @param particle is the particle we are computed the direction for
  15841. */
  15842. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15843. /**
  15844. * Called by the particle System when the position is computed for the created particle.
  15845. * @param worldMatrix is the world matrix of the particle system
  15846. * @param positionToUpdate is the position vector to update with the result
  15847. * @param particle is the particle we are computed the position for
  15848. */
  15849. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15850. /**
  15851. * Clones the current emitter and returns a copy of it
  15852. * @returns the new emitter
  15853. */
  15854. clone(): SphereParticleEmitter;
  15855. /**
  15856. * Called by the GPUParticleSystem to setup the update shader
  15857. * @param effect defines the update shader
  15858. */
  15859. applyToShader(effect: Effect): void;
  15860. /**
  15861. * Returns a string to use to update the GPU particles update shader
  15862. * @returns a string containng the defines string
  15863. */
  15864. getEffectDefines(): string;
  15865. /**
  15866. * Returns the string "SphereParticleEmitter"
  15867. * @returns a string containing the class name
  15868. */
  15869. getClassName(): string;
  15870. /**
  15871. * Serializes the particle system to a JSON object.
  15872. * @returns the JSON object
  15873. */
  15874. serialize(): any;
  15875. /**
  15876. * Parse properties from a JSON object
  15877. * @param serializationObject defines the JSON object
  15878. */
  15879. parse(serializationObject: any): void;
  15880. }
  15881. /**
  15882. * Particle emitter emitting particles from the inside of a sphere.
  15883. * It emits the particles randomly between two vectors.
  15884. */
  15885. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15886. /**
  15887. * The min limit of the emission direction.
  15888. */
  15889. direction1: Vector3;
  15890. /**
  15891. * The max limit of the emission direction.
  15892. */
  15893. direction2: Vector3;
  15894. /**
  15895. * Creates a new instance SphereDirectedParticleEmitter
  15896. * @param radius the radius of the emission sphere (1 by default)
  15897. * @param direction1 the min limit of the emission direction (up vector by default)
  15898. * @param direction2 the max limit of the emission direction (up vector by default)
  15899. */
  15900. constructor(radius?: number,
  15901. /**
  15902. * The min limit of the emission direction.
  15903. */
  15904. direction1?: Vector3,
  15905. /**
  15906. * The max limit of the emission direction.
  15907. */
  15908. direction2?: Vector3);
  15909. /**
  15910. * Called by the particle System when the direction is computed for the created particle.
  15911. * @param worldMatrix is the world matrix of the particle system
  15912. * @param directionToUpdate is the direction vector to update with the result
  15913. * @param particle is the particle we are computed the direction for
  15914. */
  15915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15916. /**
  15917. * Clones the current emitter and returns a copy of it
  15918. * @returns the new emitter
  15919. */
  15920. clone(): SphereDirectedParticleEmitter;
  15921. /**
  15922. * Called by the GPUParticleSystem to setup the update shader
  15923. * @param effect defines the update shader
  15924. */
  15925. applyToShader(effect: Effect): void;
  15926. /**
  15927. * Returns a string to use to update the GPU particles update shader
  15928. * @returns a string containng the defines string
  15929. */
  15930. getEffectDefines(): string;
  15931. /**
  15932. * Returns the string "SphereDirectedParticleEmitter"
  15933. * @returns a string containing the class name
  15934. */
  15935. getClassName(): string;
  15936. /**
  15937. * Serializes the particle system to a JSON object.
  15938. * @returns the JSON object
  15939. */
  15940. serialize(): any;
  15941. /**
  15942. * Parse properties from a JSON object
  15943. * @param serializationObject defines the JSON object
  15944. */
  15945. parse(serializationObject: any): void;
  15946. }
  15947. }
  15948. declare module BABYLON {
  15949. /**
  15950. * Interface representing a particle system in Babylon.js.
  15951. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15952. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15953. */
  15954. export interface IParticleSystem {
  15955. /**
  15956. * List of animations used by the particle system.
  15957. */
  15958. animations: Animation[];
  15959. /**
  15960. * The id of the Particle system.
  15961. */
  15962. id: string;
  15963. /**
  15964. * The name of the Particle system.
  15965. */
  15966. name: string;
  15967. /**
  15968. * The emitter represents the Mesh or position we are attaching the particle system to.
  15969. */
  15970. emitter: Nullable<AbstractMesh | Vector3>;
  15971. /**
  15972. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15973. */
  15974. isBillboardBased: boolean;
  15975. /**
  15976. * The rendering group used by the Particle system to chose when to render.
  15977. */
  15978. renderingGroupId: number;
  15979. /**
  15980. * The layer mask we are rendering the particles through.
  15981. */
  15982. layerMask: number;
  15983. /**
  15984. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15985. */
  15986. updateSpeed: number;
  15987. /**
  15988. * The amount of time the particle system is running (depends of the overall update speed).
  15989. */
  15990. targetStopDuration: number;
  15991. /**
  15992. * The texture used to render each particle. (this can be a spritesheet)
  15993. */
  15994. particleTexture: Nullable<Texture>;
  15995. /**
  15996. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15997. */
  15998. blendMode: number;
  15999. /**
  16000. * Minimum life time of emitting particles.
  16001. */
  16002. minLifeTime: number;
  16003. /**
  16004. * Maximum life time of emitting particles.
  16005. */
  16006. maxLifeTime: number;
  16007. /**
  16008. * Minimum Size of emitting particles.
  16009. */
  16010. minSize: number;
  16011. /**
  16012. * Maximum Size of emitting particles.
  16013. */
  16014. maxSize: number;
  16015. /**
  16016. * Minimum scale of emitting particles on X axis.
  16017. */
  16018. minScaleX: number;
  16019. /**
  16020. * Maximum scale of emitting particles on X axis.
  16021. */
  16022. maxScaleX: number;
  16023. /**
  16024. * Minimum scale of emitting particles on Y axis.
  16025. */
  16026. minScaleY: number;
  16027. /**
  16028. * Maximum scale of emitting particles on Y axis.
  16029. */
  16030. maxScaleY: number;
  16031. /**
  16032. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16033. */
  16034. color1: Color4;
  16035. /**
  16036. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16037. */
  16038. color2: Color4;
  16039. /**
  16040. * Color the particle will have at the end of its lifetime.
  16041. */
  16042. colorDead: Color4;
  16043. /**
  16044. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16045. */
  16046. emitRate: number;
  16047. /**
  16048. * You can use gravity if you want to give an orientation to your particles.
  16049. */
  16050. gravity: Vector3;
  16051. /**
  16052. * Minimum power of emitting particles.
  16053. */
  16054. minEmitPower: number;
  16055. /**
  16056. * Maximum power of emitting particles.
  16057. */
  16058. maxEmitPower: number;
  16059. /**
  16060. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16061. */
  16062. minAngularSpeed: number;
  16063. /**
  16064. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16065. */
  16066. maxAngularSpeed: number;
  16067. /**
  16068. * Gets or sets the minimal initial rotation in radians.
  16069. */
  16070. minInitialRotation: number;
  16071. /**
  16072. * Gets or sets the maximal initial rotation in radians.
  16073. */
  16074. maxInitialRotation: number;
  16075. /**
  16076. * The particle emitter type defines the emitter used by the particle system.
  16077. * It can be for example box, sphere, or cone...
  16078. */
  16079. particleEmitterType: Nullable<IParticleEmitterType>;
  16080. /**
  16081. * Defines the delay in milliseconds before starting the system (0 by default)
  16082. */
  16083. startDelay: number;
  16084. /**
  16085. * 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
  16086. */
  16087. preWarmCycles: number;
  16088. /**
  16089. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16090. */
  16091. preWarmStepOffset: number;
  16092. /**
  16093. * 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)
  16094. */
  16095. spriteCellChangeSpeed: number;
  16096. /**
  16097. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16098. */
  16099. startSpriteCellID: number;
  16100. /**
  16101. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16102. */
  16103. endSpriteCellID: number;
  16104. /**
  16105. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16106. */
  16107. spriteCellWidth: number;
  16108. /**
  16109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16110. */
  16111. spriteCellHeight: number;
  16112. /**
  16113. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16114. */
  16115. spriteRandomStartCell: boolean;
  16116. /**
  16117. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16118. */
  16119. isAnimationSheetEnabled: boolean;
  16120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16121. translationPivot: Vector2;
  16122. /**
  16123. * Gets or sets a texture used to add random noise to particle positions
  16124. */
  16125. noiseTexture: Nullable<BaseTexture>;
  16126. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16127. noiseStrength: Vector3;
  16128. /**
  16129. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16130. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16131. */
  16132. billboardMode: number;
  16133. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16134. limitVelocityDamping: number;
  16135. /**
  16136. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16137. */
  16138. beginAnimationOnStart: boolean;
  16139. /**
  16140. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16141. */
  16142. beginAnimationFrom: number;
  16143. /**
  16144. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16145. */
  16146. beginAnimationTo: number;
  16147. /**
  16148. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16149. */
  16150. beginAnimationLoop: boolean;
  16151. /**
  16152. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16153. */
  16154. disposeOnStop: boolean;
  16155. /**
  16156. * Gets the maximum number of particles active at the same time.
  16157. * @returns The max number of active particles.
  16158. */
  16159. getCapacity(): number;
  16160. /**
  16161. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16162. * @returns True if it has been started, otherwise false.
  16163. */
  16164. isStarted(): boolean;
  16165. /**
  16166. * Animates the particle system for this frame.
  16167. */
  16168. animate(): void;
  16169. /**
  16170. * Renders the particle system in its current state.
  16171. * @returns the current number of particles
  16172. */
  16173. render(): number;
  16174. /**
  16175. * Dispose the particle system and frees its associated resources.
  16176. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16177. */
  16178. dispose(disposeTexture?: boolean): void;
  16179. /**
  16180. * Clones the particle system.
  16181. * @param name The name of the cloned object
  16182. * @param newEmitter The new emitter to use
  16183. * @returns the cloned particle system
  16184. */
  16185. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16186. /**
  16187. * Serializes the particle system to a JSON object.
  16188. * @returns the JSON object
  16189. */
  16190. serialize(): any;
  16191. /**
  16192. * Rebuild the particle system
  16193. */
  16194. rebuild(): void;
  16195. /**
  16196. * Starts the particle system and begins to emit
  16197. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16198. */
  16199. start(delay?: number): void;
  16200. /**
  16201. * Stops the particle system.
  16202. */
  16203. stop(): void;
  16204. /**
  16205. * Remove all active particles
  16206. */
  16207. reset(): void;
  16208. /**
  16209. * Is this system ready to be used/rendered
  16210. * @return true if the system is ready
  16211. */
  16212. isReady(): boolean;
  16213. /**
  16214. * Adds a new color gradient
  16215. * @param gradient defines the gradient to use (between 0 and 1)
  16216. * @param color1 defines the color to affect to the specified gradient
  16217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16218. * @returns the current particle system
  16219. */
  16220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16221. /**
  16222. * Remove a specific color gradient
  16223. * @param gradient defines the gradient to remove
  16224. * @returns the current particle system
  16225. */
  16226. removeColorGradient(gradient: number): IParticleSystem;
  16227. /**
  16228. * Adds a new size gradient
  16229. * @param gradient defines the gradient to use (between 0 and 1)
  16230. * @param factor defines the size factor to affect to the specified gradient
  16231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16232. * @returns the current particle system
  16233. */
  16234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16235. /**
  16236. * Remove a specific size gradient
  16237. * @param gradient defines the gradient to remove
  16238. * @returns the current particle system
  16239. */
  16240. removeSizeGradient(gradient: number): IParticleSystem;
  16241. /**
  16242. * Gets the current list of color gradients.
  16243. * You must use addColorGradient and removeColorGradient to udpate this list
  16244. * @returns the list of color gradients
  16245. */
  16246. getColorGradients(): Nullable<Array<ColorGradient>>;
  16247. /**
  16248. * Gets the current list of size gradients.
  16249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16250. * @returns the list of size gradients
  16251. */
  16252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16253. /**
  16254. * Gets the current list of angular speed gradients.
  16255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16256. * @returns the list of angular speed gradients
  16257. */
  16258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16259. /**
  16260. * Adds a new angular speed gradient
  16261. * @param gradient defines the gradient to use (between 0 and 1)
  16262. * @param factor defines the angular speed to affect to the specified gradient
  16263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16264. * @returns the current particle system
  16265. */
  16266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16267. /**
  16268. * Remove a specific angular speed gradient
  16269. * @param gradient defines the gradient to remove
  16270. * @returns the current particle system
  16271. */
  16272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16273. /**
  16274. * Gets the current list of velocity gradients.
  16275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16276. * @returns the list of velocity gradients
  16277. */
  16278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16279. /**
  16280. * Adds a new velocity gradient
  16281. * @param gradient defines the gradient to use (between 0 and 1)
  16282. * @param factor defines the velocity to affect to the specified gradient
  16283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16284. * @returns the current particle system
  16285. */
  16286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16287. /**
  16288. * Remove a specific velocity gradient
  16289. * @param gradient defines the gradient to remove
  16290. * @returns the current particle system
  16291. */
  16292. removeVelocityGradient(gradient: number): IParticleSystem;
  16293. /**
  16294. * Gets the current list of limit velocity gradients.
  16295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16296. * @returns the list of limit velocity gradients
  16297. */
  16298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16299. /**
  16300. * Adds a new limit velocity gradient
  16301. * @param gradient defines the gradient to use (between 0 and 1)
  16302. * @param factor defines the limit velocity to affect to the specified gradient
  16303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16304. * @returns the current particle system
  16305. */
  16306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16307. /**
  16308. * Remove a specific limit velocity gradient
  16309. * @param gradient defines the gradient to remove
  16310. * @returns the current particle system
  16311. */
  16312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16313. /**
  16314. * Adds a new drag gradient
  16315. * @param gradient defines the gradient to use (between 0 and 1)
  16316. * @param factor defines the drag to affect to the specified gradient
  16317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16318. * @returns the current particle system
  16319. */
  16320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16321. /**
  16322. * Remove a specific drag gradient
  16323. * @param gradient defines the gradient to remove
  16324. * @returns the current particle system
  16325. */
  16326. removeDragGradient(gradient: number): IParticleSystem;
  16327. /**
  16328. * Gets the current list of drag gradients.
  16329. * You must use addDragGradient and removeDragGradient to udpate this list
  16330. * @returns the list of drag gradients
  16331. */
  16332. getDragGradients(): Nullable<Array<FactorGradient>>;
  16333. /**
  16334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param factor defines the emit rate to affect to the specified gradient
  16337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16338. * @returns the current particle system
  16339. */
  16340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16341. /**
  16342. * Remove a specific emit rate gradient
  16343. * @param gradient defines the gradient to remove
  16344. * @returns the current particle system
  16345. */
  16346. removeEmitRateGradient(gradient: number): IParticleSystem;
  16347. /**
  16348. * Gets the current list of emit rate gradients.
  16349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16350. * @returns the list of emit rate gradients
  16351. */
  16352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16353. /**
  16354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16355. * @param gradient defines the gradient to use (between 0 and 1)
  16356. * @param factor defines the start size to affect to the specified gradient
  16357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16358. * @returns the current particle system
  16359. */
  16360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16361. /**
  16362. * Remove a specific start size gradient
  16363. * @param gradient defines the gradient to remove
  16364. * @returns the current particle system
  16365. */
  16366. removeStartSizeGradient(gradient: number): IParticleSystem;
  16367. /**
  16368. * Gets the current list of start size gradients.
  16369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16370. * @returns the list of start size gradients
  16371. */
  16372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16373. /**
  16374. * Adds a new life time gradient
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param factor defines the life time factor to affect to the specified gradient
  16377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16378. * @returns the current particle system
  16379. */
  16380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16381. /**
  16382. * Remove a specific life time gradient
  16383. * @param gradient defines the gradient to remove
  16384. * @returns the current particle system
  16385. */
  16386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16387. /**
  16388. * Gets the current list of life time gradients.
  16389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16390. * @returns the list of life time gradients
  16391. */
  16392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16393. /**
  16394. * Gets the current list of color gradients.
  16395. * You must use addColorGradient and removeColorGradient to udpate this list
  16396. * @returns the list of color gradients
  16397. */
  16398. getColorGradients(): Nullable<Array<ColorGradient>>;
  16399. /**
  16400. * Adds a new ramp gradient used to remap particle colors
  16401. * @param gradient defines the gradient to use (between 0 and 1)
  16402. * @param color defines the color to affect to the specified gradient
  16403. * @returns the current particle system
  16404. */
  16405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16406. /**
  16407. * Gets the current list of ramp gradients.
  16408. * You must use addRampGradient and removeRampGradient to udpate this list
  16409. * @returns the list of ramp gradients
  16410. */
  16411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16412. /** Gets or sets a boolean indicating that ramp gradients must be used
  16413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16414. */
  16415. useRampGradients: boolean;
  16416. /**
  16417. * Adds a new color remap gradient
  16418. * @param gradient defines the gradient to use (between 0 and 1)
  16419. * @param min defines the color remap minimal range
  16420. * @param max defines the color remap maximal range
  16421. * @returns the current particle system
  16422. */
  16423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16424. /**
  16425. * Gets the current list of color remap gradients.
  16426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16427. * @returns the list of color remap gradients
  16428. */
  16429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16430. /**
  16431. * Adds a new alpha remap gradient
  16432. * @param gradient defines the gradient to use (between 0 and 1)
  16433. * @param min defines the alpha remap minimal range
  16434. * @param max defines the alpha remap maximal range
  16435. * @returns the current particle system
  16436. */
  16437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16438. /**
  16439. * Gets the current list of alpha remap gradients.
  16440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16441. * @returns the list of alpha remap gradients
  16442. */
  16443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16444. /**
  16445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16448. * @returns the emitter
  16449. */
  16450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16451. /**
  16452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16453. * @param radius The radius of the hemisphere to emit from
  16454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16455. * @returns the emitter
  16456. */
  16457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16458. /**
  16459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16460. * @param radius The radius of the sphere to emit from
  16461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16462. * @returns the emitter
  16463. */
  16464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16465. /**
  16466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16467. * @param radius The radius of the sphere to emit from
  16468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16470. * @returns the emitter
  16471. */
  16472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16473. /**
  16474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16475. * @param radius The radius of the emission cylinder
  16476. * @param height The height of the emission cylinder
  16477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16479. * @returns the emitter
  16480. */
  16481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16482. /**
  16483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16484. * @param radius The radius of the cylinder to emit from
  16485. * @param height The height of the emission cylinder
  16486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16489. * @returns the emitter
  16490. */
  16491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16492. /**
  16493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16494. * @param radius The radius of the cone to emit from
  16495. * @param angle The base angle of the cone
  16496. * @returns the emitter
  16497. */
  16498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16499. /**
  16500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16505. * @returns the emitter
  16506. */
  16507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16508. /**
  16509. * Get hosting scene
  16510. * @returns the scene
  16511. */
  16512. getScene(): Scene;
  16513. }
  16514. }
  16515. declare module BABYLON {
  16516. /**
  16517. * Creates an instance based on a source mesh.
  16518. */
  16519. export class InstancedMesh extends AbstractMesh {
  16520. private _sourceMesh;
  16521. private _currentLOD;
  16522. /** @hidden */
  16523. _indexInSourceMeshInstanceArray: number;
  16524. constructor(name: string, source: Mesh);
  16525. /**
  16526. * Returns the string "InstancedMesh".
  16527. */
  16528. getClassName(): string;
  16529. /**
  16530. * If the source mesh receives shadows
  16531. */
  16532. readonly receiveShadows: boolean;
  16533. /**
  16534. * The material of the source mesh
  16535. */
  16536. readonly material: Nullable<Material>;
  16537. /**
  16538. * Visibility of the source mesh
  16539. */
  16540. readonly visibility: number;
  16541. /**
  16542. * Skeleton of the source mesh
  16543. */
  16544. readonly skeleton: Nullable<Skeleton>;
  16545. /**
  16546. * Rendering ground id of the source mesh
  16547. */
  16548. renderingGroupId: number;
  16549. /**
  16550. * Returns the total number of vertices (integer).
  16551. */
  16552. getTotalVertices(): number;
  16553. /**
  16554. * Returns a positive integer : the total number of indices in this mesh geometry.
  16555. * @returns the numner of indices or zero if the mesh has no geometry.
  16556. */
  16557. getTotalIndices(): number;
  16558. /**
  16559. * The source mesh of the instance
  16560. */
  16561. readonly sourceMesh: Mesh;
  16562. /**
  16563. * Is this node ready to be used/rendered
  16564. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16565. * @return {boolean} is it ready
  16566. */
  16567. isReady(completeCheck?: boolean): boolean;
  16568. /**
  16569. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16570. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16571. * @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.
  16572. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16573. */
  16574. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16575. /**
  16576. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16577. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16578. * The `data` are either a numeric array either a Float32Array.
  16579. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16580. * 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).
  16581. * Note that a new underlying VertexBuffer object is created each call.
  16582. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16583. *
  16584. * Possible `kind` values :
  16585. * - VertexBuffer.PositionKind
  16586. * - VertexBuffer.UVKind
  16587. * - VertexBuffer.UV2Kind
  16588. * - VertexBuffer.UV3Kind
  16589. * - VertexBuffer.UV4Kind
  16590. * - VertexBuffer.UV5Kind
  16591. * - VertexBuffer.UV6Kind
  16592. * - VertexBuffer.ColorKind
  16593. * - VertexBuffer.MatricesIndicesKind
  16594. * - VertexBuffer.MatricesIndicesExtraKind
  16595. * - VertexBuffer.MatricesWeightsKind
  16596. * - VertexBuffer.MatricesWeightsExtraKind
  16597. *
  16598. * Returns the Mesh.
  16599. */
  16600. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16601. /**
  16602. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16603. * If the mesh has no geometry, it is simply returned as it is.
  16604. * The `data` are either a numeric array either a Float32Array.
  16605. * No new underlying VertexBuffer object is created.
  16606. * 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.
  16607. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16608. *
  16609. * Possible `kind` values :
  16610. * - VertexBuffer.PositionKind
  16611. * - VertexBuffer.UVKind
  16612. * - VertexBuffer.UV2Kind
  16613. * - VertexBuffer.UV3Kind
  16614. * - VertexBuffer.UV4Kind
  16615. * - VertexBuffer.UV5Kind
  16616. * - VertexBuffer.UV6Kind
  16617. * - VertexBuffer.ColorKind
  16618. * - VertexBuffer.MatricesIndicesKind
  16619. * - VertexBuffer.MatricesIndicesExtraKind
  16620. * - VertexBuffer.MatricesWeightsKind
  16621. * - VertexBuffer.MatricesWeightsExtraKind
  16622. *
  16623. * Returns the Mesh.
  16624. */
  16625. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16626. /**
  16627. * Sets the mesh indices.
  16628. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16629. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16630. * This method creates a new index buffer each call.
  16631. * Returns the Mesh.
  16632. */
  16633. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16634. /**
  16635. * Boolean : True if the mesh owns the requested kind of data.
  16636. */
  16637. isVerticesDataPresent(kind: string): boolean;
  16638. /**
  16639. * Returns an array of indices (IndicesArray).
  16640. */
  16641. getIndices(): Nullable<IndicesArray>;
  16642. readonly _positions: Nullable<Vector3[]>;
  16643. /**
  16644. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16645. * This means the mesh underlying bounding box and sphere are recomputed.
  16646. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16647. * @returns the current mesh
  16648. */
  16649. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16650. /** @hidden */
  16651. _preActivate(): InstancedMesh;
  16652. /** @hidden */
  16653. _activate(renderId: number): InstancedMesh;
  16654. /**
  16655. * Returns the current associated LOD AbstractMesh.
  16656. */
  16657. getLOD(camera: Camera): AbstractMesh;
  16658. /** @hidden */
  16659. _syncSubMeshes(): InstancedMesh;
  16660. /** @hidden */
  16661. _generatePointsArray(): boolean;
  16662. /**
  16663. * Creates a new InstancedMesh from the current mesh.
  16664. * - name (string) : the cloned mesh name
  16665. * - newParent (optional Node) : the optional Node to parent the clone to.
  16666. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16667. *
  16668. * Returns the clone.
  16669. */
  16670. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16671. /**
  16672. * Disposes the InstancedMesh.
  16673. * Returns nothing.
  16674. */
  16675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16676. }
  16677. }
  16678. declare module BABYLON {
  16679. /**
  16680. * Defines the options associated with the creation of a shader material.
  16681. */
  16682. export interface IShaderMaterialOptions {
  16683. /**
  16684. * Does the material work in alpha blend mode
  16685. */
  16686. needAlphaBlending: boolean;
  16687. /**
  16688. * Does the material work in alpha test mode
  16689. */
  16690. needAlphaTesting: boolean;
  16691. /**
  16692. * The list of attribute names used in the shader
  16693. */
  16694. attributes: string[];
  16695. /**
  16696. * The list of unifrom names used in the shader
  16697. */
  16698. uniforms: string[];
  16699. /**
  16700. * The list of UBO names used in the shader
  16701. */
  16702. uniformBuffers: string[];
  16703. /**
  16704. * The list of sampler names used in the shader
  16705. */
  16706. samplers: string[];
  16707. /**
  16708. * The list of defines used in the shader
  16709. */
  16710. defines: string[];
  16711. }
  16712. /**
  16713. * 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.
  16714. *
  16715. * This returned material effects how the mesh will look based on the code in the shaders.
  16716. *
  16717. * @see http://doc.babylonjs.com/how_to/shader_material
  16718. */
  16719. export class ShaderMaterial extends Material {
  16720. private _shaderPath;
  16721. private _options;
  16722. private _textures;
  16723. private _textureArrays;
  16724. private _floats;
  16725. private _ints;
  16726. private _floatsArrays;
  16727. private _colors3;
  16728. private _colors3Arrays;
  16729. private _colors4;
  16730. private _vectors2;
  16731. private _vectors3;
  16732. private _vectors4;
  16733. private _matrices;
  16734. private _matrices3x3;
  16735. private _matrices2x2;
  16736. private _vectors2Arrays;
  16737. private _vectors3Arrays;
  16738. private _cachedWorldViewMatrix;
  16739. private _renderId;
  16740. /**
  16741. * Instantiate a new shader material.
  16742. * 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.
  16743. * This returned material effects how the mesh will look based on the code in the shaders.
  16744. * @see http://doc.babylonjs.com/how_to/shader_material
  16745. * @param name Define the name of the material in the scene
  16746. * @param scene Define the scene the material belongs to
  16747. * @param shaderPath Defines the route to the shader code in one of three ways:
  16748. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16749. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16750. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16751. * @param options Define the options used to create the shader
  16752. */
  16753. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16754. /**
  16755. * Gets the options used to compile the shader.
  16756. * They can be modified to trigger a new compilation
  16757. */
  16758. readonly options: IShaderMaterialOptions;
  16759. /**
  16760. * Gets the current class name of the material e.g. "ShaderMaterial"
  16761. * Mainly use in serialization.
  16762. * @returns the class name
  16763. */
  16764. getClassName(): string;
  16765. /**
  16766. * Specifies if the material will require alpha blending
  16767. * @returns a boolean specifying if alpha blending is needed
  16768. */
  16769. needAlphaBlending(): boolean;
  16770. /**
  16771. * Specifies if this material should be rendered in alpha test mode
  16772. * @returns a boolean specifying if an alpha test is needed.
  16773. */
  16774. needAlphaTesting(): boolean;
  16775. private _checkUniform;
  16776. /**
  16777. * Set a texture in the shader.
  16778. * @param name Define the name of the uniform samplers as defined in the shader
  16779. * @param texture Define the texture to bind to this sampler
  16780. * @return the material itself allowing "fluent" like uniform updates
  16781. */
  16782. setTexture(name: string, texture: Texture): ShaderMaterial;
  16783. /**
  16784. * Set a texture array in the shader.
  16785. * @param name Define the name of the uniform sampler array as defined in the shader
  16786. * @param textures Define the list of textures to bind to this sampler
  16787. * @return the material itself allowing "fluent" like uniform updates
  16788. */
  16789. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16790. /**
  16791. * Set a float in the shader.
  16792. * @param name Define the name of the uniform as defined in the shader
  16793. * @param value Define the value to give to the uniform
  16794. * @return the material itself allowing "fluent" like uniform updates
  16795. */
  16796. setFloat(name: string, value: number): ShaderMaterial;
  16797. /**
  16798. * Set a int in the shader.
  16799. * @param name Define the name of the uniform as defined in the shader
  16800. * @param value Define the value to give to the uniform
  16801. * @return the material itself allowing "fluent" like uniform updates
  16802. */
  16803. setInt(name: string, value: number): ShaderMaterial;
  16804. /**
  16805. * Set an array of floats in the shader.
  16806. * @param name Define the name of the uniform as defined in the shader
  16807. * @param value Define the value to give to the uniform
  16808. * @return the material itself allowing "fluent" like uniform updates
  16809. */
  16810. setFloats(name: string, value: number[]): ShaderMaterial;
  16811. /**
  16812. * Set a vec3 in the shader from a Color3.
  16813. * @param name Define the name of the uniform as defined in the shader
  16814. * @param value Define the value to give to the uniform
  16815. * @return the material itself allowing "fluent" like uniform updates
  16816. */
  16817. setColor3(name: string, value: Color3): ShaderMaterial;
  16818. /**
  16819. * Set a vec3 array in the shader from a Color3 array.
  16820. * @param name Define the name of the uniform as defined in the shader
  16821. * @param value Define the value to give to the uniform
  16822. * @return the material itself allowing "fluent" like uniform updates
  16823. */
  16824. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16825. /**
  16826. * Set a vec4 in the shader from a Color4.
  16827. * @param name Define the name of the uniform as defined in the shader
  16828. * @param value Define the value to give to the uniform
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setColor4(name: string, value: Color4): ShaderMaterial;
  16832. /**
  16833. * Set a vec2 in the shader from a Vector2.
  16834. * @param name Define the name of the uniform as defined in the shader
  16835. * @param value Define the value to give to the uniform
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setVector2(name: string, value: Vector2): ShaderMaterial;
  16839. /**
  16840. * Set a vec3 in the shader from a Vector3.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the material itself allowing "fluent" like uniform updates
  16844. */
  16845. setVector3(name: string, value: Vector3): ShaderMaterial;
  16846. /**
  16847. * Set a vec4 in the shader from a Vector4.
  16848. * @param name Define the name of the uniform as defined in the shader
  16849. * @param value Define the value to give to the uniform
  16850. * @return the material itself allowing "fluent" like uniform updates
  16851. */
  16852. setVector4(name: string, value: Vector4): ShaderMaterial;
  16853. /**
  16854. * Set a mat4 in the shader from a Matrix.
  16855. * @param name Define the name of the uniform as defined in the shader
  16856. * @param value Define the value to give to the uniform
  16857. * @return the material itself allowing "fluent" like uniform updates
  16858. */
  16859. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16860. /**
  16861. * Set a mat3 in the shader from a Float32Array.
  16862. * @param name Define the name of the uniform as defined in the shader
  16863. * @param value Define the value to give to the uniform
  16864. * @return the material itself allowing "fluent" like uniform updates
  16865. */
  16866. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16867. /**
  16868. * Set a mat2 in the shader from a Float32Array.
  16869. * @param name Define the name of the uniform as defined in the shader
  16870. * @param value Define the value to give to the uniform
  16871. * @return the material itself allowing "fluent" like uniform updates
  16872. */
  16873. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16874. /**
  16875. * Set a vec2 array in the shader from a number array.
  16876. * @param name Define the name of the uniform as defined in the shader
  16877. * @param value Define the value to give to the uniform
  16878. * @return the material itself allowing "fluent" like uniform updates
  16879. */
  16880. setArray2(name: string, value: number[]): ShaderMaterial;
  16881. /**
  16882. * Set a vec3 array in the shader from a number array.
  16883. * @param name Define the name of the uniform as defined in the shader
  16884. * @param value Define the value to give to the uniform
  16885. * @return the material itself allowing "fluent" like uniform updates
  16886. */
  16887. setArray3(name: string, value: number[]): ShaderMaterial;
  16888. private _checkCache;
  16889. /**
  16890. * Specifies that the submesh is ready to be used
  16891. * @param mesh defines the mesh to check
  16892. * @param subMesh defines which submesh to check
  16893. * @param useInstances specifies that instances should be used
  16894. * @returns a boolean indicating that the submesh is ready or not
  16895. */
  16896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16897. /**
  16898. * Checks if the material is ready to render the requested mesh
  16899. * @param mesh Define the mesh to render
  16900. * @param useInstances Define whether or not the material is used with instances
  16901. * @returns true if ready, otherwise false
  16902. */
  16903. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16904. /**
  16905. * Binds the world matrix to the material
  16906. * @param world defines the world transformation matrix
  16907. */
  16908. bindOnlyWorldMatrix(world: Matrix): void;
  16909. /**
  16910. * Binds the material to the mesh
  16911. * @param world defines the world transformation matrix
  16912. * @param mesh defines the mesh to bind the material to
  16913. */
  16914. bind(world: Matrix, mesh?: Mesh): void;
  16915. /**
  16916. * Gets the active textures from the material
  16917. * @returns an array of textures
  16918. */
  16919. getActiveTextures(): BaseTexture[];
  16920. /**
  16921. * Specifies if the material uses a texture
  16922. * @param texture defines the texture to check against the material
  16923. * @returns a boolean specifying if the material uses the texture
  16924. */
  16925. hasTexture(texture: BaseTexture): boolean;
  16926. /**
  16927. * Makes a duplicate of the material, and gives it a new name
  16928. * @param name defines the new name for the duplicated material
  16929. * @returns the cloned material
  16930. */
  16931. clone(name: string): ShaderMaterial;
  16932. /**
  16933. * Disposes the material
  16934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16937. */
  16938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16939. /**
  16940. * Serializes this material in a JSON representation
  16941. * @returns the serialized material object
  16942. */
  16943. serialize(): any;
  16944. /**
  16945. * Creates a shader material from parsed shader material data
  16946. * @param source defines the JSON represnetation of the material
  16947. * @param scene defines the hosting scene
  16948. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16949. * @returns a new material
  16950. */
  16951. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16952. }
  16953. }
  16954. declare module BABYLON {
  16955. /** @hidden */
  16956. export var colorPixelShader: {
  16957. name: string;
  16958. shader: string;
  16959. };
  16960. }
  16961. declare module BABYLON {
  16962. /** @hidden */
  16963. export var colorVertexShader: {
  16964. name: string;
  16965. shader: string;
  16966. };
  16967. }
  16968. declare module BABYLON {
  16969. /**
  16970. * Line mesh
  16971. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16972. */
  16973. export class LinesMesh extends Mesh {
  16974. /**
  16975. * If vertex color should be applied to the mesh
  16976. */
  16977. useVertexColor?: boolean | undefined;
  16978. /**
  16979. * If vertex alpha should be applied to the mesh
  16980. */
  16981. useVertexAlpha?: boolean | undefined;
  16982. /**
  16983. * Color of the line (Default: White)
  16984. */
  16985. color: Color3;
  16986. /**
  16987. * Alpha of the line (Default: 1)
  16988. */
  16989. alpha: number;
  16990. /**
  16991. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16992. * This margin is expressed in world space coordinates, so its value may vary.
  16993. * Default value is 0.1
  16994. */
  16995. intersectionThreshold: number;
  16996. private _colorShader;
  16997. /**
  16998. * Creates a new LinesMesh
  16999. * @param name defines the name
  17000. * @param scene defines the hosting scene
  17001. * @param parent defines the parent mesh if any
  17002. * @param source defines the optional source LinesMesh used to clone data from
  17003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17004. * When false, achieved by calling a clone(), also passing False.
  17005. * This will make creation of children, recursive.
  17006. * @param useVertexColor defines if this LinesMesh supports vertex color
  17007. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17008. */
  17009. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17010. /**
  17011. * If vertex color should be applied to the mesh
  17012. */
  17013. useVertexColor?: boolean | undefined,
  17014. /**
  17015. * If vertex alpha should be applied to the mesh
  17016. */
  17017. useVertexAlpha?: boolean | undefined);
  17018. private _addClipPlaneDefine;
  17019. private _removeClipPlaneDefine;
  17020. isReady(): boolean;
  17021. /**
  17022. * Returns the string "LineMesh"
  17023. */
  17024. getClassName(): string;
  17025. /**
  17026. * @hidden
  17027. */
  17028. /**
  17029. * @hidden
  17030. */
  17031. material: Material;
  17032. /**
  17033. * @hidden
  17034. */
  17035. readonly checkCollisions: boolean;
  17036. /** @hidden */
  17037. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17038. /** @hidden */
  17039. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17040. /**
  17041. * Disposes of the line mesh
  17042. * @param doNotRecurse If children should be disposed
  17043. */
  17044. dispose(doNotRecurse?: boolean): void;
  17045. /**
  17046. * Returns a new LineMesh object cloned from the current one.
  17047. */
  17048. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17049. /**
  17050. * Creates a new InstancedLinesMesh object from the mesh model.
  17051. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17052. * @param name defines the name of the new instance
  17053. * @returns a new InstancedLinesMesh
  17054. */
  17055. createInstance(name: string): InstancedLinesMesh;
  17056. }
  17057. /**
  17058. * Creates an instance based on a source LinesMesh
  17059. */
  17060. export class InstancedLinesMesh extends InstancedMesh {
  17061. /**
  17062. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17063. * This margin is expressed in world space coordinates, so its value may vary.
  17064. * Initilized with the intersectionThreshold value of the source LinesMesh
  17065. */
  17066. intersectionThreshold: number;
  17067. constructor(name: string, source: LinesMesh);
  17068. /**
  17069. * Returns the string "InstancedLinesMesh".
  17070. */
  17071. getClassName(): string;
  17072. }
  17073. }
  17074. declare module BABYLON {
  17075. /** @hidden */
  17076. export var linePixelShader: {
  17077. name: string;
  17078. shader: string;
  17079. };
  17080. }
  17081. declare module BABYLON {
  17082. /** @hidden */
  17083. export var lineVertexShader: {
  17084. name: string;
  17085. shader: string;
  17086. };
  17087. }
  17088. declare module BABYLON {
  17089. interface AbstractMesh {
  17090. /**
  17091. * Disables the mesh edge rendering mode
  17092. * @returns the currentAbstractMesh
  17093. */
  17094. disableEdgesRendering(): AbstractMesh;
  17095. /**
  17096. * Enables the edge rendering mode on the mesh.
  17097. * This mode makes the mesh edges visible
  17098. * @param epsilon defines the maximal distance between two angles to detect a face
  17099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17100. * @returns the currentAbstractMesh
  17101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17102. */
  17103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17104. /**
  17105. * Gets the edgesRenderer associated with the mesh
  17106. */
  17107. edgesRenderer: Nullable<EdgesRenderer>;
  17108. }
  17109. interface LinesMesh {
  17110. /**
  17111. * Enables the edge rendering mode on the mesh.
  17112. * This mode makes the mesh edges visible
  17113. * @param epsilon defines the maximal distance between two angles to detect a face
  17114. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17115. * @returns the currentAbstractMesh
  17116. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17117. */
  17118. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17119. }
  17120. interface InstancedLinesMesh {
  17121. /**
  17122. * Enables the edge rendering mode on the mesh.
  17123. * This mode makes the mesh edges visible
  17124. * @param epsilon defines the maximal distance between two angles to detect a face
  17125. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17126. * @returns the current InstancedLinesMesh
  17127. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17128. */
  17129. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17130. }
  17131. /**
  17132. * Defines the minimum contract an Edges renderer should follow.
  17133. */
  17134. export interface IEdgesRenderer extends IDisposable {
  17135. /**
  17136. * Gets or sets a boolean indicating if the edgesRenderer is active
  17137. */
  17138. isEnabled: boolean;
  17139. /**
  17140. * Renders the edges of the attached mesh,
  17141. */
  17142. render(): void;
  17143. /**
  17144. * Checks wether or not the edges renderer is ready to render.
  17145. * @return true if ready, otherwise false.
  17146. */
  17147. isReady(): boolean;
  17148. }
  17149. /**
  17150. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17151. */
  17152. export class EdgesRenderer implements IEdgesRenderer {
  17153. /**
  17154. * Define the size of the edges with an orthographic camera
  17155. */
  17156. edgesWidthScalerForOrthographic: number;
  17157. /**
  17158. * Define the size of the edges with a perspective camera
  17159. */
  17160. edgesWidthScalerForPerspective: number;
  17161. protected _source: AbstractMesh;
  17162. protected _linesPositions: number[];
  17163. protected _linesNormals: number[];
  17164. protected _linesIndices: number[];
  17165. protected _epsilon: number;
  17166. protected _indicesCount: number;
  17167. protected _lineShader: ShaderMaterial;
  17168. protected _ib: WebGLBuffer;
  17169. protected _buffers: {
  17170. [key: string]: Nullable<VertexBuffer>;
  17171. };
  17172. protected _checkVerticesInsteadOfIndices: boolean;
  17173. private _meshRebuildObserver;
  17174. private _meshDisposeObserver;
  17175. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17176. isEnabled: boolean;
  17177. /**
  17178. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17179. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17180. * @param source Mesh used to create edges
  17181. * @param epsilon sum of angles in adjacency to check for edge
  17182. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17183. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17184. */
  17185. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17186. protected _prepareRessources(): void;
  17187. /** @hidden */
  17188. _rebuild(): void;
  17189. /**
  17190. * Releases the required resources for the edges renderer
  17191. */
  17192. dispose(): void;
  17193. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17194. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17195. /**
  17196. * Checks if the pair of p0 and p1 is en edge
  17197. * @param faceIndex
  17198. * @param edge
  17199. * @param faceNormals
  17200. * @param p0
  17201. * @param p1
  17202. * @private
  17203. */
  17204. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17205. /**
  17206. * push line into the position, normal and index buffer
  17207. * @protected
  17208. */
  17209. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17210. /**
  17211. * Generates lines edges from adjacencjes
  17212. * @private
  17213. */
  17214. _generateEdgesLines(): void;
  17215. /**
  17216. * Checks wether or not the edges renderer is ready to render.
  17217. * @return true if ready, otherwise false.
  17218. */
  17219. isReady(): boolean;
  17220. /**
  17221. * Renders the edges of the attached mesh,
  17222. */
  17223. render(): void;
  17224. }
  17225. /**
  17226. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17227. */
  17228. export class LineEdgesRenderer extends EdgesRenderer {
  17229. /**
  17230. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17231. * @param source LineMesh used to generate edges
  17232. * @param epsilon not important (specified angle for edge detection)
  17233. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17234. */
  17235. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17236. /**
  17237. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17238. */
  17239. _generateEdgesLines(): void;
  17240. }
  17241. }
  17242. declare module BABYLON {
  17243. /**
  17244. * This represents the object necessary to create a rendering group.
  17245. * This is exclusively used and created by the rendering manager.
  17246. * To modify the behavior, you use the available helpers in your scene or meshes.
  17247. * @hidden
  17248. */
  17249. export class RenderingGroup {
  17250. index: number;
  17251. private _scene;
  17252. private _opaqueSubMeshes;
  17253. private _transparentSubMeshes;
  17254. private _alphaTestSubMeshes;
  17255. private _depthOnlySubMeshes;
  17256. private _particleSystems;
  17257. private _spriteManagers;
  17258. private _opaqueSortCompareFn;
  17259. private _alphaTestSortCompareFn;
  17260. private _transparentSortCompareFn;
  17261. private _renderOpaque;
  17262. private _renderAlphaTest;
  17263. private _renderTransparent;
  17264. private _edgesRenderers;
  17265. onBeforeTransparentRendering: () => void;
  17266. /**
  17267. * Set the opaque sort comparison function.
  17268. * If null the sub meshes will be render in the order they were created
  17269. */
  17270. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17271. /**
  17272. * Set the alpha test sort comparison function.
  17273. * If null the sub meshes will be render in the order they were created
  17274. */
  17275. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17276. /**
  17277. * Set the transparent sort comparison function.
  17278. * If null the sub meshes will be render in the order they were created
  17279. */
  17280. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17281. /**
  17282. * Creates a new rendering group.
  17283. * @param index The rendering group index
  17284. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17285. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17286. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17287. */
  17288. 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>);
  17289. /**
  17290. * Render all the sub meshes contained in the group.
  17291. * @param customRenderFunction Used to override the default render behaviour of the group.
  17292. * @returns true if rendered some submeshes.
  17293. */
  17294. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17295. /**
  17296. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17297. * @param subMeshes The submeshes to render
  17298. */
  17299. private renderOpaqueSorted;
  17300. /**
  17301. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17302. * @param subMeshes The submeshes to render
  17303. */
  17304. private renderAlphaTestSorted;
  17305. /**
  17306. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17307. * @param subMeshes The submeshes to render
  17308. */
  17309. private renderTransparentSorted;
  17310. /**
  17311. * Renders the submeshes in a specified order.
  17312. * @param subMeshes The submeshes to sort before render
  17313. * @param sortCompareFn The comparison function use to sort
  17314. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17315. * @param transparent Specifies to activate blending if true
  17316. */
  17317. private static renderSorted;
  17318. /**
  17319. * Renders the submeshes in the order they were dispatched (no sort applied).
  17320. * @param subMeshes The submeshes to render
  17321. */
  17322. private static renderUnsorted;
  17323. /**
  17324. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17325. * are rendered back to front if in the same alpha index.
  17326. *
  17327. * @param a The first submesh
  17328. * @param b The second submesh
  17329. * @returns The result of the comparison
  17330. */
  17331. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17332. /**
  17333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17334. * are rendered back to front.
  17335. *
  17336. * @param a The first submesh
  17337. * @param b The second submesh
  17338. * @returns The result of the comparison
  17339. */
  17340. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17341. /**
  17342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17343. * are rendered front to back (prevent overdraw).
  17344. *
  17345. * @param a The first submesh
  17346. * @param b The second submesh
  17347. * @returns The result of the comparison
  17348. */
  17349. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17350. /**
  17351. * Resets the different lists of submeshes to prepare a new frame.
  17352. */
  17353. prepare(): void;
  17354. dispose(): void;
  17355. /**
  17356. * Inserts the submesh in its correct queue depending on its material.
  17357. * @param subMesh The submesh to dispatch
  17358. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17359. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17360. */
  17361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17362. dispatchSprites(spriteManager: ISpriteManager): void;
  17363. dispatchParticles(particleSystem: IParticleSystem): void;
  17364. private _renderParticles;
  17365. private _renderSprites;
  17366. }
  17367. }
  17368. declare module BABYLON {
  17369. /**
  17370. * Interface describing the different options available in the rendering manager
  17371. * regarding Auto Clear between groups.
  17372. */
  17373. export interface IRenderingManagerAutoClearSetup {
  17374. /**
  17375. * Defines whether or not autoclear is enable.
  17376. */
  17377. autoClear: boolean;
  17378. /**
  17379. * Defines whether or not to autoclear the depth buffer.
  17380. */
  17381. depth: boolean;
  17382. /**
  17383. * Defines whether or not to autoclear the stencil buffer.
  17384. */
  17385. stencil: boolean;
  17386. }
  17387. /**
  17388. * This class is used by the onRenderingGroupObservable
  17389. */
  17390. export class RenderingGroupInfo {
  17391. /**
  17392. * The Scene that being rendered
  17393. */
  17394. scene: Scene;
  17395. /**
  17396. * The camera currently used for the rendering pass
  17397. */
  17398. camera: Nullable<Camera>;
  17399. /**
  17400. * The ID of the renderingGroup being processed
  17401. */
  17402. renderingGroupId: number;
  17403. }
  17404. /**
  17405. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17406. * It is enable to manage the different groups as well as the different necessary sort functions.
  17407. * This should not be used directly aside of the few static configurations
  17408. */
  17409. export class RenderingManager {
  17410. /**
  17411. * The max id used for rendering groups (not included)
  17412. */
  17413. static MAX_RENDERINGGROUPS: number;
  17414. /**
  17415. * The min id used for rendering groups (included)
  17416. */
  17417. static MIN_RENDERINGGROUPS: number;
  17418. /**
  17419. * Used to globally prevent autoclearing scenes.
  17420. */
  17421. static AUTOCLEAR: boolean;
  17422. /**
  17423. * @hidden
  17424. */
  17425. _useSceneAutoClearSetup: boolean;
  17426. private _scene;
  17427. private _renderingGroups;
  17428. private _depthStencilBufferAlreadyCleaned;
  17429. private _autoClearDepthStencil;
  17430. private _customOpaqueSortCompareFn;
  17431. private _customAlphaTestSortCompareFn;
  17432. private _customTransparentSortCompareFn;
  17433. private _renderingGroupInfo;
  17434. /**
  17435. * Instantiates a new rendering group for a particular scene
  17436. * @param scene Defines the scene the groups belongs to
  17437. */
  17438. constructor(scene: Scene);
  17439. private _clearDepthStencilBuffer;
  17440. /**
  17441. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17442. * @hidden
  17443. */
  17444. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17445. /**
  17446. * Resets the different information of the group to prepare a new frame
  17447. * @hidden
  17448. */
  17449. reset(): void;
  17450. /**
  17451. * Dispose and release the group and its associated resources.
  17452. * @hidden
  17453. */
  17454. dispose(): void;
  17455. /**
  17456. * Clear the info related to rendering groups preventing retention points during dispose.
  17457. */
  17458. freeRenderingGroups(): void;
  17459. private _prepareRenderingGroup;
  17460. /**
  17461. * Add a sprite manager to the rendering manager in order to render it this frame.
  17462. * @param spriteManager Define the sprite manager to render
  17463. */
  17464. dispatchSprites(spriteManager: ISpriteManager): void;
  17465. /**
  17466. * Add a particle system to the rendering manager in order to render it this frame.
  17467. * @param particleSystem Define the particle system to render
  17468. */
  17469. dispatchParticles(particleSystem: IParticleSystem): void;
  17470. /**
  17471. * Add a submesh to the manager in order to render it this frame
  17472. * @param subMesh The submesh to dispatch
  17473. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17474. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17475. */
  17476. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17477. /**
  17478. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17479. * This allowed control for front to back rendering or reversly depending of the special needs.
  17480. *
  17481. * @param renderingGroupId The rendering group id corresponding to its index
  17482. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17483. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17484. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17485. */
  17486. 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;
  17487. /**
  17488. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17489. *
  17490. * @param renderingGroupId The rendering group id corresponding to its index
  17491. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17492. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17493. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17494. */
  17495. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17496. /**
  17497. * Gets the current auto clear configuration for one rendering group of the rendering
  17498. * manager.
  17499. * @param index the rendering group index to get the information for
  17500. * @returns The auto clear setup for the requested rendering group
  17501. */
  17502. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17503. }
  17504. }
  17505. declare module BABYLON {
  17506. /**
  17507. * This Helps creating a texture that will be created from a camera in your scene.
  17508. * It is basically a dynamic texture that could be used to create special effects for instance.
  17509. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17510. */
  17511. export class RenderTargetTexture extends Texture {
  17512. isCube: boolean;
  17513. /**
  17514. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17515. */
  17516. static readonly REFRESHRATE_RENDER_ONCE: number;
  17517. /**
  17518. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17519. */
  17520. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17521. /**
  17522. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17523. * the central point of your effect and can save a lot of performances.
  17524. */
  17525. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17526. /**
  17527. * Use this predicate to dynamically define the list of mesh you want to render.
  17528. * If set, the renderList property will be overwritten.
  17529. */
  17530. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17531. private _renderList;
  17532. /**
  17533. * Use this list to define the list of mesh you want to render.
  17534. */
  17535. renderList: Nullable<Array<AbstractMesh>>;
  17536. private _hookArray;
  17537. /**
  17538. * Define if particles should be rendered in your texture.
  17539. */
  17540. renderParticles: boolean;
  17541. /**
  17542. * Define if sprites should be rendered in your texture.
  17543. */
  17544. renderSprites: boolean;
  17545. /**
  17546. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17547. */
  17548. coordinatesMode: number;
  17549. /**
  17550. * Define the camera used to render the texture.
  17551. */
  17552. activeCamera: Nullable<Camera>;
  17553. /**
  17554. * Override the render function of the texture with your own one.
  17555. */
  17556. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17557. /**
  17558. * Define if camera post processes should be use while rendering the texture.
  17559. */
  17560. useCameraPostProcesses: boolean;
  17561. /**
  17562. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17563. */
  17564. ignoreCameraViewport: boolean;
  17565. private _postProcessManager;
  17566. private _postProcesses;
  17567. private _resizeObserver;
  17568. /**
  17569. * An event triggered when the texture is unbind.
  17570. */
  17571. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17572. /**
  17573. * An event triggered when the texture is unbind.
  17574. */
  17575. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17576. private _onAfterUnbindObserver;
  17577. /**
  17578. * Set a after unbind callback in the texture.
  17579. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17580. */
  17581. onAfterUnbind: () => void;
  17582. /**
  17583. * An event triggered before rendering the texture
  17584. */
  17585. onBeforeRenderObservable: Observable<number>;
  17586. private _onBeforeRenderObserver;
  17587. /**
  17588. * Set a before render callback in the texture.
  17589. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17590. */
  17591. onBeforeRender: (faceIndex: number) => void;
  17592. /**
  17593. * An event triggered after rendering the texture
  17594. */
  17595. onAfterRenderObservable: Observable<number>;
  17596. private _onAfterRenderObserver;
  17597. /**
  17598. * Set a after render callback in the texture.
  17599. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17600. */
  17601. onAfterRender: (faceIndex: number) => void;
  17602. /**
  17603. * An event triggered after the texture clear
  17604. */
  17605. onClearObservable: Observable<Engine>;
  17606. private _onClearObserver;
  17607. /**
  17608. * Set a clear callback in the texture.
  17609. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17610. */
  17611. onClear: (Engine: Engine) => void;
  17612. /**
  17613. * Define the clear color of the Render Target if it should be different from the scene.
  17614. */
  17615. clearColor: Color4;
  17616. protected _size: number | {
  17617. width: number;
  17618. height: number;
  17619. };
  17620. protected _initialSizeParameter: number | {
  17621. width: number;
  17622. height: number;
  17623. } | {
  17624. ratio: number;
  17625. };
  17626. protected _sizeRatio: Nullable<number>;
  17627. /** @hidden */
  17628. _generateMipMaps: boolean;
  17629. protected _renderingManager: RenderingManager;
  17630. /** @hidden */
  17631. _waitingRenderList: string[];
  17632. protected _doNotChangeAspectRatio: boolean;
  17633. protected _currentRefreshId: number;
  17634. protected _refreshRate: number;
  17635. protected _textureMatrix: Matrix;
  17636. protected _samples: number;
  17637. protected _renderTargetOptions: RenderTargetCreationOptions;
  17638. /**
  17639. * Gets render target creation options that were used.
  17640. */
  17641. readonly renderTargetOptions: RenderTargetCreationOptions;
  17642. protected _engine: Engine;
  17643. protected _onRatioRescale(): void;
  17644. /**
  17645. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17646. * It must define where the camera used to render the texture is set
  17647. */
  17648. boundingBoxPosition: Vector3;
  17649. private _boundingBoxSize;
  17650. /**
  17651. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17652. * When defined, the cubemap will switch to local mode
  17653. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17654. * @example https://www.babylonjs-playground.com/#RNASML
  17655. */
  17656. boundingBoxSize: Vector3;
  17657. /**
  17658. * In case the RTT has been created with a depth texture, get the associated
  17659. * depth texture.
  17660. * Otherwise, return null.
  17661. */
  17662. depthStencilTexture: Nullable<InternalTexture>;
  17663. /**
  17664. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17665. * or used a shadow, depth texture...
  17666. * @param name The friendly name of the texture
  17667. * @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)
  17668. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17669. * @param generateMipMaps True if mip maps need to be generated after render.
  17670. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17671. * @param type The type of the buffer in the RTT (int, half float, float...)
  17672. * @param isCube True if a cube texture needs to be created
  17673. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17674. * @param generateDepthBuffer True to generate a depth buffer
  17675. * @param generateStencilBuffer True to generate a stencil buffer
  17676. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17677. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17678. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17679. */
  17680. constructor(name: string, size: number | {
  17681. width: number;
  17682. height: number;
  17683. } | {
  17684. ratio: number;
  17685. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17686. /**
  17687. * Creates a depth stencil texture.
  17688. * This is only available in WebGL 2 or with the depth texture extension available.
  17689. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17690. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17691. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17692. */
  17693. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17694. private _processSizeParameter;
  17695. /**
  17696. * Define the number of samples to use in case of MSAA.
  17697. * It defaults to one meaning no MSAA has been enabled.
  17698. */
  17699. samples: number;
  17700. /**
  17701. * Resets the refresh counter of the texture and start bak from scratch.
  17702. * Could be useful to regenerate the texture if it is setup to render only once.
  17703. */
  17704. resetRefreshCounter(): void;
  17705. /**
  17706. * Define the refresh rate of the texture or the rendering frequency.
  17707. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17708. */
  17709. refreshRate: number;
  17710. /**
  17711. * Adds a post process to the render target rendering passes.
  17712. * @param postProcess define the post process to add
  17713. */
  17714. addPostProcess(postProcess: PostProcess): void;
  17715. /**
  17716. * Clear all the post processes attached to the render target
  17717. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17718. */
  17719. clearPostProcesses(dispose?: boolean): void;
  17720. /**
  17721. * Remove one of the post process from the list of attached post processes to the texture
  17722. * @param postProcess define the post process to remove from the list
  17723. */
  17724. removePostProcess(postProcess: PostProcess): void;
  17725. /** @hidden */
  17726. _shouldRender(): boolean;
  17727. /**
  17728. * Gets the actual render size of the texture.
  17729. * @returns the width of the render size
  17730. */
  17731. getRenderSize(): number;
  17732. /**
  17733. * Gets the actual render width of the texture.
  17734. * @returns the width of the render size
  17735. */
  17736. getRenderWidth(): number;
  17737. /**
  17738. * Gets the actual render height of the texture.
  17739. * @returns the height of the render size
  17740. */
  17741. getRenderHeight(): number;
  17742. /**
  17743. * Get if the texture can be rescaled or not.
  17744. */
  17745. readonly canRescale: boolean;
  17746. /**
  17747. * Resize the texture using a ratio.
  17748. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17749. */
  17750. scale(ratio: number): void;
  17751. /**
  17752. * Get the texture reflection matrix used to rotate/transform the reflection.
  17753. * @returns the reflection matrix
  17754. */
  17755. getReflectionTextureMatrix(): Matrix;
  17756. /**
  17757. * Resize the texture to a new desired size.
  17758. * Be carrefull as it will recreate all the data in the new texture.
  17759. * @param size Define the new size. It can be:
  17760. * - a number for squared texture,
  17761. * - an object containing { width: number, height: number }
  17762. * - or an object containing a ratio { ratio: number }
  17763. */
  17764. resize(size: number | {
  17765. width: number;
  17766. height: number;
  17767. } | {
  17768. ratio: number;
  17769. }): void;
  17770. /**
  17771. * Renders all the objects from the render list into the texture.
  17772. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17773. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17774. */
  17775. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17776. private _bestReflectionRenderTargetDimension;
  17777. /**
  17778. * @hidden
  17779. * @param faceIndex face index to bind to if this is a cubetexture
  17780. */
  17781. _bindFrameBuffer(faceIndex?: number): void;
  17782. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17783. private renderToTarget;
  17784. /**
  17785. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17786. * This allowed control for front to back rendering or reversly depending of the special needs.
  17787. *
  17788. * @param renderingGroupId The rendering group id corresponding to its index
  17789. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17790. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17791. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17792. */
  17793. 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;
  17794. /**
  17795. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17796. *
  17797. * @param renderingGroupId The rendering group id corresponding to its index
  17798. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17799. */
  17800. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17801. /**
  17802. * Clones the texture.
  17803. * @returns the cloned texture
  17804. */
  17805. clone(): RenderTargetTexture;
  17806. /**
  17807. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17808. * @returns The JSON representation of the texture
  17809. */
  17810. serialize(): any;
  17811. /**
  17812. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17813. */
  17814. disposeFramebufferObjects(): void;
  17815. /**
  17816. * Dispose the texture and release its associated resources.
  17817. */
  17818. dispose(): void;
  17819. /** @hidden */
  17820. _rebuild(): void;
  17821. /**
  17822. * Clear the info related to rendering groups preventing retention point in material dispose.
  17823. */
  17824. freeRenderingGroups(): void;
  17825. /**
  17826. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17827. * @returns the view count
  17828. */
  17829. getViewCount(): number;
  17830. }
  17831. /**
  17832. * Renders to multiple views with a single draw call
  17833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17834. */
  17835. export class MultiviewRenderTarget extends RenderTargetTexture {
  17836. /**
  17837. * Creates a multiview render target
  17838. * @param scene scene used with the render target
  17839. * @param size the size of the render target (used for each view)
  17840. */
  17841. constructor(scene: Scene, size?: number | {
  17842. width: number;
  17843. height: number;
  17844. } | {
  17845. ratio: number;
  17846. });
  17847. /**
  17848. * @hidden
  17849. * @param faceIndex the face index, if its a cube texture
  17850. */
  17851. _bindFrameBuffer(faceIndex?: number): void;
  17852. /**
  17853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17854. * @returns the view count
  17855. */
  17856. getViewCount(): number;
  17857. }
  17858. }
  17859. declare module BABYLON {
  17860. /**
  17861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17863. * You can then easily use it as a reflectionTexture on a flat surface.
  17864. * In case the surface is not a plane, please consider relying on reflection probes.
  17865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17866. */
  17867. export class MirrorTexture extends RenderTargetTexture {
  17868. private scene;
  17869. /**
  17870. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17871. * 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.
  17872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17873. */
  17874. mirrorPlane: Plane;
  17875. /**
  17876. * Define the blur ratio used to blur the reflection if needed.
  17877. */
  17878. blurRatio: number;
  17879. /**
  17880. * Define the adaptive blur kernel used to blur the reflection if needed.
  17881. * This will autocompute the closest best match for the `blurKernel`
  17882. */
  17883. adaptiveBlurKernel: number;
  17884. /**
  17885. * Define the blur kernel used to blur the reflection if needed.
  17886. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17887. */
  17888. blurKernel: number;
  17889. /**
  17890. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17891. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17892. */
  17893. blurKernelX: number;
  17894. /**
  17895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17897. */
  17898. blurKernelY: number;
  17899. private _autoComputeBlurKernel;
  17900. protected _onRatioRescale(): void;
  17901. private _updateGammaSpace;
  17902. private _imageProcessingConfigChangeObserver;
  17903. private _transformMatrix;
  17904. private _mirrorMatrix;
  17905. private _savedViewMatrix;
  17906. private _blurX;
  17907. private _blurY;
  17908. private _adaptiveBlurKernel;
  17909. private _blurKernelX;
  17910. private _blurKernelY;
  17911. private _blurRatio;
  17912. /**
  17913. * Instantiates a Mirror Texture.
  17914. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17915. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17916. * You can then easily use it as a reflectionTexture on a flat surface.
  17917. * In case the surface is not a plane, please consider relying on reflection probes.
  17918. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17919. * @param name
  17920. * @param size
  17921. * @param scene
  17922. * @param generateMipMaps
  17923. * @param type
  17924. * @param samplingMode
  17925. * @param generateDepthBuffer
  17926. */
  17927. constructor(name: string, size: number | {
  17928. width: number;
  17929. height: number;
  17930. } | {
  17931. ratio: number;
  17932. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17933. private _preparePostProcesses;
  17934. /**
  17935. * Clone the mirror texture.
  17936. * @returns the cloned texture
  17937. */
  17938. clone(): MirrorTexture;
  17939. /**
  17940. * Serialize the texture to a JSON representation you could use in Parse later on
  17941. * @returns the serialized JSON representation
  17942. */
  17943. serialize(): any;
  17944. /**
  17945. * Dispose the texture and release its associated resources.
  17946. */
  17947. dispose(): void;
  17948. }
  17949. }
  17950. declare module BABYLON {
  17951. /**
  17952. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17953. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17954. */
  17955. export class Texture extends BaseTexture {
  17956. /** @hidden */
  17957. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17958. /** @hidden */
  17959. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17960. /** @hidden */
  17961. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17962. /** nearest is mag = nearest and min = nearest and mip = linear */
  17963. static readonly NEAREST_SAMPLINGMODE: number;
  17964. /** nearest is mag = nearest and min = nearest and mip = linear */
  17965. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17967. static readonly BILINEAR_SAMPLINGMODE: number;
  17968. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17969. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17970. /** Trilinear is mag = linear and min = linear and mip = linear */
  17971. static readonly TRILINEAR_SAMPLINGMODE: number;
  17972. /** Trilinear is mag = linear and min = linear and mip = linear */
  17973. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17974. /** mag = nearest and min = nearest and mip = nearest */
  17975. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17976. /** mag = nearest and min = linear and mip = nearest */
  17977. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17978. /** mag = nearest and min = linear and mip = linear */
  17979. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17980. /** mag = nearest and min = linear and mip = none */
  17981. static readonly NEAREST_LINEAR: number;
  17982. /** mag = nearest and min = nearest and mip = none */
  17983. static readonly NEAREST_NEAREST: number;
  17984. /** mag = linear and min = nearest and mip = nearest */
  17985. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17986. /** mag = linear and min = nearest and mip = linear */
  17987. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17988. /** mag = linear and min = linear and mip = none */
  17989. static readonly LINEAR_LINEAR: number;
  17990. /** mag = linear and min = nearest and mip = none */
  17991. static readonly LINEAR_NEAREST: number;
  17992. /** Explicit coordinates mode */
  17993. static readonly EXPLICIT_MODE: number;
  17994. /** Spherical coordinates mode */
  17995. static readonly SPHERICAL_MODE: number;
  17996. /** Planar coordinates mode */
  17997. static readonly PLANAR_MODE: number;
  17998. /** Cubic coordinates mode */
  17999. static readonly CUBIC_MODE: number;
  18000. /** Projection coordinates mode */
  18001. static readonly PROJECTION_MODE: number;
  18002. /** Inverse Cubic coordinates mode */
  18003. static readonly SKYBOX_MODE: number;
  18004. /** Inverse Cubic coordinates mode */
  18005. static readonly INVCUBIC_MODE: number;
  18006. /** Equirectangular coordinates mode */
  18007. static readonly EQUIRECTANGULAR_MODE: number;
  18008. /** Equirectangular Fixed coordinates mode */
  18009. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18010. /** Equirectangular Fixed Mirrored coordinates mode */
  18011. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18012. /** Texture is not repeating outside of 0..1 UVs */
  18013. static readonly CLAMP_ADDRESSMODE: number;
  18014. /** Texture is repeating outside of 0..1 UVs */
  18015. static readonly WRAP_ADDRESSMODE: number;
  18016. /** Texture is repeating and mirrored */
  18017. static readonly MIRROR_ADDRESSMODE: number;
  18018. /**
  18019. * 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
  18020. */
  18021. static UseSerializedUrlIfAny: boolean;
  18022. /**
  18023. * Define the url of the texture.
  18024. */
  18025. url: Nullable<string>;
  18026. /**
  18027. * Define an offset on the texture to offset the u coordinates of the UVs
  18028. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18029. */
  18030. uOffset: number;
  18031. /**
  18032. * Define an offset on the texture to offset the v coordinates of the UVs
  18033. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18034. */
  18035. vOffset: number;
  18036. /**
  18037. * Define an offset on the texture to scale the u coordinates of the UVs
  18038. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18039. */
  18040. uScale: number;
  18041. /**
  18042. * Define an offset on the texture to scale the v coordinates of the UVs
  18043. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18044. */
  18045. vScale: number;
  18046. /**
  18047. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18048. * @see http://doc.babylonjs.com/how_to/more_materials
  18049. */
  18050. uAng: number;
  18051. /**
  18052. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18053. * @see http://doc.babylonjs.com/how_to/more_materials
  18054. */
  18055. vAng: number;
  18056. /**
  18057. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18058. * @see http://doc.babylonjs.com/how_to/more_materials
  18059. */
  18060. wAng: number;
  18061. /**
  18062. * Defines the center of rotation (U)
  18063. */
  18064. uRotationCenter: number;
  18065. /**
  18066. * Defines the center of rotation (V)
  18067. */
  18068. vRotationCenter: number;
  18069. /**
  18070. * Defines the center of rotation (W)
  18071. */
  18072. wRotationCenter: number;
  18073. /**
  18074. * Are mip maps generated for this texture or not.
  18075. */
  18076. readonly noMipmap: boolean;
  18077. /**
  18078. * List of inspectable custom properties (used by the Inspector)
  18079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18080. */
  18081. inspectableCustomProperties: IInspectable[];
  18082. private _noMipmap;
  18083. /** @hidden */
  18084. _invertY: boolean;
  18085. private _rowGenerationMatrix;
  18086. private _cachedTextureMatrix;
  18087. private _projectionModeMatrix;
  18088. private _t0;
  18089. private _t1;
  18090. private _t2;
  18091. private _cachedUOffset;
  18092. private _cachedVOffset;
  18093. private _cachedUScale;
  18094. private _cachedVScale;
  18095. private _cachedUAng;
  18096. private _cachedVAng;
  18097. private _cachedWAng;
  18098. private _cachedProjectionMatrixId;
  18099. private _cachedCoordinatesMode;
  18100. /** @hidden */
  18101. protected _initialSamplingMode: number;
  18102. /** @hidden */
  18103. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18104. private _deleteBuffer;
  18105. protected _format: Nullable<number>;
  18106. private _delayedOnLoad;
  18107. private _delayedOnError;
  18108. /**
  18109. * Observable triggered once the texture has been loaded.
  18110. */
  18111. onLoadObservable: Observable<Texture>;
  18112. protected _isBlocking: boolean;
  18113. /**
  18114. * Is the texture preventing material to render while loading.
  18115. * If false, a default texture will be used instead of the loading one during the preparation step.
  18116. */
  18117. isBlocking: boolean;
  18118. /**
  18119. * Get the current sampling mode associated with the texture.
  18120. */
  18121. readonly samplingMode: number;
  18122. /**
  18123. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18124. */
  18125. readonly invertY: boolean;
  18126. /**
  18127. * Instantiates a new texture.
  18128. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18129. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18130. * @param url define the url of the picture to load as a texture
  18131. * @param scene define the scene the texture will belong to
  18132. * @param noMipmap define if the texture will require mip maps or not
  18133. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18134. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18135. * @param onLoad define a callback triggered when the texture has been loaded
  18136. * @param onError define a callback triggered when an error occurred during the loading session
  18137. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18138. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18139. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18140. */
  18141. 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);
  18142. /**
  18143. * Update the url (and optional buffer) of this texture if url was null during construction.
  18144. * @param url the url of the texture
  18145. * @param buffer the buffer of the texture (defaults to null)
  18146. * @param onLoad callback called when the texture is loaded (defaults to null)
  18147. */
  18148. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18149. /**
  18150. * Finish the loading sequence of a texture flagged as delayed load.
  18151. * @hidden
  18152. */
  18153. delayLoad(): void;
  18154. private _prepareRowForTextureGeneration;
  18155. /**
  18156. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18157. * @returns the transform matrix of the texture.
  18158. */
  18159. getTextureMatrix(): Matrix;
  18160. /**
  18161. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18162. * @returns The reflection texture transform
  18163. */
  18164. getReflectionTextureMatrix(): Matrix;
  18165. /**
  18166. * Clones the texture.
  18167. * @returns the cloned texture
  18168. */
  18169. clone(): Texture;
  18170. /**
  18171. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18172. * @returns The JSON representation of the texture
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Get the current class name of the texture useful for serialization or dynamic coding.
  18177. * @returns "Texture"
  18178. */
  18179. getClassName(): string;
  18180. /**
  18181. * Dispose the texture and release its associated resources.
  18182. */
  18183. dispose(): void;
  18184. /**
  18185. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18186. * @param parsedTexture Define the JSON representation of the texture
  18187. * @param scene Define the scene the parsed texture should be instantiated in
  18188. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18189. * @returns The parsed texture if successful
  18190. */
  18191. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18192. /**
  18193. * Creates a texture from its base 64 representation.
  18194. * @param data Define the base64 payload without the data: prefix
  18195. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18196. * @param scene Define the scene the texture should belong to
  18197. * @param noMipmap Forces the texture to not create mip map information if true
  18198. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18199. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18200. * @param onLoad define a callback triggered when the texture has been loaded
  18201. * @param onError define a callback triggered when an error occurred during the loading session
  18202. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18203. * @returns the created texture
  18204. */
  18205. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18206. /**
  18207. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18208. * @param data Define the base64 payload without the data: prefix
  18209. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18210. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18211. * @param scene Define the scene the texture should belong to
  18212. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18213. * @param noMipmap Forces the texture to not create mip map information if true
  18214. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18215. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18216. * @param onLoad define a callback triggered when the texture has been loaded
  18217. * @param onError define a callback triggered when an error occurred during the loading session
  18218. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18219. * @returns the created texture
  18220. */
  18221. 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;
  18222. }
  18223. }
  18224. declare module BABYLON {
  18225. /**
  18226. * Raw texture can help creating a texture directly from an array of data.
  18227. * This can be super useful if you either get the data from an uncompressed source or
  18228. * if you wish to create your texture pixel by pixel.
  18229. */
  18230. export class RawTexture extends Texture {
  18231. /**
  18232. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18233. */
  18234. format: number;
  18235. private _engine;
  18236. /**
  18237. * Instantiates a new RawTexture.
  18238. * Raw texture can help creating a texture directly from an array of data.
  18239. * This can be super useful if you either get the data from an uncompressed source or
  18240. * if you wish to create your texture pixel by pixel.
  18241. * @param data define the array of data to use to create the texture
  18242. * @param width define the width of the texture
  18243. * @param height define the height of the texture
  18244. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18245. * @param scene define the scene the texture belongs to
  18246. * @param generateMipMaps define whether mip maps should be generated or not
  18247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18250. */
  18251. constructor(data: ArrayBufferView, width: number, height: number,
  18252. /**
  18253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18254. */
  18255. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18256. /**
  18257. * Updates the texture underlying data.
  18258. * @param data Define the new data of the texture
  18259. */
  18260. update(data: ArrayBufferView): void;
  18261. /**
  18262. * Creates a luminance texture from some data.
  18263. * @param data Define the texture data
  18264. * @param width Define the width of the texture
  18265. * @param height Define the height of the texture
  18266. * @param scene Define the scene the texture belongs to
  18267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18270. * @returns the luminance texture
  18271. */
  18272. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18273. /**
  18274. * Creates a luminance alpha texture from some data.
  18275. * @param data Define the texture data
  18276. * @param width Define the width of the texture
  18277. * @param height Define the height of the texture
  18278. * @param scene Define the scene the texture belongs to
  18279. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18280. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18281. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18282. * @returns the luminance alpha texture
  18283. */
  18284. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18285. /**
  18286. * Creates an alpha texture from some data.
  18287. * @param data Define the texture data
  18288. * @param width Define the width of the texture
  18289. * @param height Define the height of the texture
  18290. * @param scene Define the scene the texture belongs to
  18291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18294. * @returns the alpha texture
  18295. */
  18296. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18297. /**
  18298. * Creates a RGB texture from some data.
  18299. * @param data Define the texture data
  18300. * @param width Define the width of the texture
  18301. * @param height Define the height of the texture
  18302. * @param scene Define the scene the texture belongs to
  18303. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18307. * @returns the RGB alpha texture
  18308. */
  18309. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18310. /**
  18311. * Creates a RGBA texture from some data.
  18312. * @param data Define the texture data
  18313. * @param width Define the width of the texture
  18314. * @param height Define the height of the texture
  18315. * @param scene Define the scene the texture belongs to
  18316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18319. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18320. * @returns the RGBA texture
  18321. */
  18322. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18323. /**
  18324. * Creates a R texture from some data.
  18325. * @param data Define the texture data
  18326. * @param width Define the width of the texture
  18327. * @param height Define the height of the texture
  18328. * @param scene Define the scene the texture belongs to
  18329. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18330. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18331. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18332. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18333. * @returns the R texture
  18334. */
  18335. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18336. }
  18337. }
  18338. declare module BABYLON {
  18339. /**
  18340. * Defines a runtime animation
  18341. */
  18342. export class RuntimeAnimation {
  18343. private _events;
  18344. /**
  18345. * The current frame of the runtime animation
  18346. */
  18347. private _currentFrame;
  18348. /**
  18349. * The animation used by the runtime animation
  18350. */
  18351. private _animation;
  18352. /**
  18353. * The target of the runtime animation
  18354. */
  18355. private _target;
  18356. /**
  18357. * The initiating animatable
  18358. */
  18359. private _host;
  18360. /**
  18361. * The original value of the runtime animation
  18362. */
  18363. private _originalValue;
  18364. /**
  18365. * The original blend value of the runtime animation
  18366. */
  18367. private _originalBlendValue;
  18368. /**
  18369. * The offsets cache of the runtime animation
  18370. */
  18371. private _offsetsCache;
  18372. /**
  18373. * The high limits cache of the runtime animation
  18374. */
  18375. private _highLimitsCache;
  18376. /**
  18377. * Specifies if the runtime animation has been stopped
  18378. */
  18379. private _stopped;
  18380. /**
  18381. * The blending factor of the runtime animation
  18382. */
  18383. private _blendingFactor;
  18384. /**
  18385. * The BabylonJS scene
  18386. */
  18387. private _scene;
  18388. /**
  18389. * The current value of the runtime animation
  18390. */
  18391. private _currentValue;
  18392. /** @hidden */
  18393. _workValue: any;
  18394. /**
  18395. * The active target of the runtime animation
  18396. */
  18397. private _activeTarget;
  18398. /**
  18399. * The target path of the runtime animation
  18400. */
  18401. private _targetPath;
  18402. /**
  18403. * The weight of the runtime animation
  18404. */
  18405. private _weight;
  18406. /**
  18407. * The ratio offset of the runtime animation
  18408. */
  18409. private _ratioOffset;
  18410. /**
  18411. * The previous delay of the runtime animation
  18412. */
  18413. private _previousDelay;
  18414. /**
  18415. * The previous ratio of the runtime animation
  18416. */
  18417. private _previousRatio;
  18418. /**
  18419. * Gets the current frame of the runtime animation
  18420. */
  18421. readonly currentFrame: number;
  18422. /**
  18423. * Gets the weight of the runtime animation
  18424. */
  18425. readonly weight: number;
  18426. /**
  18427. * Gets the current value of the runtime animation
  18428. */
  18429. readonly currentValue: any;
  18430. /**
  18431. * Gets the target path of the runtime animation
  18432. */
  18433. readonly targetPath: string;
  18434. /**
  18435. * Gets the actual target of the runtime animation
  18436. */
  18437. readonly target: any;
  18438. /**
  18439. * Create a new RuntimeAnimation object
  18440. * @param target defines the target of the animation
  18441. * @param animation defines the source animation object
  18442. * @param scene defines the hosting scene
  18443. * @param host defines the initiating Animatable
  18444. */
  18445. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18446. /**
  18447. * Gets the animation from the runtime animation
  18448. */
  18449. readonly animation: Animation;
  18450. /**
  18451. * Resets the runtime animation to the beginning
  18452. * @param restoreOriginal defines whether to restore the target property to the original value
  18453. */
  18454. reset(restoreOriginal?: boolean): void;
  18455. /**
  18456. * Specifies if the runtime animation is stopped
  18457. * @returns Boolean specifying if the runtime animation is stopped
  18458. */
  18459. isStopped(): boolean;
  18460. /**
  18461. * Disposes of the runtime animation
  18462. */
  18463. dispose(): void;
  18464. /**
  18465. * Interpolates the animation from the current frame
  18466. * @param currentFrame The frame to interpolate the animation to
  18467. * @param repeatCount The number of times that the animation should loop
  18468. * @param loopMode The type of looping mode to use
  18469. * @param offsetValue Animation offset value
  18470. * @param highLimitValue The high limit value
  18471. * @returns The interpolated value
  18472. */
  18473. private _interpolate;
  18474. /**
  18475. * Apply the interpolated value to the target
  18476. * @param currentValue defines the value computed by the animation
  18477. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18478. */
  18479. setValue(currentValue: any, weight?: number): void;
  18480. private _setValue;
  18481. /**
  18482. * Gets the loop pmode of the runtime animation
  18483. * @returns Loop Mode
  18484. */
  18485. private _getCorrectLoopMode;
  18486. /**
  18487. * Move the current animation to a given frame
  18488. * @param frame defines the frame to move to
  18489. */
  18490. goToFrame(frame: number): void;
  18491. /**
  18492. * @hidden Internal use only
  18493. */
  18494. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18495. /**
  18496. * Execute the current animation
  18497. * @param delay defines the delay to add to the current frame
  18498. * @param from defines the lower bound of the animation range
  18499. * @param to defines the upper bound of the animation range
  18500. * @param loop defines if the current animation must loop
  18501. * @param speedRatio defines the current speed ratio
  18502. * @param weight defines the weight of the animation (default is -1 so no weight)
  18503. * @param onLoop optional callback called when animation loops
  18504. * @returns a boolean indicating if the animation is running
  18505. */
  18506. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18507. }
  18508. }
  18509. declare module BABYLON {
  18510. /**
  18511. * Class used to store an actual running animation
  18512. */
  18513. export class Animatable {
  18514. /** defines the target object */
  18515. target: any;
  18516. /** defines the starting frame number (default is 0) */
  18517. fromFrame: number;
  18518. /** defines the ending frame number (default is 100) */
  18519. toFrame: number;
  18520. /** defines if the animation must loop (default is false) */
  18521. loopAnimation: boolean;
  18522. /** defines a callback to call when animation ends if it is not looping */
  18523. onAnimationEnd?: (() => void) | null | undefined;
  18524. /** defines a callback to call when animation loops */
  18525. onAnimationLoop?: (() => void) | null | undefined;
  18526. private _localDelayOffset;
  18527. private _pausedDelay;
  18528. private _runtimeAnimations;
  18529. private _paused;
  18530. private _scene;
  18531. private _speedRatio;
  18532. private _weight;
  18533. private _syncRoot;
  18534. /**
  18535. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18536. * This will only apply for non looping animation (default is true)
  18537. */
  18538. disposeOnEnd: boolean;
  18539. /**
  18540. * Gets a boolean indicating if the animation has started
  18541. */
  18542. animationStarted: boolean;
  18543. /**
  18544. * Observer raised when the animation ends
  18545. */
  18546. onAnimationEndObservable: Observable<Animatable>;
  18547. /**
  18548. * Observer raised when the animation loops
  18549. */
  18550. onAnimationLoopObservable: Observable<Animatable>;
  18551. /**
  18552. * Gets the root Animatable used to synchronize and normalize animations
  18553. */
  18554. readonly syncRoot: Animatable;
  18555. /**
  18556. * Gets the current frame of the first RuntimeAnimation
  18557. * Used to synchronize Animatables
  18558. */
  18559. readonly masterFrame: number;
  18560. /**
  18561. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18562. */
  18563. weight: number;
  18564. /**
  18565. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18566. */
  18567. speedRatio: number;
  18568. /**
  18569. * Creates a new Animatable
  18570. * @param scene defines the hosting scene
  18571. * @param target defines the target object
  18572. * @param fromFrame defines the starting frame number (default is 0)
  18573. * @param toFrame defines the ending frame number (default is 100)
  18574. * @param loopAnimation defines if the animation must loop (default is false)
  18575. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18576. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18577. * @param animations defines a group of animation to add to the new Animatable
  18578. * @param onAnimationLoop defines a callback to call when animation loops
  18579. */
  18580. constructor(scene: Scene,
  18581. /** defines the target object */
  18582. target: any,
  18583. /** defines the starting frame number (default is 0) */
  18584. fromFrame?: number,
  18585. /** defines the ending frame number (default is 100) */
  18586. toFrame?: number,
  18587. /** defines if the animation must loop (default is false) */
  18588. loopAnimation?: boolean, speedRatio?: number,
  18589. /** defines a callback to call when animation ends if it is not looping */
  18590. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18591. /** defines a callback to call when animation loops */
  18592. onAnimationLoop?: (() => void) | null | undefined);
  18593. /**
  18594. * Synchronize and normalize current Animatable with a source Animatable
  18595. * This is useful when using animation weights and when animations are not of the same length
  18596. * @param root defines the root Animatable to synchronize with
  18597. * @returns the current Animatable
  18598. */
  18599. syncWith(root: Animatable): Animatable;
  18600. /**
  18601. * Gets the list of runtime animations
  18602. * @returns an array of RuntimeAnimation
  18603. */
  18604. getAnimations(): RuntimeAnimation[];
  18605. /**
  18606. * Adds more animations to the current animatable
  18607. * @param target defines the target of the animations
  18608. * @param animations defines the new animations to add
  18609. */
  18610. appendAnimations(target: any, animations: Animation[]): void;
  18611. /**
  18612. * Gets the source animation for a specific property
  18613. * @param property defines the propertyu to look for
  18614. * @returns null or the source animation for the given property
  18615. */
  18616. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18617. /**
  18618. * Gets the runtime animation for a specific property
  18619. * @param property defines the propertyu to look for
  18620. * @returns null or the runtime animation for the given property
  18621. */
  18622. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18623. /**
  18624. * Resets the animatable to its original state
  18625. */
  18626. reset(): void;
  18627. /**
  18628. * Allows the animatable to blend with current running animations
  18629. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18630. * @param blendingSpeed defines the blending speed to use
  18631. */
  18632. enableBlending(blendingSpeed: number): void;
  18633. /**
  18634. * Disable animation blending
  18635. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18636. */
  18637. disableBlending(): void;
  18638. /**
  18639. * Jump directly to a given frame
  18640. * @param frame defines the frame to jump to
  18641. */
  18642. goToFrame(frame: number): void;
  18643. /**
  18644. * Pause the animation
  18645. */
  18646. pause(): void;
  18647. /**
  18648. * Restart the animation
  18649. */
  18650. restart(): void;
  18651. private _raiseOnAnimationEnd;
  18652. /**
  18653. * Stop and delete the current animation
  18654. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18655. * @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)
  18656. */
  18657. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18658. /**
  18659. * Wait asynchronously for the animation to end
  18660. * @returns a promise which will be fullfilled when the animation ends
  18661. */
  18662. waitAsync(): Promise<Animatable>;
  18663. /** @hidden */
  18664. _animate(delay: number): boolean;
  18665. }
  18666. interface Scene {
  18667. /** @hidden */
  18668. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18669. /** @hidden */
  18670. _processLateAnimationBindingsForMatrices(holder: {
  18671. totalWeight: number;
  18672. animations: RuntimeAnimation[];
  18673. originalValue: Matrix;
  18674. }): any;
  18675. /** @hidden */
  18676. _processLateAnimationBindingsForQuaternions(holder: {
  18677. totalWeight: number;
  18678. animations: RuntimeAnimation[];
  18679. originalValue: Quaternion;
  18680. }, refQuaternion: Quaternion): Quaternion;
  18681. /** @hidden */
  18682. _processLateAnimationBindings(): void;
  18683. /**
  18684. * Will start the animation sequence of a given target
  18685. * @param target defines the target
  18686. * @param from defines from which frame should animation start
  18687. * @param to defines until which frame should animation run.
  18688. * @param weight defines the weight to apply to the animation (1.0 by default)
  18689. * @param loop defines if the animation loops
  18690. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18691. * @param onAnimationEnd defines the function to be executed when the animation ends
  18692. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18693. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18694. * @param onAnimationLoop defines the callback to call when an animation loops
  18695. * @returns the animatable object created for this animation
  18696. */
  18697. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18698. /**
  18699. * Will start the animation sequence of a given target
  18700. * @param target defines the target
  18701. * @param from defines from which frame should animation start
  18702. * @param to defines until which frame should animation run.
  18703. * @param loop defines if the animation loops
  18704. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18705. * @param onAnimationEnd defines the function to be executed when the animation ends
  18706. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18707. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18708. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18709. * @param onAnimationLoop defines the callback to call when an animation loops
  18710. * @returns the animatable object created for this animation
  18711. */
  18712. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18713. /**
  18714. * Will start the animation sequence of a given target and its hierarchy
  18715. * @param target defines the target
  18716. * @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.
  18717. * @param from defines from which frame should animation start
  18718. * @param to defines until which frame should animation run.
  18719. * @param loop defines if the animation loops
  18720. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18721. * @param onAnimationEnd defines the function to be executed when the animation ends
  18722. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18723. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18724. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18725. * @param onAnimationLoop defines the callback to call when an animation loops
  18726. * @returns the list of created animatables
  18727. */
  18728. 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[];
  18729. /**
  18730. * Begin a new animation on a given node
  18731. * @param target defines the target where the animation will take place
  18732. * @param animations defines the list of animations to start
  18733. * @param from defines the initial value
  18734. * @param to defines the final value
  18735. * @param loop defines if you want animation to loop (off by default)
  18736. * @param speedRatio defines the speed ratio to apply to all animations
  18737. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18738. * @param onAnimationLoop defines the callback to call when an animation loops
  18739. * @returns the list of created animatables
  18740. */
  18741. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18742. /**
  18743. * Begin a new animation on a given node and its hierarchy
  18744. * @param target defines the root node where the animation will take place
  18745. * @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.
  18746. * @param animations defines the list of animations to start
  18747. * @param from defines the initial value
  18748. * @param to defines the final value
  18749. * @param loop defines if you want animation to loop (off by default)
  18750. * @param speedRatio defines the speed ratio to apply to all animations
  18751. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18752. * @param onAnimationLoop defines the callback to call when an animation loops
  18753. * @returns the list of animatables created for all nodes
  18754. */
  18755. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18756. /**
  18757. * Gets the animatable associated with a specific target
  18758. * @param target defines the target of the animatable
  18759. * @returns the required animatable if found
  18760. */
  18761. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18762. /**
  18763. * Gets all animatables associated with a given target
  18764. * @param target defines the target to look animatables for
  18765. * @returns an array of Animatables
  18766. */
  18767. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18768. /**
  18769. * Will stop the animation of the given target
  18770. * @param target - the target
  18771. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18772. * @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)
  18773. */
  18774. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18775. /**
  18776. * Stops and removes all animations that have been applied to the scene
  18777. */
  18778. stopAllAnimations(): void;
  18779. }
  18780. interface Bone {
  18781. /**
  18782. * Copy an animation range from another bone
  18783. * @param source defines the source bone
  18784. * @param rangeName defines the range name to copy
  18785. * @param frameOffset defines the frame offset
  18786. * @param rescaleAsRequired defines if rescaling must be applied if required
  18787. * @param skelDimensionsRatio defines the scaling ratio
  18788. * @returns true if operation was successful
  18789. */
  18790. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18791. }
  18792. }
  18793. declare module BABYLON {
  18794. /**
  18795. * Class used to handle skinning animations
  18796. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18797. */
  18798. export class Skeleton implements IAnimatable {
  18799. /** defines the skeleton name */
  18800. name: string;
  18801. /** defines the skeleton Id */
  18802. id: string;
  18803. /**
  18804. * Defines the list of child bones
  18805. */
  18806. bones: Bone[];
  18807. /**
  18808. * Defines an estimate of the dimension of the skeleton at rest
  18809. */
  18810. dimensionsAtRest: Vector3;
  18811. /**
  18812. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18813. */
  18814. needInitialSkinMatrix: boolean;
  18815. /**
  18816. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18817. */
  18818. overrideMesh: Nullable<AbstractMesh>;
  18819. /**
  18820. * Gets the list of animations attached to this skeleton
  18821. */
  18822. animations: Array<Animation>;
  18823. private _scene;
  18824. private _isDirty;
  18825. private _transformMatrices;
  18826. private _transformMatrixTexture;
  18827. private _meshesWithPoseMatrix;
  18828. private _animatables;
  18829. private _identity;
  18830. private _synchronizedWithMesh;
  18831. private _ranges;
  18832. private _lastAbsoluteTransformsUpdateId;
  18833. private _canUseTextureForBones;
  18834. private _uniqueId;
  18835. /** @hidden */
  18836. _numBonesWithLinkedTransformNode: number;
  18837. /**
  18838. * Specifies if the skeleton should be serialized
  18839. */
  18840. doNotSerialize: boolean;
  18841. private _useTextureToStoreBoneMatrices;
  18842. /**
  18843. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18844. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18845. */
  18846. useTextureToStoreBoneMatrices: boolean;
  18847. private _animationPropertiesOverride;
  18848. /**
  18849. * Gets or sets the animation properties override
  18850. */
  18851. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18852. /**
  18853. * List of inspectable custom properties (used by the Inspector)
  18854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18855. */
  18856. inspectableCustomProperties: IInspectable[];
  18857. /**
  18858. * An observable triggered before computing the skeleton's matrices
  18859. */
  18860. onBeforeComputeObservable: Observable<Skeleton>;
  18861. /**
  18862. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18863. */
  18864. readonly isUsingTextureForMatrices: boolean;
  18865. /**
  18866. * Gets the unique ID of this skeleton
  18867. */
  18868. readonly uniqueId: number;
  18869. /**
  18870. * Creates a new skeleton
  18871. * @param name defines the skeleton name
  18872. * @param id defines the skeleton Id
  18873. * @param scene defines the hosting scene
  18874. */
  18875. constructor(
  18876. /** defines the skeleton name */
  18877. name: string,
  18878. /** defines the skeleton Id */
  18879. id: string, scene: Scene);
  18880. /**
  18881. * Gets the current object class name.
  18882. * @return the class name
  18883. */
  18884. getClassName(): string;
  18885. /**
  18886. * Returns an array containing the root bones
  18887. * @returns an array containing the root bones
  18888. */
  18889. getChildren(): Array<Bone>;
  18890. /**
  18891. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18892. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18893. * @returns a Float32Array containing matrices data
  18894. */
  18895. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18896. /**
  18897. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18898. * @returns a raw texture containing the data
  18899. */
  18900. getTransformMatrixTexture(): Nullable<RawTexture>;
  18901. /**
  18902. * Gets the current hosting scene
  18903. * @returns a scene object
  18904. */
  18905. getScene(): Scene;
  18906. /**
  18907. * Gets a string representing the current skeleton data
  18908. * @param fullDetails defines a boolean indicating if we want a verbose version
  18909. * @returns a string representing the current skeleton data
  18910. */
  18911. toString(fullDetails?: boolean): string;
  18912. /**
  18913. * Get bone's index searching by name
  18914. * @param name defines bone's name to search for
  18915. * @return the indice of the bone. Returns -1 if not found
  18916. */
  18917. getBoneIndexByName(name: string): number;
  18918. /**
  18919. * Creater a new animation range
  18920. * @param name defines the name of the range
  18921. * @param from defines the start key
  18922. * @param to defines the end key
  18923. */
  18924. createAnimationRange(name: string, from: number, to: number): void;
  18925. /**
  18926. * Delete a specific animation range
  18927. * @param name defines the name of the range
  18928. * @param deleteFrames defines if frames must be removed as well
  18929. */
  18930. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18931. /**
  18932. * Gets a specific animation range
  18933. * @param name defines the name of the range to look for
  18934. * @returns the requested animation range or null if not found
  18935. */
  18936. getAnimationRange(name: string): Nullable<AnimationRange>;
  18937. /**
  18938. * Gets the list of all animation ranges defined on this skeleton
  18939. * @returns an array
  18940. */
  18941. getAnimationRanges(): Nullable<AnimationRange>[];
  18942. /**
  18943. * Copy animation range from a source skeleton.
  18944. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18945. * @param source defines the source skeleton
  18946. * @param name defines the name of the range to copy
  18947. * @param rescaleAsRequired defines if rescaling must be applied if required
  18948. * @returns true if operation was successful
  18949. */
  18950. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18951. /**
  18952. * Forces the skeleton to go to rest pose
  18953. */
  18954. returnToRest(): void;
  18955. private _getHighestAnimationFrame;
  18956. /**
  18957. * Begin a specific animation range
  18958. * @param name defines the name of the range to start
  18959. * @param loop defines if looping must be turned on (false by default)
  18960. * @param speedRatio defines the speed ratio to apply (1 by default)
  18961. * @param onAnimationEnd defines a callback which will be called when animation will end
  18962. * @returns a new animatable
  18963. */
  18964. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18965. /** @hidden */
  18966. _markAsDirty(): void;
  18967. /** @hidden */
  18968. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18969. /** @hidden */
  18970. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18971. private _computeTransformMatrices;
  18972. /**
  18973. * Build all resources required to render a skeleton
  18974. */
  18975. prepare(): void;
  18976. /**
  18977. * Gets the list of animatables currently running for this skeleton
  18978. * @returns an array of animatables
  18979. */
  18980. getAnimatables(): IAnimatable[];
  18981. /**
  18982. * Clone the current skeleton
  18983. * @param name defines the name of the new skeleton
  18984. * @param id defines the id of the enw skeleton
  18985. * @returns the new skeleton
  18986. */
  18987. clone(name: string, id: string): Skeleton;
  18988. /**
  18989. * Enable animation blending for this skeleton
  18990. * @param blendingSpeed defines the blending speed to apply
  18991. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18992. */
  18993. enableBlending(blendingSpeed?: number): void;
  18994. /**
  18995. * Releases all resources associated with the current skeleton
  18996. */
  18997. dispose(): void;
  18998. /**
  18999. * Serialize the skeleton in a JSON object
  19000. * @returns a JSON object
  19001. */
  19002. serialize(): any;
  19003. /**
  19004. * Creates a new skeleton from serialized data
  19005. * @param parsedSkeleton defines the serialized data
  19006. * @param scene defines the hosting scene
  19007. * @returns a new skeleton
  19008. */
  19009. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19010. /**
  19011. * Compute all node absolute transforms
  19012. * @param forceUpdate defines if computation must be done even if cache is up to date
  19013. */
  19014. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19015. /**
  19016. * Gets the root pose matrix
  19017. * @returns a matrix
  19018. */
  19019. getPoseMatrix(): Nullable<Matrix>;
  19020. /**
  19021. * Sorts bones per internal index
  19022. */
  19023. sortBones(): void;
  19024. private _sortBones;
  19025. }
  19026. }
  19027. declare module BABYLON {
  19028. /**
  19029. * Defines a target to use with MorphTargetManager
  19030. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19031. */
  19032. export class MorphTarget implements IAnimatable {
  19033. /** defines the name of the target */
  19034. name: string;
  19035. /**
  19036. * Gets or sets the list of animations
  19037. */
  19038. animations: Animation[];
  19039. private _scene;
  19040. private _positions;
  19041. private _normals;
  19042. private _tangents;
  19043. private _influence;
  19044. /**
  19045. * Observable raised when the influence changes
  19046. */
  19047. onInfluenceChanged: Observable<boolean>;
  19048. /** @hidden */
  19049. _onDataLayoutChanged: Observable<void>;
  19050. /**
  19051. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19052. */
  19053. influence: number;
  19054. /**
  19055. * Gets or sets the id of the morph Target
  19056. */
  19057. id: string;
  19058. private _animationPropertiesOverride;
  19059. /**
  19060. * Gets or sets the animation properties override
  19061. */
  19062. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19063. /**
  19064. * Creates a new MorphTarget
  19065. * @param name defines the name of the target
  19066. * @param influence defines the influence to use
  19067. * @param scene defines the scene the morphtarget belongs to
  19068. */
  19069. constructor(
  19070. /** defines the name of the target */
  19071. name: string, influence?: number, scene?: Nullable<Scene>);
  19072. /**
  19073. * Gets a boolean defining if the target contains position data
  19074. */
  19075. readonly hasPositions: boolean;
  19076. /**
  19077. * Gets a boolean defining if the target contains normal data
  19078. */
  19079. readonly hasNormals: boolean;
  19080. /**
  19081. * Gets a boolean defining if the target contains tangent data
  19082. */
  19083. readonly hasTangents: boolean;
  19084. /**
  19085. * Affects position data to this target
  19086. * @param data defines the position data to use
  19087. */
  19088. setPositions(data: Nullable<FloatArray>): void;
  19089. /**
  19090. * Gets the position data stored in this target
  19091. * @returns a FloatArray containing the position data (or null if not present)
  19092. */
  19093. getPositions(): Nullable<FloatArray>;
  19094. /**
  19095. * Affects normal data to this target
  19096. * @param data defines the normal data to use
  19097. */
  19098. setNormals(data: Nullable<FloatArray>): void;
  19099. /**
  19100. * Gets the normal data stored in this target
  19101. * @returns a FloatArray containing the normal data (or null if not present)
  19102. */
  19103. getNormals(): Nullable<FloatArray>;
  19104. /**
  19105. * Affects tangent data to this target
  19106. * @param data defines the tangent data to use
  19107. */
  19108. setTangents(data: Nullable<FloatArray>): void;
  19109. /**
  19110. * Gets the tangent data stored in this target
  19111. * @returns a FloatArray containing the tangent data (or null if not present)
  19112. */
  19113. getTangents(): Nullable<FloatArray>;
  19114. /**
  19115. * Serializes the current target into a Serialization object
  19116. * @returns the serialized object
  19117. */
  19118. serialize(): any;
  19119. /**
  19120. * Returns the string "MorphTarget"
  19121. * @returns "MorphTarget"
  19122. */
  19123. getClassName(): string;
  19124. /**
  19125. * Creates a new target from serialized data
  19126. * @param serializationObject defines the serialized data to use
  19127. * @returns a new MorphTarget
  19128. */
  19129. static Parse(serializationObject: any): MorphTarget;
  19130. /**
  19131. * Creates a MorphTarget from mesh data
  19132. * @param mesh defines the source mesh
  19133. * @param name defines the name to use for the new target
  19134. * @param influence defines the influence to attach to the target
  19135. * @returns a new MorphTarget
  19136. */
  19137. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19138. }
  19139. }
  19140. declare module BABYLON {
  19141. /**
  19142. * This class is used to deform meshes using morphing between different targets
  19143. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19144. */
  19145. export class MorphTargetManager {
  19146. private _targets;
  19147. private _targetInfluenceChangedObservers;
  19148. private _targetDataLayoutChangedObservers;
  19149. private _activeTargets;
  19150. private _scene;
  19151. private _influences;
  19152. private _supportsNormals;
  19153. private _supportsTangents;
  19154. private _vertexCount;
  19155. private _uniqueId;
  19156. private _tempInfluences;
  19157. /**
  19158. * Creates a new MorphTargetManager
  19159. * @param scene defines the current scene
  19160. */
  19161. constructor(scene?: Nullable<Scene>);
  19162. /**
  19163. * Gets the unique ID of this manager
  19164. */
  19165. readonly uniqueId: number;
  19166. /**
  19167. * Gets the number of vertices handled by this manager
  19168. */
  19169. readonly vertexCount: number;
  19170. /**
  19171. * Gets a boolean indicating if this manager supports morphing of normals
  19172. */
  19173. readonly supportsNormals: boolean;
  19174. /**
  19175. * Gets a boolean indicating if this manager supports morphing of tangents
  19176. */
  19177. readonly supportsTangents: boolean;
  19178. /**
  19179. * Gets the number of targets stored in this manager
  19180. */
  19181. readonly numTargets: number;
  19182. /**
  19183. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19184. */
  19185. readonly numInfluencers: number;
  19186. /**
  19187. * Gets the list of influences (one per target)
  19188. */
  19189. readonly influences: Float32Array;
  19190. /**
  19191. * Gets the active target at specified index. An active target is a target with an influence > 0
  19192. * @param index defines the index to check
  19193. * @returns the requested target
  19194. */
  19195. getActiveTarget(index: number): MorphTarget;
  19196. /**
  19197. * Gets the target at specified index
  19198. * @param index defines the index to check
  19199. * @returns the requested target
  19200. */
  19201. getTarget(index: number): MorphTarget;
  19202. /**
  19203. * Add a new target to this manager
  19204. * @param target defines the target to add
  19205. */
  19206. addTarget(target: MorphTarget): void;
  19207. /**
  19208. * Removes a target from the manager
  19209. * @param target defines the target to remove
  19210. */
  19211. removeTarget(target: MorphTarget): void;
  19212. /**
  19213. * Serializes the current manager into a Serialization object
  19214. * @returns the serialized object
  19215. */
  19216. serialize(): any;
  19217. private _syncActiveTargets;
  19218. /**
  19219. * Syncrhonize the targets with all the meshes using this morph target manager
  19220. */
  19221. synchronize(): void;
  19222. /**
  19223. * Creates a new MorphTargetManager from serialized data
  19224. * @param serializationObject defines the serialized data
  19225. * @param scene defines the hosting scene
  19226. * @returns the new MorphTargetManager
  19227. */
  19228. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19229. }
  19230. }
  19231. declare module BABYLON {
  19232. /**
  19233. * Mesh representing the gorund
  19234. */
  19235. export class GroundMesh extends Mesh {
  19236. /** If octree should be generated */
  19237. generateOctree: boolean;
  19238. private _heightQuads;
  19239. /** @hidden */
  19240. _subdivisionsX: number;
  19241. /** @hidden */
  19242. _subdivisionsY: number;
  19243. /** @hidden */
  19244. _width: number;
  19245. /** @hidden */
  19246. _height: number;
  19247. /** @hidden */
  19248. _minX: number;
  19249. /** @hidden */
  19250. _maxX: number;
  19251. /** @hidden */
  19252. _minZ: number;
  19253. /** @hidden */
  19254. _maxZ: number;
  19255. constructor(name: string, scene: Scene);
  19256. /**
  19257. * "GroundMesh"
  19258. * @returns "GroundMesh"
  19259. */
  19260. getClassName(): string;
  19261. /**
  19262. * The minimum of x and y subdivisions
  19263. */
  19264. readonly subdivisions: number;
  19265. /**
  19266. * X subdivisions
  19267. */
  19268. readonly subdivisionsX: number;
  19269. /**
  19270. * Y subdivisions
  19271. */
  19272. readonly subdivisionsY: number;
  19273. /**
  19274. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19275. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19276. * @param chunksCount the number of subdivisions for x and y
  19277. * @param octreeBlocksSize (Default: 32)
  19278. */
  19279. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19280. /**
  19281. * Returns a height (y) value in the Worl system :
  19282. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19283. * @param x x coordinate
  19284. * @param z z coordinate
  19285. * @returns the ground y position if (x, z) are outside the ground surface.
  19286. */
  19287. getHeightAtCoordinates(x: number, z: number): number;
  19288. /**
  19289. * Returns a normalized vector (Vector3) orthogonal to the ground
  19290. * at the ground coordinates (x, z) expressed in the World system.
  19291. * @param x x coordinate
  19292. * @param z z coordinate
  19293. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19294. */
  19295. getNormalAtCoordinates(x: number, z: number): Vector3;
  19296. /**
  19297. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19298. * at the ground coordinates (x, z) expressed in the World system.
  19299. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19300. * @param x x coordinate
  19301. * @param z z coordinate
  19302. * @param ref vector to store the result
  19303. * @returns the GroundMesh.
  19304. */
  19305. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19306. /**
  19307. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19308. * if the ground has been updated.
  19309. * This can be used in the render loop.
  19310. * @returns the GroundMesh.
  19311. */
  19312. updateCoordinateHeights(): GroundMesh;
  19313. private _getFacetAt;
  19314. private _initHeightQuads;
  19315. private _computeHeightQuads;
  19316. /**
  19317. * Serializes this ground mesh
  19318. * @param serializationObject object to write serialization to
  19319. */
  19320. serialize(serializationObject: any): void;
  19321. /**
  19322. * Parses a serialized ground mesh
  19323. * @param parsedMesh the serialized mesh
  19324. * @param scene the scene to create the ground mesh in
  19325. * @returns the created ground mesh
  19326. */
  19327. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19328. }
  19329. }
  19330. declare module BABYLON {
  19331. /**
  19332. * Interface for Physics-Joint data
  19333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19334. */
  19335. export interface PhysicsJointData {
  19336. /**
  19337. * The main pivot of the joint
  19338. */
  19339. mainPivot?: Vector3;
  19340. /**
  19341. * The connected pivot of the joint
  19342. */
  19343. connectedPivot?: Vector3;
  19344. /**
  19345. * The main axis of the joint
  19346. */
  19347. mainAxis?: Vector3;
  19348. /**
  19349. * The connected axis of the joint
  19350. */
  19351. connectedAxis?: Vector3;
  19352. /**
  19353. * The collision of the joint
  19354. */
  19355. collision?: boolean;
  19356. /**
  19357. * Native Oimo/Cannon/Energy data
  19358. */
  19359. nativeParams?: any;
  19360. }
  19361. /**
  19362. * This is a holder class for the physics joint created by the physics plugin
  19363. * It holds a set of functions to control the underlying joint
  19364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19365. */
  19366. export class PhysicsJoint {
  19367. /**
  19368. * The type of the physics joint
  19369. */
  19370. type: number;
  19371. /**
  19372. * The data for the physics joint
  19373. */
  19374. jointData: PhysicsJointData;
  19375. private _physicsJoint;
  19376. protected _physicsPlugin: IPhysicsEnginePlugin;
  19377. /**
  19378. * Initializes the physics joint
  19379. * @param type The type of the physics joint
  19380. * @param jointData The data for the physics joint
  19381. */
  19382. constructor(
  19383. /**
  19384. * The type of the physics joint
  19385. */
  19386. type: number,
  19387. /**
  19388. * The data for the physics joint
  19389. */
  19390. jointData: PhysicsJointData);
  19391. /**
  19392. * Gets the physics joint
  19393. */
  19394. /**
  19395. * Sets the physics joint
  19396. */
  19397. physicsJoint: any;
  19398. /**
  19399. * Sets the physics plugin
  19400. */
  19401. physicsPlugin: IPhysicsEnginePlugin;
  19402. /**
  19403. * Execute a function that is physics-plugin specific.
  19404. * @param {Function} func the function that will be executed.
  19405. * It accepts two parameters: the physics world and the physics joint
  19406. */
  19407. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19408. /**
  19409. * Distance-Joint type
  19410. */
  19411. static DistanceJoint: number;
  19412. /**
  19413. * Hinge-Joint type
  19414. */
  19415. static HingeJoint: number;
  19416. /**
  19417. * Ball-and-Socket joint type
  19418. */
  19419. static BallAndSocketJoint: number;
  19420. /**
  19421. * Wheel-Joint type
  19422. */
  19423. static WheelJoint: number;
  19424. /**
  19425. * Slider-Joint type
  19426. */
  19427. static SliderJoint: number;
  19428. /**
  19429. * Prismatic-Joint type
  19430. */
  19431. static PrismaticJoint: number;
  19432. /**
  19433. * Universal-Joint type
  19434. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19435. */
  19436. static UniversalJoint: number;
  19437. /**
  19438. * Hinge-Joint 2 type
  19439. */
  19440. static Hinge2Joint: number;
  19441. /**
  19442. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19443. */
  19444. static PointToPointJoint: number;
  19445. /**
  19446. * Spring-Joint type
  19447. */
  19448. static SpringJoint: number;
  19449. /**
  19450. * Lock-Joint type
  19451. */
  19452. static LockJoint: number;
  19453. }
  19454. /**
  19455. * A class representing a physics distance joint
  19456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19457. */
  19458. export class DistanceJoint extends PhysicsJoint {
  19459. /**
  19460. *
  19461. * @param jointData The data for the Distance-Joint
  19462. */
  19463. constructor(jointData: DistanceJointData);
  19464. /**
  19465. * Update the predefined distance.
  19466. * @param maxDistance The maximum preferred distance
  19467. * @param minDistance The minimum preferred distance
  19468. */
  19469. updateDistance(maxDistance: number, minDistance?: number): void;
  19470. }
  19471. /**
  19472. * Represents a Motor-Enabled Joint
  19473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19474. */
  19475. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19476. /**
  19477. * Initializes the Motor-Enabled Joint
  19478. * @param type The type of the joint
  19479. * @param jointData The physica joint data for the joint
  19480. */
  19481. constructor(type: number, jointData: PhysicsJointData);
  19482. /**
  19483. * Set the motor values.
  19484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19485. * @param force the force to apply
  19486. * @param maxForce max force for this motor.
  19487. */
  19488. setMotor(force?: number, maxForce?: number): void;
  19489. /**
  19490. * Set the motor's limits.
  19491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19492. * @param upperLimit The upper limit of the motor
  19493. * @param lowerLimit The lower limit of the motor
  19494. */
  19495. setLimit(upperLimit: number, lowerLimit?: number): void;
  19496. }
  19497. /**
  19498. * This class represents a single physics Hinge-Joint
  19499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19500. */
  19501. export class HingeJoint extends MotorEnabledJoint {
  19502. /**
  19503. * Initializes the Hinge-Joint
  19504. * @param jointData The joint data for the Hinge-Joint
  19505. */
  19506. constructor(jointData: PhysicsJointData);
  19507. /**
  19508. * Set the motor values.
  19509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19510. * @param {number} force the force to apply
  19511. * @param {number} maxForce max force for this motor.
  19512. */
  19513. setMotor(force?: number, maxForce?: number): void;
  19514. /**
  19515. * Set the motor's limits.
  19516. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19517. * @param upperLimit The upper limit of the motor
  19518. * @param lowerLimit The lower limit of the motor
  19519. */
  19520. setLimit(upperLimit: number, lowerLimit?: number): void;
  19521. }
  19522. /**
  19523. * This class represents a dual hinge physics joint (same as wheel joint)
  19524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19525. */
  19526. export class Hinge2Joint extends MotorEnabledJoint {
  19527. /**
  19528. * Initializes the Hinge2-Joint
  19529. * @param jointData The joint data for the Hinge2-Joint
  19530. */
  19531. constructor(jointData: PhysicsJointData);
  19532. /**
  19533. * Set the motor values.
  19534. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19535. * @param {number} targetSpeed the speed the motor is to reach
  19536. * @param {number} maxForce max force for this motor.
  19537. * @param {motorIndex} the motor's index, 0 or 1.
  19538. */
  19539. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19540. /**
  19541. * Set the motor limits.
  19542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19543. * @param {number} upperLimit the upper limit
  19544. * @param {number} lowerLimit lower limit
  19545. * @param {motorIndex} the motor's index, 0 or 1.
  19546. */
  19547. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19548. }
  19549. /**
  19550. * Interface for a motor enabled joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export interface IMotorEnabledJoint {
  19554. /**
  19555. * Physics joint
  19556. */
  19557. physicsJoint: any;
  19558. /**
  19559. * Sets the motor of the motor-enabled joint
  19560. * @param force The force of the motor
  19561. * @param maxForce The maximum force of the motor
  19562. * @param motorIndex The index of the motor
  19563. */
  19564. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19565. /**
  19566. * Sets the limit of the motor
  19567. * @param upperLimit The upper limit of the motor
  19568. * @param lowerLimit The lower limit of the motor
  19569. * @param motorIndex The index of the motor
  19570. */
  19571. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19572. }
  19573. /**
  19574. * Joint data for a Distance-Joint
  19575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19576. */
  19577. export interface DistanceJointData extends PhysicsJointData {
  19578. /**
  19579. * Max distance the 2 joint objects can be apart
  19580. */
  19581. maxDistance: number;
  19582. }
  19583. /**
  19584. * Joint data from a spring joint
  19585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19586. */
  19587. export interface SpringJointData extends PhysicsJointData {
  19588. /**
  19589. * Length of the spring
  19590. */
  19591. length: number;
  19592. /**
  19593. * Stiffness of the spring
  19594. */
  19595. stiffness: number;
  19596. /**
  19597. * Damping of the spring
  19598. */
  19599. damping: number;
  19600. /** this callback will be called when applying the force to the impostors. */
  19601. forceApplicationCallback: () => void;
  19602. }
  19603. }
  19604. declare module BABYLON {
  19605. /**
  19606. * Holds the data for the raycast result
  19607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19608. */
  19609. export class PhysicsRaycastResult {
  19610. private _hasHit;
  19611. private _hitDistance;
  19612. private _hitNormalWorld;
  19613. private _hitPointWorld;
  19614. private _rayFromWorld;
  19615. private _rayToWorld;
  19616. /**
  19617. * Gets if there was a hit
  19618. */
  19619. readonly hasHit: boolean;
  19620. /**
  19621. * Gets the distance from the hit
  19622. */
  19623. readonly hitDistance: number;
  19624. /**
  19625. * Gets the hit normal/direction in the world
  19626. */
  19627. readonly hitNormalWorld: Vector3;
  19628. /**
  19629. * Gets the hit point in the world
  19630. */
  19631. readonly hitPointWorld: Vector3;
  19632. /**
  19633. * Gets the ray "start point" of the ray in the world
  19634. */
  19635. readonly rayFromWorld: Vector3;
  19636. /**
  19637. * Gets the ray "end point" of the ray in the world
  19638. */
  19639. readonly rayToWorld: Vector3;
  19640. /**
  19641. * Sets the hit data (normal & point in world space)
  19642. * @param hitNormalWorld defines the normal in world space
  19643. * @param hitPointWorld defines the point in world space
  19644. */
  19645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19646. /**
  19647. * Sets the distance from the start point to the hit point
  19648. * @param distance
  19649. */
  19650. setHitDistance(distance: number): void;
  19651. /**
  19652. * Calculates the distance manually
  19653. */
  19654. calculateHitDistance(): void;
  19655. /**
  19656. * Resets all the values to default
  19657. * @param from The from point on world space
  19658. * @param to The to point on world space
  19659. */
  19660. reset(from?: Vector3, to?: Vector3): void;
  19661. }
  19662. /**
  19663. * Interface for the size containing width and height
  19664. */
  19665. interface IXYZ {
  19666. /**
  19667. * X
  19668. */
  19669. x: number;
  19670. /**
  19671. * Y
  19672. */
  19673. y: number;
  19674. /**
  19675. * Z
  19676. */
  19677. z: number;
  19678. }
  19679. }
  19680. declare module BABYLON {
  19681. /**
  19682. * Interface used to describe a physics joint
  19683. */
  19684. export interface PhysicsImpostorJoint {
  19685. /** Defines the main impostor to which the joint is linked */
  19686. mainImpostor: PhysicsImpostor;
  19687. /** Defines the impostor that is connected to the main impostor using this joint */
  19688. connectedImpostor: PhysicsImpostor;
  19689. /** Defines the joint itself */
  19690. joint: PhysicsJoint;
  19691. }
  19692. /** @hidden */
  19693. export interface IPhysicsEnginePlugin {
  19694. world: any;
  19695. name: string;
  19696. setGravity(gravity: Vector3): void;
  19697. setTimeStep(timeStep: number): void;
  19698. getTimeStep(): number;
  19699. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19700. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19701. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19702. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19703. removePhysicsBody(impostor: PhysicsImpostor): void;
  19704. generateJoint(joint: PhysicsImpostorJoint): void;
  19705. removeJoint(joint: PhysicsImpostorJoint): void;
  19706. isSupported(): boolean;
  19707. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19708. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19710. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19711. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19712. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19713. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19714. getBodyMass(impostor: PhysicsImpostor): number;
  19715. getBodyFriction(impostor: PhysicsImpostor): number;
  19716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19717. getBodyRestitution(impostor: PhysicsImpostor): number;
  19718. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19719. getBodyPressure?(impostor: PhysicsImpostor): number;
  19720. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19721. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19722. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19723. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19724. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19725. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19726. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19727. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19728. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19729. sleepBody(impostor: PhysicsImpostor): void;
  19730. wakeUpBody(impostor: PhysicsImpostor): void;
  19731. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19732. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19733. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19734. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19735. getRadius(impostor: PhysicsImpostor): number;
  19736. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19738. dispose(): void;
  19739. }
  19740. /**
  19741. * Interface used to define a physics engine
  19742. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19743. */
  19744. export interface IPhysicsEngine {
  19745. /**
  19746. * Gets the gravity vector used by the simulation
  19747. */
  19748. gravity: Vector3;
  19749. /**
  19750. * Sets the gravity vector used by the simulation
  19751. * @param gravity defines the gravity vector to use
  19752. */
  19753. setGravity(gravity: Vector3): void;
  19754. /**
  19755. * Set the time step of the physics engine.
  19756. * Default is 1/60.
  19757. * To slow it down, enter 1/600 for example.
  19758. * To speed it up, 1/30
  19759. * @param newTimeStep the new timestep to apply to this world.
  19760. */
  19761. setTimeStep(newTimeStep: number): void;
  19762. /**
  19763. * Get the time step of the physics engine.
  19764. * @returns the current time step
  19765. */
  19766. getTimeStep(): number;
  19767. /**
  19768. * Release all resources
  19769. */
  19770. dispose(): void;
  19771. /**
  19772. * Gets the name of the current physics plugin
  19773. * @returns the name of the plugin
  19774. */
  19775. getPhysicsPluginName(): string;
  19776. /**
  19777. * Adding a new impostor for the impostor tracking.
  19778. * This will be done by the impostor itself.
  19779. * @param impostor the impostor to add
  19780. */
  19781. addImpostor(impostor: PhysicsImpostor): void;
  19782. /**
  19783. * Remove an impostor from the engine.
  19784. * This impostor and its mesh will not longer be updated by the physics engine.
  19785. * @param impostor the impostor to remove
  19786. */
  19787. removeImpostor(impostor: PhysicsImpostor): void;
  19788. /**
  19789. * Add a joint to the physics engine
  19790. * @param mainImpostor defines the main impostor to which the joint is added.
  19791. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19792. * @param joint defines the joint that will connect both impostors.
  19793. */
  19794. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19795. /**
  19796. * Removes a joint from the simulation
  19797. * @param mainImpostor defines the impostor used with the joint
  19798. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19799. * @param joint defines the joint to remove
  19800. */
  19801. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19802. /**
  19803. * Gets the current plugin used to run the simulation
  19804. * @returns current plugin
  19805. */
  19806. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19807. /**
  19808. * Gets the list of physic impostors
  19809. * @returns an array of PhysicsImpostor
  19810. */
  19811. getImpostors(): Array<PhysicsImpostor>;
  19812. /**
  19813. * Gets the impostor for a physics enabled object
  19814. * @param object defines the object impersonated by the impostor
  19815. * @returns the PhysicsImpostor or null if not found
  19816. */
  19817. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19818. /**
  19819. * Gets the impostor for a physics body object
  19820. * @param body defines physics body used by the impostor
  19821. * @returns the PhysicsImpostor or null if not found
  19822. */
  19823. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19824. /**
  19825. * Does a raycast in the physics world
  19826. * @param from when should the ray start?
  19827. * @param to when should the ray end?
  19828. * @returns PhysicsRaycastResult
  19829. */
  19830. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19831. /**
  19832. * Called by the scene. No need to call it.
  19833. * @param delta defines the timespam between frames
  19834. */
  19835. _step(delta: number): void;
  19836. }
  19837. }
  19838. declare module BABYLON {
  19839. /**
  19840. * The interface for the physics imposter parameters
  19841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19842. */
  19843. export interface PhysicsImpostorParameters {
  19844. /**
  19845. * The mass of the physics imposter
  19846. */
  19847. mass: number;
  19848. /**
  19849. * The friction of the physics imposter
  19850. */
  19851. friction?: number;
  19852. /**
  19853. * The coefficient of restitution of the physics imposter
  19854. */
  19855. restitution?: number;
  19856. /**
  19857. * The native options of the physics imposter
  19858. */
  19859. nativeOptions?: any;
  19860. /**
  19861. * Specifies if the parent should be ignored
  19862. */
  19863. ignoreParent?: boolean;
  19864. /**
  19865. * Specifies if bi-directional transformations should be disabled
  19866. */
  19867. disableBidirectionalTransformation?: boolean;
  19868. /**
  19869. * The pressure inside the physics imposter, soft object only
  19870. */
  19871. pressure?: number;
  19872. /**
  19873. * The stiffness the physics imposter, soft object only
  19874. */
  19875. stiffness?: number;
  19876. /**
  19877. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19878. */
  19879. velocityIterations?: number;
  19880. /**
  19881. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19882. */
  19883. positionIterations?: number;
  19884. /**
  19885. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19886. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19887. * Add to fix multiple points
  19888. */
  19889. fixedPoints?: number;
  19890. /**
  19891. * The collision margin around a soft object
  19892. */
  19893. margin?: number;
  19894. /**
  19895. * The collision margin around a soft object
  19896. */
  19897. damping?: number;
  19898. /**
  19899. * The path for a rope based on an extrusion
  19900. */
  19901. path?: any;
  19902. /**
  19903. * The shape of an extrusion used for a rope based on an extrusion
  19904. */
  19905. shape?: any;
  19906. }
  19907. /**
  19908. * Interface for a physics-enabled object
  19909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19910. */
  19911. export interface IPhysicsEnabledObject {
  19912. /**
  19913. * The position of the physics-enabled object
  19914. */
  19915. position: Vector3;
  19916. /**
  19917. * The rotation of the physics-enabled object
  19918. */
  19919. rotationQuaternion: Nullable<Quaternion>;
  19920. /**
  19921. * The scale of the physics-enabled object
  19922. */
  19923. scaling: Vector3;
  19924. /**
  19925. * The rotation of the physics-enabled object
  19926. */
  19927. rotation?: Vector3;
  19928. /**
  19929. * The parent of the physics-enabled object
  19930. */
  19931. parent?: any;
  19932. /**
  19933. * The bounding info of the physics-enabled object
  19934. * @returns The bounding info of the physics-enabled object
  19935. */
  19936. getBoundingInfo(): BoundingInfo;
  19937. /**
  19938. * Computes the world matrix
  19939. * @param force Specifies if the world matrix should be computed by force
  19940. * @returns A world matrix
  19941. */
  19942. computeWorldMatrix(force: boolean): Matrix;
  19943. /**
  19944. * Gets the world matrix
  19945. * @returns A world matrix
  19946. */
  19947. getWorldMatrix?(): Matrix;
  19948. /**
  19949. * Gets the child meshes
  19950. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19951. * @returns An array of abstract meshes
  19952. */
  19953. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19954. /**
  19955. * Gets the vertex data
  19956. * @param kind The type of vertex data
  19957. * @returns A nullable array of numbers, or a float32 array
  19958. */
  19959. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19960. /**
  19961. * Gets the indices from the mesh
  19962. * @returns A nullable array of index arrays
  19963. */
  19964. getIndices?(): Nullable<IndicesArray>;
  19965. /**
  19966. * Gets the scene from the mesh
  19967. * @returns the indices array or null
  19968. */
  19969. getScene?(): Scene;
  19970. /**
  19971. * Gets the absolute position from the mesh
  19972. * @returns the absolute position
  19973. */
  19974. getAbsolutePosition(): Vector3;
  19975. /**
  19976. * Gets the absolute pivot point from the mesh
  19977. * @returns the absolute pivot point
  19978. */
  19979. getAbsolutePivotPoint(): Vector3;
  19980. /**
  19981. * Rotates the mesh
  19982. * @param axis The axis of rotation
  19983. * @param amount The amount of rotation
  19984. * @param space The space of the rotation
  19985. * @returns The rotation transform node
  19986. */
  19987. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19988. /**
  19989. * Translates the mesh
  19990. * @param axis The axis of translation
  19991. * @param distance The distance of translation
  19992. * @param space The space of the translation
  19993. * @returns The transform node
  19994. */
  19995. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19996. /**
  19997. * Sets the absolute position of the mesh
  19998. * @param absolutePosition The absolute position of the mesh
  19999. * @returns The transform node
  20000. */
  20001. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20002. /**
  20003. * Gets the class name of the mesh
  20004. * @returns The class name
  20005. */
  20006. getClassName(): string;
  20007. }
  20008. /**
  20009. * Represents a physics imposter
  20010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20011. */
  20012. export class PhysicsImpostor {
  20013. /**
  20014. * The physics-enabled object used as the physics imposter
  20015. */
  20016. object: IPhysicsEnabledObject;
  20017. /**
  20018. * The type of the physics imposter
  20019. */
  20020. type: number;
  20021. private _options;
  20022. private _scene?;
  20023. /**
  20024. * The default object size of the imposter
  20025. */
  20026. static DEFAULT_OBJECT_SIZE: Vector3;
  20027. /**
  20028. * The identity quaternion of the imposter
  20029. */
  20030. static IDENTITY_QUATERNION: Quaternion;
  20031. /** @hidden */
  20032. _pluginData: any;
  20033. private _physicsEngine;
  20034. private _physicsBody;
  20035. private _bodyUpdateRequired;
  20036. private _onBeforePhysicsStepCallbacks;
  20037. private _onAfterPhysicsStepCallbacks;
  20038. /** @hidden */
  20039. _onPhysicsCollideCallbacks: Array<{
  20040. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20041. otherImpostors: Array<PhysicsImpostor>;
  20042. }>;
  20043. private _deltaPosition;
  20044. private _deltaRotation;
  20045. private _deltaRotationConjugated;
  20046. /** hidden */
  20047. _isFromLine: boolean;
  20048. private _parent;
  20049. private _isDisposed;
  20050. private static _tmpVecs;
  20051. private static _tmpQuat;
  20052. /**
  20053. * Specifies if the physics imposter is disposed
  20054. */
  20055. readonly isDisposed: boolean;
  20056. /**
  20057. * Gets the mass of the physics imposter
  20058. */
  20059. mass: number;
  20060. /**
  20061. * Gets the coefficient of friction
  20062. */
  20063. /**
  20064. * Sets the coefficient of friction
  20065. */
  20066. friction: number;
  20067. /**
  20068. * Gets the coefficient of restitution
  20069. */
  20070. /**
  20071. * Sets the coefficient of restitution
  20072. */
  20073. restitution: number;
  20074. /**
  20075. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20076. */
  20077. /**
  20078. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20079. */
  20080. pressure: number;
  20081. /**
  20082. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20083. */
  20084. /**
  20085. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20086. */
  20087. stiffness: number;
  20088. /**
  20089. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20090. */
  20091. /**
  20092. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20093. */
  20094. velocityIterations: number;
  20095. /**
  20096. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20097. */
  20098. /**
  20099. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20100. */
  20101. positionIterations: number;
  20102. /**
  20103. * The unique id of the physics imposter
  20104. * set by the physics engine when adding this impostor to the array
  20105. */
  20106. uniqueId: number;
  20107. /**
  20108. * @hidden
  20109. */
  20110. soft: boolean;
  20111. /**
  20112. * @hidden
  20113. */
  20114. segments: number;
  20115. private _joints;
  20116. /**
  20117. * Initializes the physics imposter
  20118. * @param object The physics-enabled object used as the physics imposter
  20119. * @param type The type of the physics imposter
  20120. * @param _options The options for the physics imposter
  20121. * @param _scene The Babylon scene
  20122. */
  20123. constructor(
  20124. /**
  20125. * The physics-enabled object used as the physics imposter
  20126. */
  20127. object: IPhysicsEnabledObject,
  20128. /**
  20129. * The type of the physics imposter
  20130. */
  20131. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20132. /**
  20133. * This function will completly initialize this impostor.
  20134. * It will create a new body - but only if this mesh has no parent.
  20135. * If it has, this impostor will not be used other than to define the impostor
  20136. * of the child mesh.
  20137. * @hidden
  20138. */
  20139. _init(): void;
  20140. private _getPhysicsParent;
  20141. /**
  20142. * Should a new body be generated.
  20143. * @returns boolean specifying if body initialization is required
  20144. */
  20145. isBodyInitRequired(): boolean;
  20146. /**
  20147. * Sets the updated scaling
  20148. * @param updated Specifies if the scaling is updated
  20149. */
  20150. setScalingUpdated(): void;
  20151. /**
  20152. * Force a regeneration of this or the parent's impostor's body.
  20153. * Use under cautious - This will remove all joints already implemented.
  20154. */
  20155. forceUpdate(): void;
  20156. /**
  20157. * Gets the body that holds this impostor. Either its own, or its parent.
  20158. */
  20159. /**
  20160. * Set the physics body. Used mainly by the physics engine/plugin
  20161. */
  20162. physicsBody: any;
  20163. /**
  20164. * Get the parent of the physics imposter
  20165. * @returns Physics imposter or null
  20166. */
  20167. /**
  20168. * Sets the parent of the physics imposter
  20169. */
  20170. parent: Nullable<PhysicsImpostor>;
  20171. /**
  20172. * Resets the update flags
  20173. */
  20174. resetUpdateFlags(): void;
  20175. /**
  20176. * Gets the object extend size
  20177. * @returns the object extend size
  20178. */
  20179. getObjectExtendSize(): Vector3;
  20180. /**
  20181. * Gets the object center
  20182. * @returns The object center
  20183. */
  20184. getObjectCenter(): Vector3;
  20185. /**
  20186. * Get a specific parametes from the options parameter
  20187. * @param paramName The object parameter name
  20188. * @returns The object parameter
  20189. */
  20190. getParam(paramName: string): any;
  20191. /**
  20192. * Sets a specific parameter in the options given to the physics plugin
  20193. * @param paramName The parameter name
  20194. * @param value The value of the parameter
  20195. */
  20196. setParam(paramName: string, value: number): void;
  20197. /**
  20198. * Specifically change the body's mass option. Won't recreate the physics body object
  20199. * @param mass The mass of the physics imposter
  20200. */
  20201. setMass(mass: number): void;
  20202. /**
  20203. * Gets the linear velocity
  20204. * @returns linear velocity or null
  20205. */
  20206. getLinearVelocity(): Nullable<Vector3>;
  20207. /**
  20208. * Sets the linear velocity
  20209. * @param velocity linear velocity or null
  20210. */
  20211. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20212. /**
  20213. * Gets the angular velocity
  20214. * @returns angular velocity or null
  20215. */
  20216. getAngularVelocity(): Nullable<Vector3>;
  20217. /**
  20218. * Sets the angular velocity
  20219. * @param velocity The velocity or null
  20220. */
  20221. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20222. /**
  20223. * Execute a function with the physics plugin native code
  20224. * Provide a function the will have two variables - the world object and the physics body object
  20225. * @param func The function to execute with the physics plugin native code
  20226. */
  20227. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20228. /**
  20229. * Register a function that will be executed before the physics world is stepping forward
  20230. * @param func The function to execute before the physics world is stepped forward
  20231. */
  20232. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20233. /**
  20234. * Unregister a function that will be executed before the physics world is stepping forward
  20235. * @param func The function to execute before the physics world is stepped forward
  20236. */
  20237. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20238. /**
  20239. * Register a function that will be executed after the physics step
  20240. * @param func The function to execute after physics step
  20241. */
  20242. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20243. /**
  20244. * Unregisters a function that will be executed after the physics step
  20245. * @param func The function to execute after physics step
  20246. */
  20247. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20248. /**
  20249. * register a function that will be executed when this impostor collides against a different body
  20250. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20251. * @param func Callback that is executed on collision
  20252. */
  20253. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20254. /**
  20255. * Unregisters the physics imposter on contact
  20256. * @param collideAgainst The physics object to collide against
  20257. * @param func Callback to execute on collision
  20258. */
  20259. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20260. private _tmpQuat;
  20261. private _tmpQuat2;
  20262. /**
  20263. * Get the parent rotation
  20264. * @returns The parent rotation
  20265. */
  20266. getParentsRotation(): Quaternion;
  20267. /**
  20268. * this function is executed by the physics engine.
  20269. */
  20270. beforeStep: () => void;
  20271. /**
  20272. * this function is executed by the physics engine
  20273. */
  20274. afterStep: () => void;
  20275. /**
  20276. * Legacy collision detection event support
  20277. */
  20278. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20279. /**
  20280. * event and body object due to cannon's event-based architecture.
  20281. */
  20282. onCollide: (e: {
  20283. body: any;
  20284. }) => void;
  20285. /**
  20286. * Apply a force
  20287. * @param force The force to apply
  20288. * @param contactPoint The contact point for the force
  20289. * @returns The physics imposter
  20290. */
  20291. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20292. /**
  20293. * Apply an impulse
  20294. * @param force The impulse force
  20295. * @param contactPoint The contact point for the impulse force
  20296. * @returns The physics imposter
  20297. */
  20298. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20299. /**
  20300. * A help function to create a joint
  20301. * @param otherImpostor A physics imposter used to create a joint
  20302. * @param jointType The type of joint
  20303. * @param jointData The data for the joint
  20304. * @returns The physics imposter
  20305. */
  20306. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20307. /**
  20308. * Add a joint to this impostor with a different impostor
  20309. * @param otherImpostor A physics imposter used to add a joint
  20310. * @param joint The joint to add
  20311. * @returns The physics imposter
  20312. */
  20313. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20314. /**
  20315. * Add an anchor to a cloth impostor
  20316. * @param otherImpostor rigid impostor to anchor to
  20317. * @param width ratio across width from 0 to 1
  20318. * @param height ratio up height from 0 to 1
  20319. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20320. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20321. * @returns impostor the soft imposter
  20322. */
  20323. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20324. /**
  20325. * Add a hook to a rope impostor
  20326. * @param otherImpostor rigid impostor to anchor to
  20327. * @param length ratio across rope from 0 to 1
  20328. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20329. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20330. * @returns impostor the rope imposter
  20331. */
  20332. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20333. /**
  20334. * Will keep this body still, in a sleep mode.
  20335. * @returns the physics imposter
  20336. */
  20337. sleep(): PhysicsImpostor;
  20338. /**
  20339. * Wake the body up.
  20340. * @returns The physics imposter
  20341. */
  20342. wakeUp(): PhysicsImpostor;
  20343. /**
  20344. * Clones the physics imposter
  20345. * @param newObject The physics imposter clones to this physics-enabled object
  20346. * @returns A nullable physics imposter
  20347. */
  20348. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20349. /**
  20350. * Disposes the physics imposter
  20351. */
  20352. dispose(): void;
  20353. /**
  20354. * Sets the delta position
  20355. * @param position The delta position amount
  20356. */
  20357. setDeltaPosition(position: Vector3): void;
  20358. /**
  20359. * Sets the delta rotation
  20360. * @param rotation The delta rotation amount
  20361. */
  20362. setDeltaRotation(rotation: Quaternion): void;
  20363. /**
  20364. * Gets the box size of the physics imposter and stores the result in the input parameter
  20365. * @param result Stores the box size
  20366. * @returns The physics imposter
  20367. */
  20368. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20369. /**
  20370. * Gets the radius of the physics imposter
  20371. * @returns Radius of the physics imposter
  20372. */
  20373. getRadius(): number;
  20374. /**
  20375. * Sync a bone with this impostor
  20376. * @param bone The bone to sync to the impostor.
  20377. * @param boneMesh The mesh that the bone is influencing.
  20378. * @param jointPivot The pivot of the joint / bone in local space.
  20379. * @param distToJoint Optional distance from the impostor to the joint.
  20380. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20381. */
  20382. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20383. /**
  20384. * Sync impostor to a bone
  20385. * @param bone The bone that the impostor will be synced to.
  20386. * @param boneMesh The mesh that the bone is influencing.
  20387. * @param jointPivot The pivot of the joint / bone in local space.
  20388. * @param distToJoint Optional distance from the impostor to the joint.
  20389. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20390. * @param boneAxis Optional vector3 axis the bone is aligned with
  20391. */
  20392. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20393. /**
  20394. * No-Imposter type
  20395. */
  20396. static NoImpostor: number;
  20397. /**
  20398. * Sphere-Imposter type
  20399. */
  20400. static SphereImpostor: number;
  20401. /**
  20402. * Box-Imposter type
  20403. */
  20404. static BoxImpostor: number;
  20405. /**
  20406. * Plane-Imposter type
  20407. */
  20408. static PlaneImpostor: number;
  20409. /**
  20410. * Mesh-imposter type
  20411. */
  20412. static MeshImpostor: number;
  20413. /**
  20414. * Cylinder-Imposter type
  20415. */
  20416. static CylinderImpostor: number;
  20417. /**
  20418. * Particle-Imposter type
  20419. */
  20420. static ParticleImpostor: number;
  20421. /**
  20422. * Heightmap-Imposter type
  20423. */
  20424. static HeightmapImpostor: number;
  20425. /**
  20426. * ConvexHull-Impostor type (Ammo.js plugin only)
  20427. */
  20428. static ConvexHullImpostor: number;
  20429. /**
  20430. * Rope-Imposter type
  20431. */
  20432. static RopeImpostor: number;
  20433. /**
  20434. * Cloth-Imposter type
  20435. */
  20436. static ClothImpostor: number;
  20437. /**
  20438. * Softbody-Imposter type
  20439. */
  20440. static SoftbodyImpostor: number;
  20441. }
  20442. }
  20443. declare module BABYLON {
  20444. /**
  20445. * Class used to represent a specific level of detail of a mesh
  20446. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20447. */
  20448. export class MeshLODLevel {
  20449. /** Defines the distance where this level should star being displayed */
  20450. distance: number;
  20451. /** Defines the mesh to use to render this level */
  20452. mesh: Nullable<Mesh>;
  20453. /**
  20454. * Creates a new LOD level
  20455. * @param distance defines the distance where this level should star being displayed
  20456. * @param mesh defines the mesh to use to render this level
  20457. */
  20458. constructor(
  20459. /** Defines the distance where this level should star being displayed */
  20460. distance: number,
  20461. /** Defines the mesh to use to render this level */
  20462. mesh: Nullable<Mesh>);
  20463. }
  20464. /**
  20465. * @hidden
  20466. **/
  20467. export class _CreationDataStorage {
  20468. closePath?: boolean;
  20469. closeArray?: boolean;
  20470. idx: number[];
  20471. dashSize: number;
  20472. gapSize: number;
  20473. path3D: Path3D;
  20474. pathArray: Vector3[][];
  20475. arc: number;
  20476. radius: number;
  20477. cap: number;
  20478. tessellation: number;
  20479. }
  20480. /**
  20481. * @hidden
  20482. **/
  20483. class _InstanceDataStorage {
  20484. visibleInstances: any;
  20485. renderIdForInstances: number[];
  20486. batchCache: _InstancesBatch;
  20487. instancesBufferSize: number;
  20488. instancesBuffer: Nullable<Buffer>;
  20489. instancesData: Float32Array;
  20490. overridenInstanceCount: number;
  20491. }
  20492. /**
  20493. * @hidden
  20494. **/
  20495. export class _InstancesBatch {
  20496. mustReturn: boolean;
  20497. visibleInstances: Nullable<InstancedMesh[]>[];
  20498. renderSelf: boolean[];
  20499. }
  20500. /**
  20501. * Class used to represent renderable models
  20502. */
  20503. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20504. /**
  20505. * Mesh side orientation : usually the external or front surface
  20506. */
  20507. static readonly FRONTSIDE: number;
  20508. /**
  20509. * Mesh side orientation : usually the internal or back surface
  20510. */
  20511. static readonly BACKSIDE: number;
  20512. /**
  20513. * Mesh side orientation : both internal and external or front and back surfaces
  20514. */
  20515. static readonly DOUBLESIDE: number;
  20516. /**
  20517. * Mesh side orientation : by default, `FRONTSIDE`
  20518. */
  20519. static readonly DEFAULTSIDE: number;
  20520. /**
  20521. * Mesh cap setting : no cap
  20522. */
  20523. static readonly NO_CAP: number;
  20524. /**
  20525. * Mesh cap setting : one cap at the beginning of the mesh
  20526. */
  20527. static readonly CAP_START: number;
  20528. /**
  20529. * Mesh cap setting : one cap at the end of the mesh
  20530. */
  20531. static readonly CAP_END: number;
  20532. /**
  20533. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20534. */
  20535. static readonly CAP_ALL: number;
  20536. /**
  20537. * Gets the default side orientation.
  20538. * @param orientation the orientation to value to attempt to get
  20539. * @returns the default orientation
  20540. * @hidden
  20541. */
  20542. static _GetDefaultSideOrientation(orientation?: number): number;
  20543. private _onBeforeRenderObservable;
  20544. private _onBeforeBindObservable;
  20545. private _onAfterRenderObservable;
  20546. private _onBeforeDrawObservable;
  20547. /**
  20548. * An event triggered before rendering the mesh
  20549. */
  20550. readonly onBeforeRenderObservable: Observable<Mesh>;
  20551. /**
  20552. * An event triggered before binding the mesh
  20553. */
  20554. readonly onBeforeBindObservable: Observable<Mesh>;
  20555. /**
  20556. * An event triggered after rendering the mesh
  20557. */
  20558. readonly onAfterRenderObservable: Observable<Mesh>;
  20559. /**
  20560. * An event triggered before drawing the mesh
  20561. */
  20562. readonly onBeforeDrawObservable: Observable<Mesh>;
  20563. private _onBeforeDrawObserver;
  20564. /**
  20565. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20566. */
  20567. onBeforeDraw: () => void;
  20568. /**
  20569. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20570. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20571. */
  20572. delayLoadState: number;
  20573. /**
  20574. * Gets the list of instances created from this mesh
  20575. * it is not supposed to be modified manually.
  20576. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20577. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20578. */
  20579. instances: InstancedMesh[];
  20580. /**
  20581. * Gets the file containing delay loading data for this mesh
  20582. */
  20583. delayLoadingFile: string;
  20584. /** @hidden */
  20585. _binaryInfo: any;
  20586. private _LODLevels;
  20587. /**
  20588. * User defined function used to change how LOD level selection is done
  20589. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20590. */
  20591. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20592. private _morphTargetManager;
  20593. /**
  20594. * Gets or sets the morph target manager
  20595. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20596. */
  20597. morphTargetManager: Nullable<MorphTargetManager>;
  20598. /** @hidden */
  20599. _creationDataStorage: Nullable<_CreationDataStorage>;
  20600. /** @hidden */
  20601. _geometry: Nullable<Geometry>;
  20602. /** @hidden */
  20603. _delayInfo: Array<string>;
  20604. /** @hidden */
  20605. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20606. /** @hidden */
  20607. _instanceDataStorage: _InstanceDataStorage;
  20608. private _effectiveMaterial;
  20609. /** @hidden */
  20610. _shouldGenerateFlatShading: boolean;
  20611. private _preActivateId;
  20612. /** @hidden */
  20613. _originalBuilderSideOrientation: number;
  20614. /**
  20615. * Use this property to change the original side orientation defined at construction time
  20616. */
  20617. overrideMaterialSideOrientation: Nullable<number>;
  20618. private _areNormalsFrozen;
  20619. private _sourcePositions;
  20620. private _sourceNormals;
  20621. private _source;
  20622. private meshMap;
  20623. /**
  20624. * Gets the source mesh (the one used to clone this one from)
  20625. */
  20626. readonly source: Nullable<Mesh>;
  20627. /**
  20628. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20629. */
  20630. isUnIndexed: boolean;
  20631. /**
  20632. * @constructor
  20633. * @param name The value used by scene.getMeshByName() to do a lookup.
  20634. * @param scene The scene to add this mesh to.
  20635. * @param parent The parent of this mesh, if it has one
  20636. * @param source An optional Mesh from which geometry is shared, cloned.
  20637. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20638. * When false, achieved by calling a clone(), also passing False.
  20639. * This will make creation of children, recursive.
  20640. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20641. */
  20642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20643. /**
  20644. * Gets the class name
  20645. * @returns the string "Mesh".
  20646. */
  20647. getClassName(): string;
  20648. /** @hidden */
  20649. readonly _isMesh: boolean;
  20650. /**
  20651. * Returns a description of this mesh
  20652. * @param fullDetails define if full details about this mesh must be used
  20653. * @returns a descriptive string representing this mesh
  20654. */
  20655. toString(fullDetails?: boolean): string;
  20656. /** @hidden */
  20657. _unBindEffect(): void;
  20658. /**
  20659. * Gets a boolean indicating if this mesh has LOD
  20660. */
  20661. readonly hasLODLevels: boolean;
  20662. /**
  20663. * Gets the list of MeshLODLevel associated with the current mesh
  20664. * @returns an array of MeshLODLevel
  20665. */
  20666. getLODLevels(): MeshLODLevel[];
  20667. private _sortLODLevels;
  20668. /**
  20669. * Add a mesh as LOD level triggered at the given distance.
  20670. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20671. * @param distance The distance from the center of the object to show this level
  20672. * @param mesh The mesh to be added as LOD level (can be null)
  20673. * @return This mesh (for chaining)
  20674. */
  20675. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20676. /**
  20677. * Returns the LOD level mesh at the passed distance or null if not found.
  20678. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20679. * @param distance The distance from the center of the object to show this level
  20680. * @returns a Mesh or `null`
  20681. */
  20682. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20683. /**
  20684. * Remove a mesh from the LOD array
  20685. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20686. * @param mesh defines the mesh to be removed
  20687. * @return This mesh (for chaining)
  20688. */
  20689. removeLODLevel(mesh: Mesh): Mesh;
  20690. /**
  20691. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20692. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20693. * @param camera defines the camera to use to compute distance
  20694. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20695. * @return This mesh (for chaining)
  20696. */
  20697. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20698. /**
  20699. * Gets the mesh internal Geometry object
  20700. */
  20701. readonly geometry: Nullable<Geometry>;
  20702. /**
  20703. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20704. * @returns the total number of vertices
  20705. */
  20706. getTotalVertices(): number;
  20707. /**
  20708. * Returns the content of an associated vertex buffer
  20709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20710. * - VertexBuffer.PositionKind
  20711. * - VertexBuffer.UVKind
  20712. * - VertexBuffer.UV2Kind
  20713. * - VertexBuffer.UV3Kind
  20714. * - VertexBuffer.UV4Kind
  20715. * - VertexBuffer.UV5Kind
  20716. * - VertexBuffer.UV6Kind
  20717. * - VertexBuffer.ColorKind
  20718. * - VertexBuffer.MatricesIndicesKind
  20719. * - VertexBuffer.MatricesIndicesExtraKind
  20720. * - VertexBuffer.MatricesWeightsKind
  20721. * - VertexBuffer.MatricesWeightsExtraKind
  20722. * @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
  20723. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20724. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20725. */
  20726. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20727. /**
  20728. * Returns the mesh VertexBuffer object from the requested `kind`
  20729. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20730. * - VertexBuffer.PositionKind
  20731. * - VertexBuffer.UVKind
  20732. * - VertexBuffer.UV2Kind
  20733. * - VertexBuffer.UV3Kind
  20734. * - VertexBuffer.UV4Kind
  20735. * - VertexBuffer.UV5Kind
  20736. * - VertexBuffer.UV6Kind
  20737. * - VertexBuffer.ColorKind
  20738. * - VertexBuffer.MatricesIndicesKind
  20739. * - VertexBuffer.MatricesIndicesExtraKind
  20740. * - VertexBuffer.MatricesWeightsKind
  20741. * - VertexBuffer.MatricesWeightsExtraKind
  20742. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20743. */
  20744. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20745. /**
  20746. * Tests if a specific vertex buffer is associated with this mesh
  20747. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20748. * - VertexBuffer.PositionKind
  20749. * - VertexBuffer.UVKind
  20750. * - VertexBuffer.UV2Kind
  20751. * - VertexBuffer.UV3Kind
  20752. * - VertexBuffer.UV4Kind
  20753. * - VertexBuffer.UV5Kind
  20754. * - VertexBuffer.UV6Kind
  20755. * - VertexBuffer.ColorKind
  20756. * - VertexBuffer.MatricesIndicesKind
  20757. * - VertexBuffer.MatricesIndicesExtraKind
  20758. * - VertexBuffer.MatricesWeightsKind
  20759. * - VertexBuffer.MatricesWeightsExtraKind
  20760. * @returns a boolean
  20761. */
  20762. isVerticesDataPresent(kind: string): boolean;
  20763. /**
  20764. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20766. * - VertexBuffer.PositionKind
  20767. * - VertexBuffer.UVKind
  20768. * - VertexBuffer.UV2Kind
  20769. * - VertexBuffer.UV3Kind
  20770. * - VertexBuffer.UV4Kind
  20771. * - VertexBuffer.UV5Kind
  20772. * - VertexBuffer.UV6Kind
  20773. * - VertexBuffer.ColorKind
  20774. * - VertexBuffer.MatricesIndicesKind
  20775. * - VertexBuffer.MatricesIndicesExtraKind
  20776. * - VertexBuffer.MatricesWeightsKind
  20777. * - VertexBuffer.MatricesWeightsExtraKind
  20778. * @returns a boolean
  20779. */
  20780. isVertexBufferUpdatable(kind: string): boolean;
  20781. /**
  20782. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20784. * - VertexBuffer.PositionKind
  20785. * - VertexBuffer.UVKind
  20786. * - VertexBuffer.UV2Kind
  20787. * - VertexBuffer.UV3Kind
  20788. * - VertexBuffer.UV4Kind
  20789. * - VertexBuffer.UV5Kind
  20790. * - VertexBuffer.UV6Kind
  20791. * - VertexBuffer.ColorKind
  20792. * - VertexBuffer.MatricesIndicesKind
  20793. * - VertexBuffer.MatricesIndicesExtraKind
  20794. * - VertexBuffer.MatricesWeightsKind
  20795. * - VertexBuffer.MatricesWeightsExtraKind
  20796. * @returns an array of strings
  20797. */
  20798. getVerticesDataKinds(): string[];
  20799. /**
  20800. * Returns a positive integer : the total number of indices in this mesh geometry.
  20801. * @returns the numner of indices or zero if the mesh has no geometry.
  20802. */
  20803. getTotalIndices(): number;
  20804. /**
  20805. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20806. * @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.
  20807. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20808. * @returns the indices array or an empty array if the mesh has no geometry
  20809. */
  20810. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20811. readonly isBlocked: boolean;
  20812. /**
  20813. * Determine if the current mesh is ready to be rendered
  20814. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20815. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20816. * @returns true if all associated assets are ready (material, textures, shaders)
  20817. */
  20818. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20819. /**
  20820. * 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.
  20821. */
  20822. readonly areNormalsFrozen: boolean;
  20823. /**
  20824. * 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.
  20825. * @returns the current mesh
  20826. */
  20827. freezeNormals(): Mesh;
  20828. /**
  20829. * 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
  20830. * @returns the current mesh
  20831. */
  20832. unfreezeNormals(): Mesh;
  20833. /**
  20834. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20835. */
  20836. overridenInstanceCount: number;
  20837. /** @hidden */
  20838. _preActivate(): Mesh;
  20839. /** @hidden */
  20840. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20841. /** @hidden */
  20842. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20843. /**
  20844. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20845. * This means the mesh underlying bounding box and sphere are recomputed.
  20846. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20847. * @returns the current mesh
  20848. */
  20849. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20850. /** @hidden */
  20851. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20852. /**
  20853. * This function will subdivide the mesh into multiple submeshes
  20854. * @param count defines the expected number of submeshes
  20855. */
  20856. subdivide(count: number): void;
  20857. /**
  20858. * Copy a FloatArray into a specific associated vertex buffer
  20859. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20860. * - VertexBuffer.PositionKind
  20861. * - VertexBuffer.UVKind
  20862. * - VertexBuffer.UV2Kind
  20863. * - VertexBuffer.UV3Kind
  20864. * - VertexBuffer.UV4Kind
  20865. * - VertexBuffer.UV5Kind
  20866. * - VertexBuffer.UV6Kind
  20867. * - VertexBuffer.ColorKind
  20868. * - VertexBuffer.MatricesIndicesKind
  20869. * - VertexBuffer.MatricesIndicesExtraKind
  20870. * - VertexBuffer.MatricesWeightsKind
  20871. * - VertexBuffer.MatricesWeightsExtraKind
  20872. * @param data defines the data source
  20873. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20874. * @param stride defines the data stride size (can be null)
  20875. * @returns the current mesh
  20876. */
  20877. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20878. /**
  20879. * Flags an associated vertex buffer as updatable
  20880. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20881. * - VertexBuffer.PositionKind
  20882. * - VertexBuffer.UVKind
  20883. * - VertexBuffer.UV2Kind
  20884. * - VertexBuffer.UV3Kind
  20885. * - VertexBuffer.UV4Kind
  20886. * - VertexBuffer.UV5Kind
  20887. * - VertexBuffer.UV6Kind
  20888. * - VertexBuffer.ColorKind
  20889. * - VertexBuffer.MatricesIndicesKind
  20890. * - VertexBuffer.MatricesIndicesExtraKind
  20891. * - VertexBuffer.MatricesWeightsKind
  20892. * - VertexBuffer.MatricesWeightsExtraKind
  20893. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20894. */
  20895. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20896. /**
  20897. * Sets the mesh global Vertex Buffer
  20898. * @param buffer defines the buffer to use
  20899. * @returns the current mesh
  20900. */
  20901. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20902. /**
  20903. * Update a specific associated vertex buffer
  20904. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20905. * - VertexBuffer.PositionKind
  20906. * - VertexBuffer.UVKind
  20907. * - VertexBuffer.UV2Kind
  20908. * - VertexBuffer.UV3Kind
  20909. * - VertexBuffer.UV4Kind
  20910. * - VertexBuffer.UV5Kind
  20911. * - VertexBuffer.UV6Kind
  20912. * - VertexBuffer.ColorKind
  20913. * - VertexBuffer.MatricesIndicesKind
  20914. * - VertexBuffer.MatricesIndicesExtraKind
  20915. * - VertexBuffer.MatricesWeightsKind
  20916. * - VertexBuffer.MatricesWeightsExtraKind
  20917. * @param data defines the data source
  20918. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20919. * @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)
  20920. * @returns the current mesh
  20921. */
  20922. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20923. /**
  20924. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20925. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20926. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20927. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20928. * @returns the current mesh
  20929. */
  20930. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20931. /**
  20932. * Creates a un-shared specific occurence of the geometry for the mesh.
  20933. * @returns the current mesh
  20934. */
  20935. makeGeometryUnique(): Mesh;
  20936. /**
  20937. * Set the index buffer of this mesh
  20938. * @param indices defines the source data
  20939. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20940. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20941. * @returns the current mesh
  20942. */
  20943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20944. /**
  20945. * Update the current index buffer
  20946. * @param indices defines the source data
  20947. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20948. * @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)
  20949. * @returns the current mesh
  20950. */
  20951. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20952. /**
  20953. * Invert the geometry to move from a right handed system to a left handed one.
  20954. * @returns the current mesh
  20955. */
  20956. toLeftHanded(): Mesh;
  20957. /** @hidden */
  20958. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20959. /** @hidden */
  20960. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20961. /**
  20962. * Registers for this mesh a javascript function called just before the rendering process
  20963. * @param func defines the function to call before rendering this mesh
  20964. * @returns the current mesh
  20965. */
  20966. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20967. /**
  20968. * Disposes a previously registered javascript function called before the rendering
  20969. * @param func defines the function to remove
  20970. * @returns the current mesh
  20971. */
  20972. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just after the rendering is complete
  20975. * @param func defines the function to call after rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called after the rendering.
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /** @hidden */
  20986. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20987. /** @hidden */
  20988. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20989. /** @hidden */
  20990. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20991. /**
  20992. * 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
  20993. * @param subMesh defines the subMesh to render
  20994. * @param enableAlphaMode defines if alpha mode can be changed
  20995. * @returns the current mesh
  20996. */
  20997. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20998. private _onBeforeDraw;
  20999. /**
  21000. * Renormalize the mesh and patch it up if there are no weights
  21001. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21002. * However in the case of zero weights then we set just a single influence to 1.
  21003. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21004. */
  21005. cleanMatrixWeights(): void;
  21006. private normalizeSkinFourWeights;
  21007. private normalizeSkinWeightsAndExtra;
  21008. /**
  21009. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21010. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21011. * the user know there was an issue with importing the mesh
  21012. * @returns a validation object with skinned, valid and report string
  21013. */
  21014. validateSkinning(): {
  21015. skinned: boolean;
  21016. valid: boolean;
  21017. report: string;
  21018. };
  21019. /** @hidden */
  21020. _checkDelayState(): Mesh;
  21021. private _queueLoad;
  21022. /**
  21023. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21024. * A mesh is in the frustum if its bounding box intersects the frustum
  21025. * @param frustumPlanes defines the frustum to test
  21026. * @returns true if the mesh is in the frustum planes
  21027. */
  21028. isInFrustum(frustumPlanes: Plane[]): boolean;
  21029. /**
  21030. * Sets the mesh material by the material or multiMaterial `id` property
  21031. * @param id is a string identifying the material or the multiMaterial
  21032. * @returns the current mesh
  21033. */
  21034. setMaterialByID(id: string): Mesh;
  21035. /**
  21036. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21037. * @returns an array of IAnimatable
  21038. */
  21039. getAnimatables(): IAnimatable[];
  21040. /**
  21041. * Modifies the mesh geometry according to the passed transformation matrix.
  21042. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21043. * The mesh normals are modified using the same transformation.
  21044. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21045. * @param transform defines the transform matrix to use
  21046. * @see http://doc.babylonjs.com/resources/baking_transformations
  21047. * @returns the current mesh
  21048. */
  21049. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21050. /**
  21051. * Modifies the mesh geometry according to its own current World Matrix.
  21052. * The mesh World Matrix is then reset.
  21053. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21054. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21055. * @see http://doc.babylonjs.com/resources/baking_transformations
  21056. * @returns the current mesh
  21057. */
  21058. bakeCurrentTransformIntoVertices(): Mesh;
  21059. /** @hidden */
  21060. readonly _positions: Nullable<Vector3[]>;
  21061. /** @hidden */
  21062. _resetPointsArrayCache(): Mesh;
  21063. /** @hidden */
  21064. _generatePointsArray(): boolean;
  21065. /**
  21066. * Returns a new Mesh object generated from the current mesh properties.
  21067. * This method must not get confused with createInstance()
  21068. * @param name is a string, the name given to the new mesh
  21069. * @param newParent can be any Node object (default `null`)
  21070. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21071. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21072. * @returns a new mesh
  21073. */
  21074. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21075. /**
  21076. * Releases resources associated with this mesh.
  21077. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21078. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21079. */
  21080. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21081. /**
  21082. * Modifies the mesh geometry according to a displacement map.
  21083. * 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.
  21084. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21085. * @param url is a string, the URL from the image file is to be downloaded.
  21086. * @param minHeight is the lower limit of the displacement.
  21087. * @param maxHeight is the upper limit of the displacement.
  21088. * @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.
  21089. * @param uvOffset is an optional vector2 used to offset UV.
  21090. * @param uvScale is an optional vector2 used to scale UV.
  21091. * @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.
  21092. * @returns the Mesh.
  21093. */
  21094. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21095. /**
  21096. * Modifies the mesh geometry according to a displacementMap buffer.
  21097. * 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.
  21098. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21099. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21100. * @param heightMapWidth is the width of the buffer image.
  21101. * @param heightMapHeight is the height of the buffer image.
  21102. * @param minHeight is the lower limit of the displacement.
  21103. * @param maxHeight is the upper limit of the displacement.
  21104. * @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.
  21105. * @param uvOffset is an optional vector2 used to offset UV.
  21106. * @param uvScale is an optional vector2 used to scale UV.
  21107. * @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.
  21108. * @returns the Mesh.
  21109. */
  21110. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21111. /**
  21112. * Modify the mesh to get a flat shading rendering.
  21113. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21114. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21115. * @returns current mesh
  21116. */
  21117. convertToFlatShadedMesh(): Mesh;
  21118. /**
  21119. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21120. * In other words, more vertices, no more indices and a single bigger VBO.
  21121. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21122. * @returns current mesh
  21123. */
  21124. convertToUnIndexedMesh(): Mesh;
  21125. /**
  21126. * Inverses facet orientations.
  21127. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21128. * @param flipNormals will also inverts the normals
  21129. * @returns current mesh
  21130. */
  21131. flipFaces(flipNormals?: boolean): Mesh;
  21132. /**
  21133. * Increase the number of facets and hence vertices in a mesh
  21134. * Vertex normals are interpolated from existing vertex normals
  21135. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21136. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21137. */
  21138. increaseVertices(numberPerEdge: number): void;
  21139. /**
  21140. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21141. * This will undo any application of covertToFlatShadedMesh
  21142. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21143. */
  21144. forceSharedVertices(): void;
  21145. /** @hidden */
  21146. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21147. /** @hidden */
  21148. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21149. /**
  21150. * Creates a new InstancedMesh object from the mesh model.
  21151. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21152. * @param name defines the name of the new instance
  21153. * @returns a new InstancedMesh
  21154. */
  21155. createInstance(name: string): InstancedMesh;
  21156. /**
  21157. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21158. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21159. * @returns the current mesh
  21160. */
  21161. synchronizeInstances(): Mesh;
  21162. /**
  21163. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21164. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21165. * This should be used together with the simplification to avoid disappearing triangles.
  21166. * @param successCallback an optional success callback to be called after the optimization finished.
  21167. * @returns the current mesh
  21168. */
  21169. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21170. /**
  21171. * Serialize current mesh
  21172. * @param serializationObject defines the object which will receive the serialization data
  21173. */
  21174. serialize(serializationObject: any): void;
  21175. /** @hidden */
  21176. _syncGeometryWithMorphTargetManager(): void;
  21177. /** @hidden */
  21178. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21179. /**
  21180. * Returns a new Mesh object parsed from the source provided.
  21181. * @param parsedMesh is the source
  21182. * @param scene defines the hosting scene
  21183. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21184. * @returns a new Mesh
  21185. */
  21186. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21187. /**
  21188. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21189. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21190. * @param name defines the name of the mesh to create
  21191. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21192. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21193. * @param closePath creates a seam between the first and the last points of each path of the path array
  21194. * @param offset is taken in account only if the `pathArray` is containing a single path
  21195. * @param scene defines the hosting scene
  21196. * @param updatable defines if the mesh must be flagged as updatable
  21197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21198. * @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)
  21199. * @returns a new Mesh
  21200. */
  21201. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21202. /**
  21203. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21204. * @param name defines the name of the mesh to create
  21205. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21206. * @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
  21207. * @param scene defines the hosting scene
  21208. * @param updatable defines if the mesh must be flagged as updatable
  21209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21210. * @returns a new Mesh
  21211. */
  21212. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21213. /**
  21214. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21215. * @param name defines the name of the mesh to create
  21216. * @param size sets the size (float) of each box side (default 1)
  21217. * @param scene defines the hosting scene
  21218. * @param updatable defines if the mesh must be flagged as updatable
  21219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21220. * @returns a new Mesh
  21221. */
  21222. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21223. /**
  21224. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21225. * @param name defines the name of the mesh to create
  21226. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21227. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21228. * @param scene defines the hosting scene
  21229. * @param updatable defines if the mesh must be flagged as updatable
  21230. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21231. * @returns a new Mesh
  21232. */
  21233. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21234. /**
  21235. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21236. * @param name defines the name of the mesh to create
  21237. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21238. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21239. * @param scene defines the hosting scene
  21240. * @returns a new Mesh
  21241. */
  21242. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21243. /**
  21244. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21245. * @param name defines the name of the mesh to create
  21246. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21247. * @param diameterTop set the top cap diameter (floats, default 1)
  21248. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21249. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21250. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21251. * @param scene defines the hosting scene
  21252. * @param updatable defines if the mesh must be flagged as updatable
  21253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21254. * @returns a new Mesh
  21255. */
  21256. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21257. /**
  21258. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21259. * @param name defines the name of the mesh to create
  21260. * @param diameter sets the diameter size (float) of the torus (default 1)
  21261. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21262. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21263. * @param scene defines the hosting scene
  21264. * @param updatable defines if the mesh must be flagged as updatable
  21265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21266. * @returns a new Mesh
  21267. */
  21268. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21269. /**
  21270. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21271. * @param name defines the name of the mesh to create
  21272. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21273. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21274. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21275. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21276. * @param p the number of windings on X axis (positive integers, default 2)
  21277. * @param q the number of windings on Y axis (positive integers, default 3)
  21278. * @param scene defines the hosting scene
  21279. * @param updatable defines if the mesh must be flagged as updatable
  21280. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21281. * @returns a new Mesh
  21282. */
  21283. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21284. /**
  21285. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21286. * @param name defines the name of the mesh to create
  21287. * @param points is an array successive Vector3
  21288. * @param scene defines the hosting scene
  21289. * @param updatable defines if the mesh must be flagged as updatable
  21290. * @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).
  21291. * @returns a new Mesh
  21292. */
  21293. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21294. /**
  21295. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21296. * @param name defines the name of the mesh to create
  21297. * @param points is an array successive Vector3
  21298. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21299. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21300. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21301. * @param scene defines the hosting scene
  21302. * @param updatable defines if the mesh must be flagged as updatable
  21303. * @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)
  21304. * @returns a new Mesh
  21305. */
  21306. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21307. /**
  21308. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21309. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21310. * 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.
  21311. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21312. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21313. * Remember you can only change the shape positions, not their number when updating a polygon.
  21314. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21315. * @param name defines the name of the mesh to create
  21316. * @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
  21317. * @param scene defines the hosting scene
  21318. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21319. * @param updatable defines if the mesh must be flagged as updatable
  21320. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21321. * @param earcutInjection can be used to inject your own earcut reference
  21322. * @returns a new Mesh
  21323. */
  21324. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21325. /**
  21326. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21328. * @param name defines the name of the mesh to create
  21329. * @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
  21330. * @param depth defines the height of extrusion
  21331. * @param scene defines the hosting scene
  21332. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21333. * @param updatable defines if the mesh must be flagged as updatable
  21334. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21335. * @param earcutInjection can be used to inject your own earcut reference
  21336. * @returns a new Mesh
  21337. */
  21338. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21339. /**
  21340. * Creates an extruded shape mesh.
  21341. * 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
  21342. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21343. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21344. * @param name defines the name of the mesh to create
  21345. * @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
  21346. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21347. * @param scale is the value to scale the shape
  21348. * @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
  21349. * @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
  21350. * @param scene defines the hosting scene
  21351. * @param updatable defines if the mesh must be flagged as updatable
  21352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21353. * @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)
  21354. * @returns a new Mesh
  21355. */
  21356. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21357. /**
  21358. * Creates an custom extruded shape mesh.
  21359. * The custom extrusion is a parametric shape.
  21360. * It has no predefined shape. Its final shape will depend on the input parameters.
  21361. * Please consider using the same method from the MeshBuilder class instead
  21362. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21363. * @param name defines the name of the mesh to create
  21364. * @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
  21365. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21366. * @param scaleFunction is a custom Javascript function called on each path point
  21367. * @param rotationFunction is a custom Javascript function called on each path point
  21368. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21369. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21370. * @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
  21371. * @param scene defines the hosting scene
  21372. * @param updatable defines if the mesh must be flagged as updatable
  21373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21374. * @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)
  21375. * @returns a new Mesh
  21376. */
  21377. 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;
  21378. /**
  21379. * Creates lathe mesh.
  21380. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21381. * Please consider using the same method from the MeshBuilder class instead
  21382. * @param name defines the name of the mesh to create
  21383. * @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
  21384. * @param radius is the radius value of the lathe
  21385. * @param tessellation is the side number of the lathe.
  21386. * @param scene defines the hosting scene
  21387. * @param updatable defines if the mesh must be flagged as updatable
  21388. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21389. * @returns a new Mesh
  21390. */
  21391. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21392. /**
  21393. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21394. * @param name defines the name of the mesh to create
  21395. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21396. * @param scene defines the hosting scene
  21397. * @param updatable defines if the mesh must be flagged as updatable
  21398. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21399. * @returns a new Mesh
  21400. */
  21401. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21402. /**
  21403. * Creates a ground mesh.
  21404. * Please consider using the same method from the MeshBuilder class instead
  21405. * @param name defines the name of the mesh to create
  21406. * @param width set the width of the ground
  21407. * @param height set the height of the ground
  21408. * @param subdivisions sets the number of subdivisions per side
  21409. * @param scene defines the hosting scene
  21410. * @param updatable defines if the mesh must be flagged as updatable
  21411. * @returns a new Mesh
  21412. */
  21413. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21414. /**
  21415. * Creates a tiled ground mesh.
  21416. * Please consider using the same method from the MeshBuilder class instead
  21417. * @param name defines the name of the mesh to create
  21418. * @param xmin set the ground minimum X coordinate
  21419. * @param zmin set the ground minimum Y coordinate
  21420. * @param xmax set the ground maximum X coordinate
  21421. * @param zmax set the ground maximum Z coordinate
  21422. * @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
  21423. * @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
  21424. * @param scene defines the hosting scene
  21425. * @param updatable defines if the mesh must be flagged as updatable
  21426. * @returns a new Mesh
  21427. */
  21428. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21429. w: number;
  21430. h: number;
  21431. }, precision: {
  21432. w: number;
  21433. h: number;
  21434. }, scene: Scene, updatable?: boolean): Mesh;
  21435. /**
  21436. * Creates a ground mesh from a height map.
  21437. * Please consider using the same method from the MeshBuilder class instead
  21438. * @see http://doc.babylonjs.com/babylon101/height_map
  21439. * @param name defines the name of the mesh to create
  21440. * @param url sets the URL of the height map image resource
  21441. * @param width set the ground width size
  21442. * @param height set the ground height size
  21443. * @param subdivisions sets the number of subdivision per side
  21444. * @param minHeight is the minimum altitude on the ground
  21445. * @param maxHeight is the maximum altitude on the ground
  21446. * @param scene defines the hosting scene
  21447. * @param updatable defines if the mesh must be flagged as updatable
  21448. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21449. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21450. * @returns a new Mesh
  21451. */
  21452. 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;
  21453. /**
  21454. * Creates a tube mesh.
  21455. * The tube is a parametric shape.
  21456. * It has no predefined shape. Its final shape will depend on the input parameters.
  21457. * Please consider using the same method from the MeshBuilder class instead
  21458. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21459. * @param name defines the name of the mesh to create
  21460. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21461. * @param radius sets the tube radius size
  21462. * @param tessellation is the number of sides on the tubular surface
  21463. * @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
  21464. * @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
  21465. * @param scene defines the hosting scene
  21466. * @param updatable defines if the mesh must be flagged as updatable
  21467. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21468. * @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)
  21469. * @returns a new Mesh
  21470. */
  21471. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21472. (i: number, distance: number): number;
  21473. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21474. /**
  21475. * Creates a polyhedron mesh.
  21476. * Please consider using the same method from the MeshBuilder class instead.
  21477. * * 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
  21478. * * The parameter `size` (positive float, default 1) sets the polygon size
  21479. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21480. * * 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`
  21481. * * 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
  21482. * * 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)`)
  21483. * * 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
  21484. * * 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
  21485. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21486. * * 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
  21487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21488. * @param name defines the name of the mesh to create
  21489. * @param options defines the options used to create the mesh
  21490. * @param scene defines the hosting scene
  21491. * @returns a new Mesh
  21492. */
  21493. static CreatePolyhedron(name: string, options: {
  21494. type?: number;
  21495. size?: number;
  21496. sizeX?: number;
  21497. sizeY?: number;
  21498. sizeZ?: number;
  21499. custom?: any;
  21500. faceUV?: Vector4[];
  21501. faceColors?: Color4[];
  21502. updatable?: boolean;
  21503. sideOrientation?: number;
  21504. }, scene: Scene): Mesh;
  21505. /**
  21506. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21507. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21508. * * 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`)
  21509. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21510. * * 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
  21511. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21512. * * 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
  21513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21514. * @param name defines the name of the mesh
  21515. * @param options defines the options used to create the mesh
  21516. * @param scene defines the hosting scene
  21517. * @returns a new Mesh
  21518. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21519. */
  21520. static CreateIcoSphere(name: string, options: {
  21521. radius?: number;
  21522. flat?: boolean;
  21523. subdivisions?: number;
  21524. sideOrientation?: number;
  21525. updatable?: boolean;
  21526. }, scene: Scene): Mesh;
  21527. /**
  21528. * Creates a decal mesh.
  21529. * Please consider using the same method from the MeshBuilder class instead.
  21530. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21531. * @param name defines the name of the mesh
  21532. * @param sourceMesh defines the mesh receiving the decal
  21533. * @param position sets the position of the decal in world coordinates
  21534. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21535. * @param size sets the decal scaling
  21536. * @param angle sets the angle to rotate the decal
  21537. * @returns a new Mesh
  21538. */
  21539. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21540. /**
  21541. * Prepare internal position array for software CPU skinning
  21542. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21543. */
  21544. setPositionsForCPUSkinning(): Float32Array;
  21545. /**
  21546. * Prepare internal normal array for software CPU skinning
  21547. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21548. */
  21549. setNormalsForCPUSkinning(): Float32Array;
  21550. /**
  21551. * Updates the vertex buffer by applying transformation from the bones
  21552. * @param skeleton defines the skeleton to apply to current mesh
  21553. * @returns the current mesh
  21554. */
  21555. applySkeleton(skeleton: Skeleton): Mesh;
  21556. /**
  21557. * 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
  21558. * @param meshes defines the list of meshes to scan
  21559. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21560. */
  21561. static MinMax(meshes: AbstractMesh[]): {
  21562. min: Vector3;
  21563. max: Vector3;
  21564. };
  21565. /**
  21566. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21567. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21568. * @returns a vector3
  21569. */
  21570. static Center(meshesOrMinMaxVector: {
  21571. min: Vector3;
  21572. max: Vector3;
  21573. } | AbstractMesh[]): Vector3;
  21574. /**
  21575. * Merge the array of meshes into a single mesh for performance reasons.
  21576. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21577. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21578. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21579. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21580. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21581. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21582. * @returns a new mesh
  21583. */
  21584. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21585. /** @hidden */
  21586. addInstance(instance: InstancedMesh): void;
  21587. /** @hidden */
  21588. removeInstance(instance: InstancedMesh): void;
  21589. }
  21590. }
  21591. declare module BABYLON {
  21592. /**
  21593. * Base class for the main features of a material in Babylon.js
  21594. */
  21595. export class Material implements IAnimatable {
  21596. /**
  21597. * Returns the triangle fill mode
  21598. */
  21599. static readonly TriangleFillMode: number;
  21600. /**
  21601. * Returns the wireframe mode
  21602. */
  21603. static readonly WireFrameFillMode: number;
  21604. /**
  21605. * Returns the point fill mode
  21606. */
  21607. static readonly PointFillMode: number;
  21608. /**
  21609. * Returns the point list draw mode
  21610. */
  21611. static readonly PointListDrawMode: number;
  21612. /**
  21613. * Returns the line list draw mode
  21614. */
  21615. static readonly LineListDrawMode: number;
  21616. /**
  21617. * Returns the line loop draw mode
  21618. */
  21619. static readonly LineLoopDrawMode: number;
  21620. /**
  21621. * Returns the line strip draw mode
  21622. */
  21623. static readonly LineStripDrawMode: number;
  21624. /**
  21625. * Returns the triangle strip draw mode
  21626. */
  21627. static readonly TriangleStripDrawMode: number;
  21628. /**
  21629. * Returns the triangle fan draw mode
  21630. */
  21631. static readonly TriangleFanDrawMode: number;
  21632. /**
  21633. * Stores the clock-wise side orientation
  21634. */
  21635. static readonly ClockWiseSideOrientation: number;
  21636. /**
  21637. * Stores the counter clock-wise side orientation
  21638. */
  21639. static readonly CounterClockWiseSideOrientation: number;
  21640. /**
  21641. * The dirty texture flag value
  21642. */
  21643. static readonly TextureDirtyFlag: number;
  21644. /**
  21645. * The dirty light flag value
  21646. */
  21647. static readonly LightDirtyFlag: number;
  21648. /**
  21649. * The dirty fresnel flag value
  21650. */
  21651. static readonly FresnelDirtyFlag: number;
  21652. /**
  21653. * The dirty attribute flag value
  21654. */
  21655. static readonly AttributesDirtyFlag: number;
  21656. /**
  21657. * The dirty misc flag value
  21658. */
  21659. static readonly MiscDirtyFlag: number;
  21660. /**
  21661. * The all dirty flag value
  21662. */
  21663. static readonly AllDirtyFlag: number;
  21664. /**
  21665. * The ID of the material
  21666. */
  21667. id: string;
  21668. /**
  21669. * Gets or sets the unique id of the material
  21670. */
  21671. uniqueId: number;
  21672. /**
  21673. * The name of the material
  21674. */
  21675. name: string;
  21676. /**
  21677. * Gets or sets user defined metadata
  21678. */
  21679. metadata: any;
  21680. /**
  21681. * For internal use only. Please do not use.
  21682. */
  21683. reservedDataStore: any;
  21684. /**
  21685. * Specifies if the ready state should be checked on each call
  21686. */
  21687. checkReadyOnEveryCall: boolean;
  21688. /**
  21689. * Specifies if the ready state should be checked once
  21690. */
  21691. checkReadyOnlyOnce: boolean;
  21692. /**
  21693. * The state of the material
  21694. */
  21695. state: string;
  21696. /**
  21697. * The alpha value of the material
  21698. */
  21699. protected _alpha: number;
  21700. /**
  21701. * List of inspectable custom properties (used by the Inspector)
  21702. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21703. */
  21704. inspectableCustomProperties: IInspectable[];
  21705. /**
  21706. * Sets the alpha value of the material
  21707. */
  21708. /**
  21709. * Gets the alpha value of the material
  21710. */
  21711. alpha: number;
  21712. /**
  21713. * Specifies if back face culling is enabled
  21714. */
  21715. protected _backFaceCulling: boolean;
  21716. /**
  21717. * Sets the back-face culling state
  21718. */
  21719. /**
  21720. * Gets the back-face culling state
  21721. */
  21722. backFaceCulling: boolean;
  21723. /**
  21724. * Stores the value for side orientation
  21725. */
  21726. sideOrientation: number;
  21727. /**
  21728. * Callback triggered when the material is compiled
  21729. */
  21730. onCompiled: (effect: Effect) => void;
  21731. /**
  21732. * Callback triggered when an error occurs
  21733. */
  21734. onError: (effect: Effect, errors: string) => void;
  21735. /**
  21736. * Callback triggered to get the render target textures
  21737. */
  21738. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21739. /**
  21740. * Gets a boolean indicating that current material needs to register RTT
  21741. */
  21742. readonly hasRenderTargetTextures: boolean;
  21743. /**
  21744. * Specifies if the material should be serialized
  21745. */
  21746. doNotSerialize: boolean;
  21747. /**
  21748. * @hidden
  21749. */
  21750. _storeEffectOnSubMeshes: boolean;
  21751. /**
  21752. * Stores the animations for the material
  21753. */
  21754. animations: Array<Animation>;
  21755. /**
  21756. * An event triggered when the material is disposed
  21757. */
  21758. onDisposeObservable: Observable<Material>;
  21759. /**
  21760. * An observer which watches for dispose events
  21761. */
  21762. private _onDisposeObserver;
  21763. private _onUnBindObservable;
  21764. /**
  21765. * Called during a dispose event
  21766. */
  21767. onDispose: () => void;
  21768. private _onBindObservable;
  21769. /**
  21770. * An event triggered when the material is bound
  21771. */
  21772. readonly onBindObservable: Observable<AbstractMesh>;
  21773. /**
  21774. * An observer which watches for bind events
  21775. */
  21776. private _onBindObserver;
  21777. /**
  21778. * Called during a bind event
  21779. */
  21780. onBind: (Mesh: AbstractMesh) => void;
  21781. /**
  21782. * An event triggered when the material is unbound
  21783. */
  21784. readonly onUnBindObservable: Observable<Material>;
  21785. /**
  21786. * Stores the value of the alpha mode
  21787. */
  21788. private _alphaMode;
  21789. /**
  21790. * Sets the value of the alpha mode.
  21791. *
  21792. * | Value | Type | Description |
  21793. * | --- | --- | --- |
  21794. * | 0 | ALPHA_DISABLE | |
  21795. * | 1 | ALPHA_ADD | |
  21796. * | 2 | ALPHA_COMBINE | |
  21797. * | 3 | ALPHA_SUBTRACT | |
  21798. * | 4 | ALPHA_MULTIPLY | |
  21799. * | 5 | ALPHA_MAXIMIZED | |
  21800. * | 6 | ALPHA_ONEONE | |
  21801. * | 7 | ALPHA_PREMULTIPLIED | |
  21802. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21803. * | 9 | ALPHA_INTERPOLATE | |
  21804. * | 10 | ALPHA_SCREENMODE | |
  21805. *
  21806. */
  21807. /**
  21808. * Gets the value of the alpha mode
  21809. */
  21810. alphaMode: number;
  21811. /**
  21812. * Stores the state of the need depth pre-pass value
  21813. */
  21814. private _needDepthPrePass;
  21815. /**
  21816. * Sets the need depth pre-pass value
  21817. */
  21818. /**
  21819. * Gets the depth pre-pass value
  21820. */
  21821. needDepthPrePass: boolean;
  21822. /**
  21823. * Specifies if depth writing should be disabled
  21824. */
  21825. disableDepthWrite: boolean;
  21826. /**
  21827. * Specifies if depth writing should be forced
  21828. */
  21829. forceDepthWrite: boolean;
  21830. /**
  21831. * Specifies if there should be a separate pass for culling
  21832. */
  21833. separateCullingPass: boolean;
  21834. /**
  21835. * Stores the state specifing if fog should be enabled
  21836. */
  21837. private _fogEnabled;
  21838. /**
  21839. * Sets the state for enabling fog
  21840. */
  21841. /**
  21842. * Gets the value of the fog enabled state
  21843. */
  21844. fogEnabled: boolean;
  21845. /**
  21846. * Stores the size of points
  21847. */
  21848. pointSize: number;
  21849. /**
  21850. * Stores the z offset value
  21851. */
  21852. zOffset: number;
  21853. /**
  21854. * Gets a value specifying if wireframe mode is enabled
  21855. */
  21856. /**
  21857. * Sets the state of wireframe mode
  21858. */
  21859. wireframe: boolean;
  21860. /**
  21861. * Gets the value specifying if point clouds are enabled
  21862. */
  21863. /**
  21864. * Sets the state of point cloud mode
  21865. */
  21866. pointsCloud: boolean;
  21867. /**
  21868. * Gets the material fill mode
  21869. */
  21870. /**
  21871. * Sets the material fill mode
  21872. */
  21873. fillMode: number;
  21874. /**
  21875. * @hidden
  21876. * Stores the effects for the material
  21877. */
  21878. _effect: Nullable<Effect>;
  21879. /**
  21880. * @hidden
  21881. * Specifies if the material was previously ready
  21882. */
  21883. _wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */
  21905. _indexInSceneMaterialArray: number;
  21906. /** @hidden */
  21907. meshMap: Nullable<{
  21908. [id: string]: AbstractMesh | undefined;
  21909. }>;
  21910. /**
  21911. * Creates a material instance
  21912. * @param name defines the name of the material
  21913. * @param scene defines the scene to reference
  21914. * @param doNotAdd specifies if the material should be added to the scene
  21915. */
  21916. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21917. /**
  21918. * Returns a string representation of the current material
  21919. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21920. * @returns a string with material information
  21921. */
  21922. toString(fullDetails?: boolean): string;
  21923. /**
  21924. * Gets the class name of the material
  21925. * @returns a string with the class name of the material
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Specifies if updates for the material been locked
  21930. */
  21931. readonly isFrozen: boolean;
  21932. /**
  21933. * Locks updates for the material
  21934. */
  21935. freeze(): void;
  21936. /**
  21937. * Unlocks updates for the material
  21938. */
  21939. unfreeze(): void;
  21940. /**
  21941. * Specifies if the material is ready to be used
  21942. * @param mesh defines the mesh to check
  21943. * @param useInstances specifies if instances should be used
  21944. * @returns a boolean indicating if the material is ready to be used
  21945. */
  21946. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21947. /**
  21948. * Specifies that the submesh is ready to be used
  21949. * @param mesh defines the mesh to check
  21950. * @param subMesh defines which submesh to check
  21951. * @param useInstances specifies that instances should be used
  21952. * @returns a boolean indicating that the submesh is ready or not
  21953. */
  21954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21955. /**
  21956. * Returns the material effect
  21957. * @returns the effect associated with the material
  21958. */
  21959. getEffect(): Nullable<Effect>;
  21960. /**
  21961. * Returns the current scene
  21962. * @returns a Scene
  21963. */
  21964. getScene(): Scene;
  21965. /**
  21966. * Specifies if the material will require alpha blending
  21967. * @returns a boolean specifying if alpha blending is needed
  21968. */
  21969. needAlphaBlending(): boolean;
  21970. /**
  21971. * Specifies if the mesh will require alpha blending
  21972. * @param mesh defines the mesh to check
  21973. * @returns a boolean specifying if alpha blending is needed for the mesh
  21974. */
  21975. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21976. /**
  21977. * Specifies if this material should be rendered in alpha test mode
  21978. * @returns a boolean specifying if an alpha test is needed.
  21979. */
  21980. needAlphaTesting(): boolean;
  21981. /**
  21982. * Gets the texture used for the alpha test
  21983. * @returns the texture to use for alpha testing
  21984. */
  21985. getAlphaTestTexture(): Nullable<BaseTexture>;
  21986. /**
  21987. * Marks the material to indicate that it needs to be re-calculated
  21988. */
  21989. markDirty(): void;
  21990. /** @hidden */
  21991. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21992. /**
  21993. * Binds the material to the mesh
  21994. * @param world defines the world transformation matrix
  21995. * @param mesh defines the mesh to bind the material to
  21996. */
  21997. bind(world: Matrix, mesh?: Mesh): void;
  21998. /**
  21999. * Binds the submesh to the material
  22000. * @param world defines the world transformation matrix
  22001. * @param mesh defines the mesh containing the submesh
  22002. * @param subMesh defines the submesh to bind the material to
  22003. */
  22004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22005. /**
  22006. * Binds the world matrix to the material
  22007. * @param world defines the world transformation matrix
  22008. */
  22009. bindOnlyWorldMatrix(world: Matrix): void;
  22010. /**
  22011. * Binds the scene's uniform buffer to the effect.
  22012. * @param effect defines the effect to bind to the scene uniform buffer
  22013. * @param sceneUbo defines the uniform buffer storing scene data
  22014. */
  22015. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22016. /**
  22017. * Binds the view matrix to the effect
  22018. * @param effect defines the effect to bind the view matrix to
  22019. */
  22020. bindView(effect: Effect): void;
  22021. /**
  22022. * Binds the view projection matrix to the effect
  22023. * @param effect defines the effect to bind the view projection matrix to
  22024. */
  22025. bindViewProjection(effect: Effect): void;
  22026. /**
  22027. * Specifies if material alpha testing should be turned on for the mesh
  22028. * @param mesh defines the mesh to check
  22029. */
  22030. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22031. /**
  22032. * Processes to execute after binding the material to a mesh
  22033. * @param mesh defines the rendered mesh
  22034. */
  22035. protected _afterBind(mesh?: Mesh): void;
  22036. /**
  22037. * Unbinds the material from the mesh
  22038. */
  22039. unbind(): void;
  22040. /**
  22041. * Gets the active textures from the material
  22042. * @returns an array of textures
  22043. */
  22044. getActiveTextures(): BaseTexture[];
  22045. /**
  22046. * Specifies if the material uses a texture
  22047. * @param texture defines the texture to check against the material
  22048. * @returns a boolean specifying if the material uses the texture
  22049. */
  22050. hasTexture(texture: BaseTexture): boolean;
  22051. /**
  22052. * Makes a duplicate of the material, and gives it a new name
  22053. * @param name defines the new name for the duplicated material
  22054. * @returns the cloned material
  22055. */
  22056. clone(name: string): Nullable<Material>;
  22057. /**
  22058. * Gets the meshes bound to the material
  22059. * @returns an array of meshes bound to the material
  22060. */
  22061. getBindedMeshes(): AbstractMesh[];
  22062. /**
  22063. * Force shader compilation
  22064. * @param mesh defines the mesh associated with this material
  22065. * @param onCompiled defines a function to execute once the material is compiled
  22066. * @param options defines the options to configure the compilation
  22067. */
  22068. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22069. clipPlane: boolean;
  22070. }>): void;
  22071. /**
  22072. * Force shader compilation
  22073. * @param mesh defines the mesh that will use this material
  22074. * @param options defines additional options for compiling the shaders
  22075. * @returns a promise that resolves when the compilation completes
  22076. */
  22077. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22078. clipPlane: boolean;
  22079. }>): Promise<void>;
  22080. private static readonly _ImageProcessingDirtyCallBack;
  22081. private static readonly _TextureDirtyCallBack;
  22082. private static readonly _FresnelDirtyCallBack;
  22083. private static readonly _MiscDirtyCallBack;
  22084. private static readonly _LightsDirtyCallBack;
  22085. private static readonly _AttributeDirtyCallBack;
  22086. private static _FresnelAndMiscDirtyCallBack;
  22087. private static _TextureAndMiscDirtyCallBack;
  22088. private static readonly _DirtyCallbackArray;
  22089. private static readonly _RunDirtyCallBacks;
  22090. /**
  22091. * Marks a define in the material to indicate that it needs to be re-computed
  22092. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22093. */
  22094. markAsDirty(flag: number): void;
  22095. /**
  22096. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22097. * @param func defines a function which checks material defines against the submeshes
  22098. */
  22099. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22100. /**
  22101. * Indicates that image processing needs to be re-calculated for all submeshes
  22102. */
  22103. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22104. /**
  22105. * Indicates that textures need to be re-calculated for all submeshes
  22106. */
  22107. protected _markAllSubMeshesAsTexturesDirty(): void;
  22108. /**
  22109. * Indicates that fresnel needs to be re-calculated for all submeshes
  22110. */
  22111. protected _markAllSubMeshesAsFresnelDirty(): void;
  22112. /**
  22113. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22114. */
  22115. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22116. /**
  22117. * Indicates that lights need to be re-calculated for all submeshes
  22118. */
  22119. protected _markAllSubMeshesAsLightsDirty(): void;
  22120. /**
  22121. * Indicates that attributes need to be re-calculated for all submeshes
  22122. */
  22123. protected _markAllSubMeshesAsAttributesDirty(): void;
  22124. /**
  22125. * Indicates that misc needs to be re-calculated for all submeshes
  22126. */
  22127. protected _markAllSubMeshesAsMiscDirty(): void;
  22128. /**
  22129. * Indicates that textures and misc need to be re-calculated for all submeshes
  22130. */
  22131. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22132. /**
  22133. * Disposes the material
  22134. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22135. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22136. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22137. */
  22138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22139. /** @hidden */
  22140. private releaseVertexArrayObject;
  22141. /**
  22142. * Serializes this material
  22143. * @returns the serialized material object
  22144. */
  22145. serialize(): any;
  22146. /**
  22147. * Creates a material from parsed material data
  22148. * @param parsedMaterial defines parsed material data
  22149. * @param scene defines the hosting scene
  22150. * @param rootUrl defines the root URL to use to load textures
  22151. * @returns a new material
  22152. */
  22153. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22154. }
  22155. }
  22156. declare module BABYLON {
  22157. /**
  22158. * Base class for submeshes
  22159. */
  22160. export class BaseSubMesh {
  22161. /** @hidden */
  22162. _materialDefines: Nullable<MaterialDefines>;
  22163. /** @hidden */
  22164. _materialEffect: Nullable<Effect>;
  22165. /**
  22166. * Gets associated effect
  22167. */
  22168. readonly effect: Nullable<Effect>;
  22169. /**
  22170. * Sets associated effect (effect used to render this submesh)
  22171. * @param effect defines the effect to associate with
  22172. * @param defines defines the set of defines used to compile this effect
  22173. */
  22174. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22175. }
  22176. /**
  22177. * Defines a subdivision inside a mesh
  22178. */
  22179. export class SubMesh extends BaseSubMesh implements ICullable {
  22180. /** the material index to use */
  22181. materialIndex: number;
  22182. /** vertex index start */
  22183. verticesStart: number;
  22184. /** vertices count */
  22185. verticesCount: number;
  22186. /** index start */
  22187. indexStart: number;
  22188. /** indices count */
  22189. indexCount: number;
  22190. /** @hidden */
  22191. _linesIndexCount: number;
  22192. private _mesh;
  22193. private _renderingMesh;
  22194. private _boundingInfo;
  22195. private _linesIndexBuffer;
  22196. /** @hidden */
  22197. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22198. /** @hidden */
  22199. _trianglePlanes: Plane[];
  22200. /** @hidden */
  22201. _lastColliderTransformMatrix: Matrix;
  22202. /** @hidden */
  22203. _renderId: number;
  22204. /** @hidden */
  22205. _alphaIndex: number;
  22206. /** @hidden */
  22207. _distanceToCamera: number;
  22208. /** @hidden */
  22209. _id: number;
  22210. private _currentMaterial;
  22211. /**
  22212. * Add a new submesh to a mesh
  22213. * @param materialIndex defines the material index to use
  22214. * @param verticesStart defines vertex index start
  22215. * @param verticesCount defines vertices count
  22216. * @param indexStart defines index start
  22217. * @param indexCount defines indices count
  22218. * @param mesh defines the parent mesh
  22219. * @param renderingMesh defines an optional rendering mesh
  22220. * @param createBoundingBox defines if bounding box should be created for this submesh
  22221. * @returns the new submesh
  22222. */
  22223. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22224. /**
  22225. * Creates a new submesh
  22226. * @param materialIndex defines the material index to use
  22227. * @param verticesStart defines vertex index start
  22228. * @param verticesCount defines vertices count
  22229. * @param indexStart defines index start
  22230. * @param indexCount defines indices count
  22231. * @param mesh defines the parent mesh
  22232. * @param renderingMesh defines an optional rendering mesh
  22233. * @param createBoundingBox defines if bounding box should be created for this submesh
  22234. */
  22235. constructor(
  22236. /** the material index to use */
  22237. materialIndex: number,
  22238. /** vertex index start */
  22239. verticesStart: number,
  22240. /** vertices count */
  22241. verticesCount: number,
  22242. /** index start */
  22243. indexStart: number,
  22244. /** indices count */
  22245. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22246. /**
  22247. * Returns true if this submesh covers the entire parent mesh
  22248. * @ignorenaming
  22249. */
  22250. readonly IsGlobal: boolean;
  22251. /**
  22252. * Returns the submesh BoudingInfo object
  22253. * @returns current bounding info (or mesh's one if the submesh is global)
  22254. */
  22255. getBoundingInfo(): BoundingInfo;
  22256. /**
  22257. * Sets the submesh BoundingInfo
  22258. * @param boundingInfo defines the new bounding info to use
  22259. * @returns the SubMesh
  22260. */
  22261. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22262. /**
  22263. * Returns the mesh of the current submesh
  22264. * @return the parent mesh
  22265. */
  22266. getMesh(): AbstractMesh;
  22267. /**
  22268. * Returns the rendering mesh of the submesh
  22269. * @returns the rendering mesh (could be different from parent mesh)
  22270. */
  22271. getRenderingMesh(): Mesh;
  22272. /**
  22273. * Returns the submesh material
  22274. * @returns null or the current material
  22275. */
  22276. getMaterial(): Nullable<Material>;
  22277. /**
  22278. * Sets a new updated BoundingInfo object to the submesh
  22279. * @returns the SubMesh
  22280. */
  22281. refreshBoundingInfo(): SubMesh;
  22282. /** @hidden */
  22283. _checkCollision(collider: Collider): boolean;
  22284. /**
  22285. * Updates the submesh BoundingInfo
  22286. * @param world defines the world matrix to use to update the bounding info
  22287. * @returns the submesh
  22288. */
  22289. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22290. /**
  22291. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22292. * @param frustumPlanes defines the frustum planes
  22293. * @returns true if the submesh is intersecting with the frustum
  22294. */
  22295. isInFrustum(frustumPlanes: Plane[]): boolean;
  22296. /**
  22297. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22298. * @param frustumPlanes defines the frustum planes
  22299. * @returns true if the submesh is inside the frustum
  22300. */
  22301. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22302. /**
  22303. * Renders the submesh
  22304. * @param enableAlphaMode defines if alpha needs to be used
  22305. * @returns the submesh
  22306. */
  22307. render(enableAlphaMode: boolean): SubMesh;
  22308. /**
  22309. * @hidden
  22310. */
  22311. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22312. /**
  22313. * Checks if the submesh intersects with a ray
  22314. * @param ray defines the ray to test
  22315. * @returns true is the passed ray intersects the submesh bounding box
  22316. */
  22317. canIntersects(ray: Ray): boolean;
  22318. /**
  22319. * Intersects current submesh with a ray
  22320. * @param ray defines the ray to test
  22321. * @param positions defines mesh's positions array
  22322. * @param indices defines mesh's indices array
  22323. * @param fastCheck defines if only bounding info should be used
  22324. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22325. * @returns intersection info or null if no intersection
  22326. */
  22327. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22328. /** @hidden */
  22329. private _intersectLines;
  22330. /** @hidden */
  22331. private _intersectTriangles;
  22332. /** @hidden */
  22333. _rebuild(): void;
  22334. /**
  22335. * Creates a new submesh from the passed mesh
  22336. * @param newMesh defines the new hosting mesh
  22337. * @param newRenderingMesh defines an optional rendering mesh
  22338. * @returns the new submesh
  22339. */
  22340. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22341. /**
  22342. * Release associated resources
  22343. */
  22344. dispose(): void;
  22345. /**
  22346. * Gets the class name
  22347. * @returns the string "SubMesh".
  22348. */
  22349. getClassName(): string;
  22350. /**
  22351. * Creates a new submesh from indices data
  22352. * @param materialIndex the index of the main mesh material
  22353. * @param startIndex the index where to start the copy in the mesh indices array
  22354. * @param indexCount the number of indices to copy then from the startIndex
  22355. * @param mesh the main mesh to create the submesh from
  22356. * @param renderingMesh the optional rendering mesh
  22357. * @returns a new submesh
  22358. */
  22359. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22360. }
  22361. }
  22362. declare module BABYLON {
  22363. /**
  22364. * Class used to store geometry data (vertex buffers + index buffer)
  22365. */
  22366. export class Geometry implements IGetSetVerticesData {
  22367. /**
  22368. * Gets or sets the ID of the geometry
  22369. */
  22370. id: string;
  22371. /**
  22372. * Gets or sets the unique ID of the geometry
  22373. */
  22374. uniqueId: number;
  22375. /**
  22376. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22377. */
  22378. delayLoadState: number;
  22379. /**
  22380. * Gets the file containing the data to load when running in delay load state
  22381. */
  22382. delayLoadingFile: Nullable<string>;
  22383. /**
  22384. * Callback called when the geometry is updated
  22385. */
  22386. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22387. private _scene;
  22388. private _engine;
  22389. private _meshes;
  22390. private _totalVertices;
  22391. /** @hidden */
  22392. _indices: IndicesArray;
  22393. /** @hidden */
  22394. _vertexBuffers: {
  22395. [key: string]: VertexBuffer;
  22396. };
  22397. private _isDisposed;
  22398. private _extend;
  22399. private _boundingBias;
  22400. /** @hidden */
  22401. _delayInfo: Array<string>;
  22402. private _indexBuffer;
  22403. private _indexBufferIsUpdatable;
  22404. /** @hidden */
  22405. _boundingInfo: Nullable<BoundingInfo>;
  22406. /** @hidden */
  22407. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22408. /** @hidden */
  22409. _softwareSkinningFrameId: number;
  22410. private _vertexArrayObjects;
  22411. private _updatable;
  22412. /** @hidden */
  22413. _positions: Nullable<Vector3[]>;
  22414. /**
  22415. * 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
  22416. */
  22417. /**
  22418. * 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
  22419. */
  22420. boundingBias: Vector2;
  22421. /**
  22422. * Static function used to attach a new empty geometry to a mesh
  22423. * @param mesh defines the mesh to attach the geometry to
  22424. * @returns the new Geometry
  22425. */
  22426. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22427. /**
  22428. * Creates a new geometry
  22429. * @param id defines the unique ID
  22430. * @param scene defines the hosting scene
  22431. * @param vertexData defines the VertexData used to get geometry data
  22432. * @param updatable defines if geometry must be updatable (false by default)
  22433. * @param mesh defines the mesh that will be associated with the geometry
  22434. */
  22435. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22436. /**
  22437. * Gets the current extend of the geometry
  22438. */
  22439. readonly extend: {
  22440. minimum: Vector3;
  22441. maximum: Vector3;
  22442. };
  22443. /**
  22444. * Gets the hosting scene
  22445. * @returns the hosting Scene
  22446. */
  22447. getScene(): Scene;
  22448. /**
  22449. * Gets the hosting engine
  22450. * @returns the hosting Engine
  22451. */
  22452. getEngine(): Engine;
  22453. /**
  22454. * Defines if the geometry is ready to use
  22455. * @returns true if the geometry is ready to be used
  22456. */
  22457. isReady(): boolean;
  22458. /**
  22459. * Gets a value indicating that the geometry should not be serialized
  22460. */
  22461. readonly doNotSerialize: boolean;
  22462. /** @hidden */
  22463. _rebuild(): void;
  22464. /**
  22465. * Affects all geometry data in one call
  22466. * @param vertexData defines the geometry data
  22467. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22468. */
  22469. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22470. /**
  22471. * Set specific vertex data
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the vertex data to use
  22474. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22475. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22476. */
  22477. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22478. /**
  22479. * Removes a specific vertex data
  22480. * @param kind defines the data kind (Position, normal, etc...)
  22481. */
  22482. removeVerticesData(kind: string): void;
  22483. /**
  22484. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22485. * @param buffer defines the vertex buffer to use
  22486. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22487. */
  22488. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22489. /**
  22490. * Update a specific vertex buffer
  22491. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22492. * It will do nothing if the buffer is not updatable
  22493. * @param kind defines the data kind (Position, normal, etc...)
  22494. * @param data defines the data to use
  22495. * @param offset defines the offset in the target buffer where to store the data
  22496. * @param useBytes set to true if the offset is in bytes
  22497. */
  22498. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22499. /**
  22500. * Update a specific vertex buffer
  22501. * This function will create a new buffer if the current one is not updatable
  22502. * @param kind defines the data kind (Position, normal, etc...)
  22503. * @param data defines the data to use
  22504. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22505. */
  22506. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22507. private _updateBoundingInfo;
  22508. /** @hidden */
  22509. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22510. /**
  22511. * Gets total number of vertices
  22512. * @returns the total number of vertices
  22513. */
  22514. getTotalVertices(): number;
  22515. /**
  22516. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22517. * @param kind defines the data kind (Position, normal, etc...)
  22518. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22519. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22520. * @returns a float array containing vertex data
  22521. */
  22522. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22523. /**
  22524. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22525. * @param kind defines the data kind (Position, normal, etc...)
  22526. * @returns true if the vertex buffer with the specified kind is updatable
  22527. */
  22528. isVertexBufferUpdatable(kind: string): boolean;
  22529. /**
  22530. * Gets a specific vertex buffer
  22531. * @param kind defines the data kind (Position, normal, etc...)
  22532. * @returns a VertexBuffer
  22533. */
  22534. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22535. /**
  22536. * Returns all vertex buffers
  22537. * @return an object holding all vertex buffers indexed by kind
  22538. */
  22539. getVertexBuffers(): Nullable<{
  22540. [key: string]: VertexBuffer;
  22541. }>;
  22542. /**
  22543. * Gets a boolean indicating if specific vertex buffer is present
  22544. * @param kind defines the data kind (Position, normal, etc...)
  22545. * @returns true if data is present
  22546. */
  22547. isVerticesDataPresent(kind: string): boolean;
  22548. /**
  22549. * Gets a list of all attached data kinds (Position, normal, etc...)
  22550. * @returns a list of string containing all kinds
  22551. */
  22552. getVerticesDataKinds(): string[];
  22553. /**
  22554. * Update index buffer
  22555. * @param indices defines the indices to store in the index buffer
  22556. * @param offset defines the offset in the target buffer where to store the data
  22557. * @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)
  22558. */
  22559. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22560. /**
  22561. * Creates a new index buffer
  22562. * @param indices defines the indices to store in the index buffer
  22563. * @param totalVertices defines the total number of vertices (could be null)
  22564. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22565. */
  22566. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22567. /**
  22568. * Return the total number of indices
  22569. * @returns the total number of indices
  22570. */
  22571. getTotalIndices(): number;
  22572. /**
  22573. * Gets the index buffer array
  22574. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22575. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22576. * @returns the index buffer array
  22577. */
  22578. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22579. /**
  22580. * Gets the index buffer
  22581. * @return the index buffer
  22582. */
  22583. getIndexBuffer(): Nullable<WebGLBuffer>;
  22584. /** @hidden */
  22585. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22586. /**
  22587. * Release the associated resources for a specific mesh
  22588. * @param mesh defines the source mesh
  22589. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22590. */
  22591. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22592. /**
  22593. * Apply current geometry to a given mesh
  22594. * @param mesh defines the mesh to apply geometry to
  22595. */
  22596. applyToMesh(mesh: Mesh): void;
  22597. private _updateExtend;
  22598. private _applyToMesh;
  22599. private notifyUpdate;
  22600. /**
  22601. * Load the geometry if it was flagged as delay loaded
  22602. * @param scene defines the hosting scene
  22603. * @param onLoaded defines a callback called when the geometry is loaded
  22604. */
  22605. load(scene: Scene, onLoaded?: () => void): void;
  22606. private _queueLoad;
  22607. /**
  22608. * Invert the geometry to move from a right handed system to a left handed one.
  22609. */
  22610. toLeftHanded(): void;
  22611. /** @hidden */
  22612. _resetPointsArrayCache(): void;
  22613. /** @hidden */
  22614. _generatePointsArray(): boolean;
  22615. /**
  22616. * Gets a value indicating if the geometry is disposed
  22617. * @returns true if the geometry was disposed
  22618. */
  22619. isDisposed(): boolean;
  22620. private _disposeVertexArrayObjects;
  22621. /**
  22622. * Free all associated resources
  22623. */
  22624. dispose(): void;
  22625. /**
  22626. * Clone the current geometry into a new geometry
  22627. * @param id defines the unique ID of the new geometry
  22628. * @returns a new geometry object
  22629. */
  22630. copy(id: string): Geometry;
  22631. /**
  22632. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22633. * @return a JSON representation of the current geometry data (without the vertices data)
  22634. */
  22635. serialize(): any;
  22636. private toNumberArray;
  22637. /**
  22638. * Serialize all vertices data into a JSON oject
  22639. * @returns a JSON representation of the current geometry data
  22640. */
  22641. serializeVerticeData(): any;
  22642. /**
  22643. * Extracts a clone of a mesh geometry
  22644. * @param mesh defines the source mesh
  22645. * @param id defines the unique ID of the new geometry object
  22646. * @returns the new geometry object
  22647. */
  22648. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22649. /**
  22650. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22651. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22652. * Be aware Math.random() could cause collisions, but:
  22653. * "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"
  22654. * @returns a string containing a new GUID
  22655. */
  22656. static RandomId(): string;
  22657. /** @hidden */
  22658. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22659. private static _CleanMatricesWeights;
  22660. /**
  22661. * Create a new geometry from persisted data (Using .babylon file format)
  22662. * @param parsedVertexData defines the persisted data
  22663. * @param scene defines the hosting scene
  22664. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22665. * @returns the new geometry object
  22666. */
  22667. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22668. }
  22669. }
  22670. declare module BABYLON {
  22671. /**
  22672. * Define an interface for all classes that will get and set the data on vertices
  22673. */
  22674. export interface IGetSetVerticesData {
  22675. /**
  22676. * Gets a boolean indicating if specific vertex data is present
  22677. * @param kind defines the vertex data kind to use
  22678. * @returns true is data kind is present
  22679. */
  22680. isVerticesDataPresent(kind: string): boolean;
  22681. /**
  22682. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22683. * @param kind defines the data kind (Position, normal, etc...)
  22684. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22686. * @returns a float array containing vertex data
  22687. */
  22688. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22689. /**
  22690. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22691. * @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.
  22692. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22693. * @returns the indices array or an empty array if the mesh has no geometry
  22694. */
  22695. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22696. /**
  22697. * Set specific vertex data
  22698. * @param kind defines the data kind (Position, normal, etc...)
  22699. * @param data defines the vertex data to use
  22700. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22701. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22702. */
  22703. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22704. /**
  22705. * Update a specific associated vertex buffer
  22706. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22707. * - VertexBuffer.PositionKind
  22708. * - VertexBuffer.UVKind
  22709. * - VertexBuffer.UV2Kind
  22710. * - VertexBuffer.UV3Kind
  22711. * - VertexBuffer.UV4Kind
  22712. * - VertexBuffer.UV5Kind
  22713. * - VertexBuffer.UV6Kind
  22714. * - VertexBuffer.ColorKind
  22715. * - VertexBuffer.MatricesIndicesKind
  22716. * - VertexBuffer.MatricesIndicesExtraKind
  22717. * - VertexBuffer.MatricesWeightsKind
  22718. * - VertexBuffer.MatricesWeightsExtraKind
  22719. * @param data defines the data source
  22720. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22721. * @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)
  22722. */
  22723. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22724. /**
  22725. * Creates a new index buffer
  22726. * @param indices defines the indices to store in the index buffer
  22727. * @param totalVertices defines the total number of vertices (could be null)
  22728. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22729. */
  22730. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22731. }
  22732. /**
  22733. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22734. */
  22735. export class VertexData {
  22736. /**
  22737. * Mesh side orientation : usually the external or front surface
  22738. */
  22739. static readonly FRONTSIDE: number;
  22740. /**
  22741. * Mesh side orientation : usually the internal or back surface
  22742. */
  22743. static readonly BACKSIDE: number;
  22744. /**
  22745. * Mesh side orientation : both internal and external or front and back surfaces
  22746. */
  22747. static readonly DOUBLESIDE: number;
  22748. /**
  22749. * Mesh side orientation : by default, `FRONTSIDE`
  22750. */
  22751. static readonly DEFAULTSIDE: number;
  22752. /**
  22753. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22754. */
  22755. positions: Nullable<FloatArray>;
  22756. /**
  22757. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22758. */
  22759. normals: Nullable<FloatArray>;
  22760. /**
  22761. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22762. */
  22763. tangents: Nullable<FloatArray>;
  22764. /**
  22765. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs: Nullable<FloatArray>;
  22768. /**
  22769. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs2: Nullable<FloatArray>;
  22772. /**
  22773. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22774. */
  22775. uvs3: Nullable<FloatArray>;
  22776. /**
  22777. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22778. */
  22779. uvs4: Nullable<FloatArray>;
  22780. /**
  22781. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22782. */
  22783. uvs5: Nullable<FloatArray>;
  22784. /**
  22785. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22786. */
  22787. uvs6: Nullable<FloatArray>;
  22788. /**
  22789. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22790. */
  22791. colors: Nullable<FloatArray>;
  22792. /**
  22793. * 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).
  22794. */
  22795. matricesIndices: Nullable<FloatArray>;
  22796. /**
  22797. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22798. */
  22799. matricesWeights: Nullable<FloatArray>;
  22800. /**
  22801. * An array extending the number of possible indices
  22802. */
  22803. matricesIndicesExtra: Nullable<FloatArray>;
  22804. /**
  22805. * An array extending the number of possible weights when the number of indices is extended
  22806. */
  22807. matricesWeightsExtra: Nullable<FloatArray>;
  22808. /**
  22809. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22810. */
  22811. indices: Nullable<IndicesArray>;
  22812. /**
  22813. * Uses the passed data array to set the set the values for the specified kind of data
  22814. * @param data a linear array of floating numbers
  22815. * @param kind the type of data that is being set, eg positions, colors etc
  22816. */
  22817. set(data: FloatArray, kind: string): void;
  22818. /**
  22819. * Associates the vertexData to the passed Mesh.
  22820. * Sets it as updatable or not (default `false`)
  22821. * @param mesh the mesh the vertexData is applied to
  22822. * @param updatable when used and having the value true allows new data to update the vertexData
  22823. * @returns the VertexData
  22824. */
  22825. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22826. /**
  22827. * Associates the vertexData to the passed Geometry.
  22828. * Sets it as updatable or not (default `false`)
  22829. * @param geometry the geometry the vertexData is applied to
  22830. * @param updatable when used and having the value true allows new data to update the vertexData
  22831. * @returns VertexData
  22832. */
  22833. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22834. /**
  22835. * Updates the associated mesh
  22836. * @param mesh the mesh to be updated
  22837. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22838. * @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
  22839. * @returns VertexData
  22840. */
  22841. updateMesh(mesh: Mesh): VertexData;
  22842. /**
  22843. * Updates the associated geometry
  22844. * @param geometry the geometry to be updated
  22845. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22846. * @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
  22847. * @returns VertexData.
  22848. */
  22849. updateGeometry(geometry: Geometry): VertexData;
  22850. private _applyTo;
  22851. private _update;
  22852. /**
  22853. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22854. * @param matrix the transforming matrix
  22855. * @returns the VertexData
  22856. */
  22857. transform(matrix: Matrix): VertexData;
  22858. /**
  22859. * Merges the passed VertexData into the current one
  22860. * @param other the VertexData to be merged into the current one
  22861. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22862. * @returns the modified VertexData
  22863. */
  22864. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22865. private _mergeElement;
  22866. private _validate;
  22867. /**
  22868. * Serializes the VertexData
  22869. * @returns a serialized object
  22870. */
  22871. serialize(): any;
  22872. /**
  22873. * Extracts the vertexData from a mesh
  22874. * @param mesh the mesh from which to extract the VertexData
  22875. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22876. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22877. * @returns the object VertexData associated to the passed mesh
  22878. */
  22879. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22880. /**
  22881. * Extracts the vertexData from the geometry
  22882. * @param geometry the geometry from which to extract the VertexData
  22883. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22884. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22885. * @returns the object VertexData associated to the passed mesh
  22886. */
  22887. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22888. private static _ExtractFrom;
  22889. /**
  22890. * Creates the VertexData for a Ribbon
  22891. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22892. * * pathArray array of paths, each of which an array of successive Vector3
  22893. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22894. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22895. * * 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
  22896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22897. * * 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)
  22898. * * 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)
  22899. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22900. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22901. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22902. * @returns the VertexData of the ribbon
  22903. */
  22904. static CreateRibbon(options: {
  22905. pathArray: Vector3[][];
  22906. closeArray?: boolean;
  22907. closePath?: boolean;
  22908. offset?: number;
  22909. sideOrientation?: number;
  22910. frontUVs?: Vector4;
  22911. backUVs?: Vector4;
  22912. invertUV?: boolean;
  22913. uvs?: Vector2[];
  22914. colors?: Color4[];
  22915. }): VertexData;
  22916. /**
  22917. * Creates the VertexData for a box
  22918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22919. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22920. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22921. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22922. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22923. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22924. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22926. * * 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)
  22927. * * 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)
  22928. * @returns the VertexData of the box
  22929. */
  22930. static CreateBox(options: {
  22931. size?: number;
  22932. width?: number;
  22933. height?: number;
  22934. depth?: number;
  22935. faceUV?: Vector4[];
  22936. faceColors?: Color4[];
  22937. sideOrientation?: number;
  22938. frontUVs?: Vector4;
  22939. backUVs?: Vector4;
  22940. }): VertexData;
  22941. /**
  22942. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22943. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22944. * * segments sets the number of horizontal strips optional, default 32
  22945. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22946. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22947. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22948. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22949. * * 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
  22950. * * 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
  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 ellipsoid
  22955. */
  22956. static CreateSphere(options: {
  22957. segments?: number;
  22958. diameter?: number;
  22959. diameterX?: number;
  22960. diameterY?: number;
  22961. diameterZ?: number;
  22962. arc?: number;
  22963. slice?: number;
  22964. sideOrientation?: number;
  22965. frontUVs?: Vector4;
  22966. backUVs?: Vector4;
  22967. }): VertexData;
  22968. /**
  22969. * Creates the VertexData for a cylinder, cone or prism
  22970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22971. * * height sets the height (y direction) of the cylinder, optional, default 2
  22972. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22973. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22974. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22975. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22976. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22977. * * 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
  22978. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22979. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22980. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22981. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22983. * * 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)
  22984. * * 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)
  22985. * @returns the VertexData of the cylinder, cone or prism
  22986. */
  22987. static CreateCylinder(options: {
  22988. height?: number;
  22989. diameterTop?: number;
  22990. diameterBottom?: number;
  22991. diameter?: number;
  22992. tessellation?: number;
  22993. subdivisions?: number;
  22994. arc?: number;
  22995. faceColors?: Color4[];
  22996. faceUV?: Vector4[];
  22997. hasRings?: boolean;
  22998. enclose?: boolean;
  22999. sideOrientation?: number;
  23000. frontUVs?: Vector4;
  23001. backUVs?: Vector4;
  23002. }): VertexData;
  23003. /**
  23004. * Creates the VertexData for a torus
  23005. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23006. * * diameter the diameter of the torus, optional default 1
  23007. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23008. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23010. * * 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)
  23011. * * 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)
  23012. * @returns the VertexData of the torus
  23013. */
  23014. static CreateTorus(options: {
  23015. diameter?: number;
  23016. thickness?: number;
  23017. tessellation?: number;
  23018. sideOrientation?: number;
  23019. frontUVs?: Vector4;
  23020. backUVs?: Vector4;
  23021. }): VertexData;
  23022. /**
  23023. * Creates the VertexData of the LineSystem
  23024. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23025. * - lines an array of lines, each line being an array of successive Vector3
  23026. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23027. * @returns the VertexData of the LineSystem
  23028. */
  23029. static CreateLineSystem(options: {
  23030. lines: Vector3[][];
  23031. colors?: Nullable<Color4[][]>;
  23032. }): VertexData;
  23033. /**
  23034. * Create the VertexData for a DashedLines
  23035. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23036. * - points an array successive Vector3
  23037. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23038. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23039. * - dashNb the intended total number of dashes, optional, default 200
  23040. * @returns the VertexData for the DashedLines
  23041. */
  23042. static CreateDashedLines(options: {
  23043. points: Vector3[];
  23044. dashSize?: number;
  23045. gapSize?: number;
  23046. dashNb?: number;
  23047. }): VertexData;
  23048. /**
  23049. * Creates the VertexData for a Ground
  23050. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23051. * - width the width (x direction) of the ground, optional, default 1
  23052. * - height the height (z direction) of the ground, optional, default 1
  23053. * - subdivisions the number of subdivisions per side, optional, default 1
  23054. * @returns the VertexData of the Ground
  23055. */
  23056. static CreateGround(options: {
  23057. width?: number;
  23058. height?: number;
  23059. subdivisions?: number;
  23060. subdivisionsX?: number;
  23061. subdivisionsY?: number;
  23062. }): VertexData;
  23063. /**
  23064. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23065. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23066. * * xmin the ground minimum X coordinate, optional, default -1
  23067. * * zmin the ground minimum Z coordinate, optional, default -1
  23068. * * xmax the ground maximum X coordinate, optional, default 1
  23069. * * zmax the ground maximum Z coordinate, optional, default 1
  23070. * * 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}
  23071. * * 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}
  23072. * @returns the VertexData of the TiledGround
  23073. */
  23074. static CreateTiledGround(options: {
  23075. xmin: number;
  23076. zmin: number;
  23077. xmax: number;
  23078. zmax: number;
  23079. subdivisions?: {
  23080. w: number;
  23081. h: number;
  23082. };
  23083. precision?: {
  23084. w: number;
  23085. h: number;
  23086. };
  23087. }): VertexData;
  23088. /**
  23089. * Creates the VertexData of the Ground designed from a heightmap
  23090. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23091. * * width the width (x direction) of the ground
  23092. * * height the height (z direction) of the ground
  23093. * * subdivisions the number of subdivisions per side
  23094. * * minHeight the minimum altitude on the ground, optional, default 0
  23095. * * maxHeight the maximum altitude on the ground, optional default 1
  23096. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23097. * * buffer the array holding the image color data
  23098. * * bufferWidth the width of image
  23099. * * bufferHeight the height of image
  23100. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23101. * @returns the VertexData of the Ground designed from a heightmap
  23102. */
  23103. static CreateGroundFromHeightMap(options: {
  23104. width: number;
  23105. height: number;
  23106. subdivisions: number;
  23107. minHeight: number;
  23108. maxHeight: number;
  23109. colorFilter: Color3;
  23110. buffer: Uint8Array;
  23111. bufferWidth: number;
  23112. bufferHeight: number;
  23113. alphaFilter: number;
  23114. }): VertexData;
  23115. /**
  23116. * Creates the VertexData for a Plane
  23117. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23118. * * size sets the width and height of the plane to the value of size, optional default 1
  23119. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23120. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23122. * * 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)
  23123. * * 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)
  23124. * @returns the VertexData of the box
  23125. */
  23126. static CreatePlane(options: {
  23127. size?: number;
  23128. width?: number;
  23129. height?: number;
  23130. sideOrientation?: number;
  23131. frontUVs?: Vector4;
  23132. backUVs?: Vector4;
  23133. }): VertexData;
  23134. /**
  23135. * Creates the VertexData of the Disc or regular Polygon
  23136. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23137. * * radius the radius of the disc, optional default 0.5
  23138. * * tessellation the number of polygon sides, optional, default 64
  23139. * * 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
  23140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23141. * * 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)
  23142. * * 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)
  23143. * @returns the VertexData of the box
  23144. */
  23145. static CreateDisc(options: {
  23146. radius?: number;
  23147. tessellation?: number;
  23148. arc?: number;
  23149. sideOrientation?: number;
  23150. frontUVs?: Vector4;
  23151. backUVs?: Vector4;
  23152. }): VertexData;
  23153. /**
  23154. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23155. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23156. * @param polygon a mesh built from polygonTriangulation.build()
  23157. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23158. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23159. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23160. * @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)
  23161. * @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)
  23162. * @returns the VertexData of the Polygon
  23163. */
  23164. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23165. /**
  23166. * Creates the VertexData of the IcoSphere
  23167. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23168. * * radius the radius of the IcoSphere, optional default 1
  23169. * * radiusX allows stretching in the x direction, optional, default radius
  23170. * * radiusY allows stretching in the y direction, optional, default radius
  23171. * * radiusZ allows stretching in the z direction, optional, default radius
  23172. * * flat when true creates a flat shaded mesh, optional, default true
  23173. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23175. * * 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)
  23176. * * 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)
  23177. * @returns the VertexData of the IcoSphere
  23178. */
  23179. static CreateIcoSphere(options: {
  23180. radius?: number;
  23181. radiusX?: number;
  23182. radiusY?: number;
  23183. radiusZ?: number;
  23184. flat?: boolean;
  23185. subdivisions?: number;
  23186. sideOrientation?: number;
  23187. frontUVs?: Vector4;
  23188. backUVs?: Vector4;
  23189. }): VertexData;
  23190. /**
  23191. * Creates the VertexData for a Polyhedron
  23192. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23193. * * type provided types are:
  23194. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23195. * * 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)
  23196. * * size the size of the IcoSphere, optional default 1
  23197. * * sizeX allows stretching in the x direction, optional, default size
  23198. * * sizeY allows stretching in the y direction, optional, default size
  23199. * * sizeZ allows stretching in the z direction, optional, default size
  23200. * * 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
  23201. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23203. * * flat when true creates a flat shaded mesh, optional, default true
  23204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23206. * * 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)
  23207. * * 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)
  23208. * @returns the VertexData of the Polyhedron
  23209. */
  23210. static CreatePolyhedron(options: {
  23211. type?: number;
  23212. size?: number;
  23213. sizeX?: number;
  23214. sizeY?: number;
  23215. sizeZ?: number;
  23216. custom?: any;
  23217. faceUV?: Vector4[];
  23218. faceColors?: Color4[];
  23219. flat?: boolean;
  23220. sideOrientation?: number;
  23221. frontUVs?: Vector4;
  23222. backUVs?: Vector4;
  23223. }): VertexData;
  23224. /**
  23225. * Creates the VertexData for a TorusKnot
  23226. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23227. * * radius the radius of the torus knot, optional, default 2
  23228. * * tube the thickness of the tube, optional, default 0.5
  23229. * * radialSegments the number of sides on each tube segments, optional, default 32
  23230. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23231. * * p the number of windings around the z axis, optional, default 2
  23232. * * q the number of windings around the x axis, optional, default 3
  23233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23234. * * 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)
  23235. * * 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)
  23236. * @returns the VertexData of the Torus Knot
  23237. */
  23238. static CreateTorusKnot(options: {
  23239. radius?: number;
  23240. tube?: number;
  23241. radialSegments?: number;
  23242. tubularSegments?: number;
  23243. p?: number;
  23244. q?: number;
  23245. sideOrientation?: number;
  23246. frontUVs?: Vector4;
  23247. backUVs?: Vector4;
  23248. }): VertexData;
  23249. /**
  23250. * Compute normals for given positions and indices
  23251. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23252. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23253. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23254. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23255. * * facetNormals : optional array of facet normals (vector3)
  23256. * * facetPositions : optional array of facet positions (vector3)
  23257. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23258. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23259. * * bInfo : optional bounding info, required for facetPartitioning computation
  23260. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23261. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23262. * * useRightHandedSystem: optional boolean to for right handed system computation
  23263. * * depthSort : optional boolean to enable the facet depth sort computation
  23264. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23265. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23266. */
  23267. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23268. facetNormals?: any;
  23269. facetPositions?: any;
  23270. facetPartitioning?: any;
  23271. ratio?: number;
  23272. bInfo?: any;
  23273. bbSize?: Vector3;
  23274. subDiv?: any;
  23275. useRightHandedSystem?: boolean;
  23276. depthSort?: boolean;
  23277. distanceTo?: Vector3;
  23278. depthSortedFacets?: any;
  23279. }): void;
  23280. /** @hidden */
  23281. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23282. /**
  23283. * Applies VertexData created from the imported parameters to the geometry
  23284. * @param parsedVertexData the parsed data from an imported file
  23285. * @param geometry the geometry to apply the VertexData to
  23286. */
  23287. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23288. }
  23289. }
  23290. declare module BABYLON {
  23291. /**
  23292. * Class containing static functions to help procedurally build meshes
  23293. */
  23294. export class DiscBuilder {
  23295. /**
  23296. * Creates a plane polygonal mesh. By default, this is a disc
  23297. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23298. * * 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
  23299. * * 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
  23300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23301. * * 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
  23302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23303. * @param name defines the name of the mesh
  23304. * @param options defines the options used to create the mesh
  23305. * @param scene defines the hosting scene
  23306. * @returns the plane polygonal mesh
  23307. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23308. */
  23309. static CreateDisc(name: string, options: {
  23310. radius?: number;
  23311. tessellation?: number;
  23312. arc?: number;
  23313. updatable?: boolean;
  23314. sideOrientation?: number;
  23315. frontUVs?: Vector4;
  23316. backUVs?: Vector4;
  23317. }, scene?: Nullable<Scene>): Mesh;
  23318. }
  23319. }
  23320. declare module BABYLON {
  23321. /**
  23322. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23323. *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.
  23324. * The SPS is also a particle system. It provides some methods to manage the particles.
  23325. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23326. *
  23327. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23328. */
  23329. export class SolidParticleSystem implements IDisposable {
  23330. /**
  23331. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23332. * Example : var p = SPS.particles[i];
  23333. */
  23334. particles: SolidParticle[];
  23335. /**
  23336. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23337. */
  23338. nbParticles: number;
  23339. /**
  23340. * If the particles must ever face the camera (default false). Useful for planar particles.
  23341. */
  23342. billboard: boolean;
  23343. /**
  23344. * Recompute normals when adding a shape
  23345. */
  23346. recomputeNormals: boolean;
  23347. /**
  23348. * This a counter ofr your own usage. It's not set by any SPS functions.
  23349. */
  23350. counter: number;
  23351. /**
  23352. * The SPS name. This name is also given to the underlying mesh.
  23353. */
  23354. name: string;
  23355. /**
  23356. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23357. */
  23358. mesh: Mesh;
  23359. /**
  23360. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23361. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23362. */
  23363. vars: any;
  23364. /**
  23365. * This array is populated when the SPS is set as 'pickable'.
  23366. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23367. * Each element of this array is an object `{idx: int, faceId: int}`.
  23368. * `idx` is the picked particle index in the `SPS.particles` array
  23369. * `faceId` is the picked face index counted within this particle.
  23370. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23371. */
  23372. pickedParticles: {
  23373. idx: number;
  23374. faceId: number;
  23375. }[];
  23376. /**
  23377. * This array is populated when `enableDepthSort` is set to true.
  23378. * Each element of this array is an instance of the class DepthSortedParticle.
  23379. */
  23380. depthSortedParticles: DepthSortedParticle[];
  23381. /**
  23382. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23383. * @hidden
  23384. */
  23385. _bSphereOnly: boolean;
  23386. /**
  23387. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23388. * @hidden
  23389. */
  23390. _bSphereRadiusFactor: number;
  23391. private _scene;
  23392. private _positions;
  23393. private _indices;
  23394. private _normals;
  23395. private _colors;
  23396. private _uvs;
  23397. private _indices32;
  23398. private _positions32;
  23399. private _normals32;
  23400. private _fixedNormal32;
  23401. private _colors32;
  23402. private _uvs32;
  23403. private _index;
  23404. private _updatable;
  23405. private _pickable;
  23406. private _isVisibilityBoxLocked;
  23407. private _alwaysVisible;
  23408. private _depthSort;
  23409. private _shapeCounter;
  23410. private _copy;
  23411. private _color;
  23412. private _computeParticleColor;
  23413. private _computeParticleTexture;
  23414. private _computeParticleRotation;
  23415. private _computeParticleVertex;
  23416. private _computeBoundingBox;
  23417. private _depthSortParticles;
  23418. private _camera;
  23419. private _mustUnrotateFixedNormals;
  23420. private _particlesIntersect;
  23421. private _needs32Bits;
  23422. /**
  23423. * Creates a SPS (Solid Particle System) object.
  23424. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23425. * @param scene (Scene) is the scene in which the SPS is added.
  23426. * @param options defines the options of the sps e.g.
  23427. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23428. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23429. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23430. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23431. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23432. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23433. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23434. */
  23435. constructor(name: string, scene: Scene, options?: {
  23436. updatable?: boolean;
  23437. isPickable?: boolean;
  23438. enableDepthSort?: boolean;
  23439. particleIntersection?: boolean;
  23440. boundingSphereOnly?: boolean;
  23441. bSphereRadiusFactor?: number;
  23442. });
  23443. /**
  23444. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23445. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23446. * @returns the created mesh
  23447. */
  23448. buildMesh(): Mesh;
  23449. /**
  23450. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23451. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23452. * Thus the particles generated from `digest()` have their property `position` set yet.
  23453. * @param mesh ( Mesh ) is the mesh to be digested
  23454. * @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
  23455. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23456. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23457. * @returns the current SPS
  23458. */
  23459. digest(mesh: Mesh, options?: {
  23460. facetNb?: number;
  23461. number?: number;
  23462. delta?: number;
  23463. }): SolidParticleSystem;
  23464. private _unrotateFixedNormals;
  23465. private _resetCopy;
  23466. private _meshBuilder;
  23467. private _posToShape;
  23468. private _uvsToShapeUV;
  23469. private _addParticle;
  23470. /**
  23471. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23472. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23473. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23474. * @param nb (positive integer) the number of particles to be created from this model
  23475. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23476. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23477. * @returns the number of shapes in the system
  23478. */
  23479. addShape(mesh: Mesh, nb: number, options?: {
  23480. positionFunction?: any;
  23481. vertexFunction?: any;
  23482. }): number;
  23483. private _rebuildParticle;
  23484. /**
  23485. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23486. * @returns the SPS.
  23487. */
  23488. rebuildMesh(): SolidParticleSystem;
  23489. /**
  23490. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23491. * This method calls `updateParticle()` for each particle of the SPS.
  23492. * For an animated SPS, it is usually called within the render loop.
  23493. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23494. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23495. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23496. * @returns the SPS.
  23497. */
  23498. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23499. /**
  23500. * Disposes the SPS.
  23501. */
  23502. dispose(): void;
  23503. /**
  23504. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23505. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23506. * @returns the SPS.
  23507. */
  23508. refreshVisibleSize(): SolidParticleSystem;
  23509. /**
  23510. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23511. * @param size the size (float) of the visibility box
  23512. * note : this doesn't lock the SPS mesh bounding box.
  23513. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23514. */
  23515. setVisibilityBox(size: number): void;
  23516. /**
  23517. * Gets whether the SPS as always visible or not
  23518. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23519. */
  23520. /**
  23521. * Sets the SPS as always visible or not
  23522. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23523. */
  23524. isAlwaysVisible: boolean;
  23525. /**
  23526. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23527. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23528. */
  23529. /**
  23530. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23531. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23532. */
  23533. isVisibilityBoxLocked: boolean;
  23534. /**
  23535. * Tells to `setParticles()` to compute the particle rotations or not.
  23536. * Default value : true. The SPS is faster when it's set to false.
  23537. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23538. */
  23539. /**
  23540. * Gets if `setParticles()` computes the particle rotations or not.
  23541. * Default value : true. The SPS is faster when it's set to false.
  23542. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23543. */
  23544. computeParticleRotation: boolean;
  23545. /**
  23546. * Tells to `setParticles()` to compute the particle colors or not.
  23547. * Default value : true. The SPS is faster when it's set to false.
  23548. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23549. */
  23550. /**
  23551. * Gets if `setParticles()` computes the particle colors or not.
  23552. * Default value : true. The SPS is faster when it's set to false.
  23553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23554. */
  23555. computeParticleColor: boolean;
  23556. /**
  23557. * Gets if `setParticles()` computes the particle textures or not.
  23558. * Default value : true. The SPS is faster when it's set to false.
  23559. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23560. */
  23561. computeParticleTexture: boolean;
  23562. /**
  23563. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23564. * Default value : false. The SPS is faster when it's set to false.
  23565. * Note : the particle custom vertex positions aren't stored values.
  23566. */
  23567. /**
  23568. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23569. * Default value : false. The SPS is faster when it's set to false.
  23570. * Note : the particle custom vertex positions aren't stored values.
  23571. */
  23572. computeParticleVertex: boolean;
  23573. /**
  23574. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23575. */
  23576. /**
  23577. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23578. */
  23579. computeBoundingBox: boolean;
  23580. /**
  23581. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23582. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23583. * Default : `true`
  23584. */
  23585. /**
  23586. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23588. * Default : `true`
  23589. */
  23590. depthSortParticles: boolean;
  23591. /**
  23592. * This function does nothing. It may be overwritten to set all the particle first values.
  23593. * The SPS doesn't call this function, you may have to call it by your own.
  23594. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23595. */
  23596. initParticles(): void;
  23597. /**
  23598. * This function does nothing. It may be overwritten to recycle a particle.
  23599. * The SPS doesn't call this function, you may have to call it by your own.
  23600. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23601. * @param particle The particle to recycle
  23602. * @returns the recycled particle
  23603. */
  23604. recycleParticle(particle: SolidParticle): SolidParticle;
  23605. /**
  23606. * Updates a particle : this function should be overwritten by the user.
  23607. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23608. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23609. * @example : just set a particle position or velocity and recycle conditions
  23610. * @param particle The particle to update
  23611. * @returns the updated particle
  23612. */
  23613. updateParticle(particle: SolidParticle): SolidParticle;
  23614. /**
  23615. * Updates a vertex of a particle : it can be overwritten by the user.
  23616. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23617. * @param particle the current particle
  23618. * @param vertex the current index of the current particle
  23619. * @param pt the index of the current vertex in the particle shape
  23620. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23621. * @example : just set a vertex particle position
  23622. * @returns the updated vertex
  23623. */
  23624. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23625. /**
  23626. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23627. * This does nothing and may be overwritten by the user.
  23628. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23629. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23630. * @param update the boolean update value actually passed to setParticles()
  23631. */
  23632. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23633. /**
  23634. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23635. * This will be passed three parameters.
  23636. * This does nothing and may be overwritten by the user.
  23637. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23638. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23639. * @param update the boolean update value actually passed to setParticles()
  23640. */
  23641. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23642. }
  23643. }
  23644. declare module BABYLON {
  23645. /**
  23646. * Represents one particle of a solid particle system.
  23647. */
  23648. export class SolidParticle {
  23649. /**
  23650. * particle global index
  23651. */
  23652. idx: number;
  23653. /**
  23654. * The color of the particle
  23655. */
  23656. color: Nullable<Color4>;
  23657. /**
  23658. * The world space position of the particle.
  23659. */
  23660. position: Vector3;
  23661. /**
  23662. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23663. */
  23664. rotation: Vector3;
  23665. /**
  23666. * The world space rotation quaternion of the particle.
  23667. */
  23668. rotationQuaternion: Nullable<Quaternion>;
  23669. /**
  23670. * The scaling of the particle.
  23671. */
  23672. scaling: Vector3;
  23673. /**
  23674. * The uvs of the particle.
  23675. */
  23676. uvs: Vector4;
  23677. /**
  23678. * The current speed of the particle.
  23679. */
  23680. velocity: Vector3;
  23681. /**
  23682. * The pivot point in the particle local space.
  23683. */
  23684. pivot: Vector3;
  23685. /**
  23686. * Must the particle be translated from its pivot point in its local space ?
  23687. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23688. * Default : false
  23689. */
  23690. translateFromPivot: boolean;
  23691. /**
  23692. * Is the particle active or not ?
  23693. */
  23694. alive: boolean;
  23695. /**
  23696. * Is the particle visible or not ?
  23697. */
  23698. isVisible: boolean;
  23699. /**
  23700. * Index of this particle in the global "positions" array (Internal use)
  23701. * @hidden
  23702. */
  23703. _pos: number;
  23704. /**
  23705. * @hidden Index of this particle in the global "indices" array (Internal use)
  23706. */
  23707. _ind: number;
  23708. /**
  23709. * @hidden ModelShape of this particle (Internal use)
  23710. */
  23711. _model: ModelShape;
  23712. /**
  23713. * ModelShape id of this particle
  23714. */
  23715. shapeId: number;
  23716. /**
  23717. * Index of the particle in its shape id (Internal use)
  23718. */
  23719. idxInShape: number;
  23720. /**
  23721. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23722. */
  23723. _modelBoundingInfo: BoundingInfo;
  23724. /**
  23725. * @hidden Particle BoundingInfo object (Internal use)
  23726. */
  23727. _boundingInfo: BoundingInfo;
  23728. /**
  23729. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23730. */
  23731. _sps: SolidParticleSystem;
  23732. /**
  23733. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23734. */
  23735. _stillInvisible: boolean;
  23736. /**
  23737. * @hidden Last computed particle rotation matrix
  23738. */
  23739. _rotationMatrix: number[];
  23740. /**
  23741. * Parent particle Id, if any.
  23742. * Default null.
  23743. */
  23744. parentId: Nullable<number>;
  23745. /**
  23746. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23747. * The possible values are :
  23748. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23749. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23750. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23751. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23752. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23753. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23754. * */
  23755. cullingStrategy: number;
  23756. /**
  23757. * @hidden Internal global position in the SPS.
  23758. */
  23759. _globalPosition: Vector3;
  23760. /**
  23761. * Creates a Solid Particle object.
  23762. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23763. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23764. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23765. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23766. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23767. * @param shapeId (integer) is the model shape identifier in the SPS.
  23768. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23769. * @param sps defines the sps it is associated to
  23770. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23771. */
  23772. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23773. /**
  23774. * Legacy support, changed scale to scaling
  23775. */
  23776. /**
  23777. * Legacy support, changed scale to scaling
  23778. */
  23779. scale: Vector3;
  23780. /**
  23781. * Legacy support, changed quaternion to rotationQuaternion
  23782. */
  23783. /**
  23784. * Legacy support, changed quaternion to rotationQuaternion
  23785. */
  23786. quaternion: Nullable<Quaternion>;
  23787. /**
  23788. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23789. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23790. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23791. * @returns true if it intersects
  23792. */
  23793. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23794. /**
  23795. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23796. * A particle is in the frustum if its bounding box intersects the frustum
  23797. * @param frustumPlanes defines the frustum to test
  23798. * @returns true if the particle is in the frustum planes
  23799. */
  23800. isInFrustum(frustumPlanes: Plane[]): boolean;
  23801. /**
  23802. * get the rotation matrix of the particle
  23803. * @hidden
  23804. */
  23805. getRotationMatrix(m: Matrix): void;
  23806. }
  23807. /**
  23808. * Represents the shape of the model used by one particle of a solid particle system.
  23809. * SPS internal tool, don't use it manually.
  23810. */
  23811. export class ModelShape {
  23812. /**
  23813. * The shape id
  23814. * @hidden
  23815. */
  23816. shapeID: number;
  23817. /**
  23818. * flat array of model positions (internal use)
  23819. * @hidden
  23820. */
  23821. _shape: Vector3[];
  23822. /**
  23823. * flat array of model UVs (internal use)
  23824. * @hidden
  23825. */
  23826. _shapeUV: number[];
  23827. /**
  23828. * length of the shape in the model indices array (internal use)
  23829. * @hidden
  23830. */
  23831. _indicesLength: number;
  23832. /**
  23833. * Custom position function (internal use)
  23834. * @hidden
  23835. */
  23836. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23837. /**
  23838. * Custom vertex function (internal use)
  23839. * @hidden
  23840. */
  23841. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23842. /**
  23843. * 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.
  23844. * SPS internal tool, don't use it manually.
  23845. * @hidden
  23846. */
  23847. 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>);
  23848. }
  23849. /**
  23850. * Represents a Depth Sorted Particle in the solid particle system.
  23851. */
  23852. export class DepthSortedParticle {
  23853. /**
  23854. * Index of the particle in the "indices" array
  23855. */
  23856. ind: number;
  23857. /**
  23858. * Length of the particle shape in the "indices" array
  23859. */
  23860. indicesLength: number;
  23861. /**
  23862. * Squared distance from the particle to the camera
  23863. */
  23864. sqDistance: number;
  23865. }
  23866. }
  23867. declare module BABYLON {
  23868. /**
  23869. * Class used to store all common mesh properties
  23870. */
  23871. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23872. /** No occlusion */
  23873. static OCCLUSION_TYPE_NONE: number;
  23874. /** Occlusion set to optimisitic */
  23875. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23876. /** Occlusion set to strict */
  23877. static OCCLUSION_TYPE_STRICT: number;
  23878. /** Use an accurante occlusion algorithm */
  23879. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23880. /** Use a conservative occlusion algorithm */
  23881. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23882. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23883. * Test order :
  23884. * Is the bounding sphere outside the frustum ?
  23885. * If not, are the bounding box vertices outside the frustum ?
  23886. * It not, then the cullable object is in the frustum.
  23887. */
  23888. static readonly CULLINGSTRATEGY_STANDARD: number;
  23889. /** Culling strategy : Bounding Sphere Only.
  23890. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23891. * It's also less accurate than the standard because some not visible objects can still be selected.
  23892. * Test : is the bounding sphere outside the frustum ?
  23893. * If not, then the cullable object is in the frustum.
  23894. */
  23895. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23896. /** Culling strategy : Optimistic Inclusion.
  23897. * This in an inclusion test first, then the standard exclusion test.
  23898. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23899. * 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.
  23900. * Anyway, it's as accurate as the standard strategy.
  23901. * Test :
  23902. * Is the cullable object bounding sphere center in the frustum ?
  23903. * If not, apply the default culling strategy.
  23904. */
  23905. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23906. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23907. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23908. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23909. * 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.
  23910. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23911. * Test :
  23912. * Is the cullable object bounding sphere center in the frustum ?
  23913. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23914. */
  23915. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23916. /**
  23917. * No billboard
  23918. */
  23919. static readonly BILLBOARDMODE_NONE: number;
  23920. /** Billboard on X axis */
  23921. static readonly BILLBOARDMODE_X: number;
  23922. /** Billboard on Y axis */
  23923. static readonly BILLBOARDMODE_Y: number;
  23924. /** Billboard on Z axis */
  23925. static readonly BILLBOARDMODE_Z: number;
  23926. /** Billboard on all axes */
  23927. static readonly BILLBOARDMODE_ALL: number;
  23928. private _facetData;
  23929. /**
  23930. * The culling strategy to use to check whether the mesh must be rendered or not.
  23931. * This value can be changed at any time and will be used on the next render mesh selection.
  23932. * The possible values are :
  23933. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23934. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23936. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23937. * Please read each static variable documentation to get details about the culling process.
  23938. * */
  23939. cullingStrategy: number;
  23940. /**
  23941. * Gets the number of facets in the mesh
  23942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23943. */
  23944. readonly facetNb: number;
  23945. /**
  23946. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23948. */
  23949. partitioningSubdivisions: number;
  23950. /**
  23951. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23952. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23954. */
  23955. partitioningBBoxRatio: number;
  23956. /**
  23957. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23958. * Works only for updatable meshes.
  23959. * Doesn't work with multi-materials
  23960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23961. */
  23962. mustDepthSortFacets: boolean;
  23963. /**
  23964. * The location (Vector3) where the facet depth sort must be computed from.
  23965. * By default, the active camera position.
  23966. * Used only when facet depth sort is enabled
  23967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23968. */
  23969. facetDepthSortFrom: Vector3;
  23970. /**
  23971. * gets a boolean indicating if facetData is enabled
  23972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23973. */
  23974. readonly isFacetDataEnabled: boolean;
  23975. /** @hidden */
  23976. _updateNonUniformScalingState(value: boolean): boolean;
  23977. /**
  23978. * An event triggered when this mesh collides with another one
  23979. */
  23980. onCollideObservable: Observable<AbstractMesh>;
  23981. private _onCollideObserver;
  23982. /** Set a function to call when this mesh collides with another one */
  23983. onCollide: () => void;
  23984. /**
  23985. * An event triggered when the collision's position changes
  23986. */
  23987. onCollisionPositionChangeObservable: Observable<Vector3>;
  23988. private _onCollisionPositionChangeObserver;
  23989. /** Set a function to call when the collision's position changes */
  23990. onCollisionPositionChange: () => void;
  23991. /**
  23992. * An event triggered when material is changed
  23993. */
  23994. onMaterialChangedObservable: Observable<AbstractMesh>;
  23995. /**
  23996. * Gets or sets the orientation for POV movement & rotation
  23997. */
  23998. definedFacingForward: boolean;
  23999. /** @hidden */
  24000. _occlusionQuery: Nullable<WebGLQuery>;
  24001. private _visibility;
  24002. /**
  24003. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24004. */
  24005. /**
  24006. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24007. */
  24008. visibility: number;
  24009. /** Gets or sets the alpha index used to sort transparent meshes
  24010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24011. */
  24012. alphaIndex: number;
  24013. /**
  24014. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24015. */
  24016. isVisible: boolean;
  24017. /**
  24018. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24019. */
  24020. isPickable: boolean;
  24021. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24022. showSubMeshesBoundingBox: boolean;
  24023. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24025. */
  24026. isBlocker: boolean;
  24027. /**
  24028. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24029. */
  24030. enablePointerMoveEvents: boolean;
  24031. /**
  24032. * Specifies the rendering group id for this mesh (0 by default)
  24033. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24034. */
  24035. renderingGroupId: number;
  24036. private _material;
  24037. /** Gets or sets current material */
  24038. material: Nullable<Material>;
  24039. private _receiveShadows;
  24040. /**
  24041. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24042. * @see http://doc.babylonjs.com/babylon101/shadows
  24043. */
  24044. receiveShadows: boolean;
  24045. /** Defines color to use when rendering outline */
  24046. outlineColor: Color3;
  24047. /** Define width to use when rendering outline */
  24048. outlineWidth: number;
  24049. /** Defines color to use when rendering overlay */
  24050. overlayColor: Color3;
  24051. /** Defines alpha to use when rendering overlay */
  24052. overlayAlpha: number;
  24053. private _hasVertexAlpha;
  24054. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24055. hasVertexAlpha: boolean;
  24056. private _useVertexColors;
  24057. /** 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) */
  24058. useVertexColors: boolean;
  24059. private _computeBonesUsingShaders;
  24060. /**
  24061. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24062. */
  24063. computeBonesUsingShaders: boolean;
  24064. private _numBoneInfluencers;
  24065. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24066. numBoneInfluencers: number;
  24067. private _applyFog;
  24068. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24069. applyFog: boolean;
  24070. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24071. useOctreeForRenderingSelection: boolean;
  24072. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24073. useOctreeForPicking: boolean;
  24074. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24075. useOctreeForCollisions: boolean;
  24076. private _layerMask;
  24077. /**
  24078. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24079. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24080. */
  24081. layerMask: number;
  24082. /**
  24083. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24084. */
  24085. alwaysSelectAsActiveMesh: boolean;
  24086. /**
  24087. * Gets or sets the current action manager
  24088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24089. */
  24090. actionManager: Nullable<AbstractActionManager>;
  24091. private _checkCollisions;
  24092. private _collisionMask;
  24093. private _collisionGroup;
  24094. /**
  24095. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24097. */
  24098. ellipsoid: Vector3;
  24099. /**
  24100. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24102. */
  24103. ellipsoidOffset: Vector3;
  24104. private _collider;
  24105. private _oldPositionForCollisions;
  24106. private _diffPositionForCollisions;
  24107. /**
  24108. * Gets or sets a collision mask used to mask collisions (default is -1).
  24109. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24110. */
  24111. collisionMask: number;
  24112. /**
  24113. * Gets or sets the current collision group mask (-1 by default).
  24114. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24115. */
  24116. collisionGroup: number;
  24117. /**
  24118. * Defines edge width used when edgesRenderer is enabled
  24119. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24120. */
  24121. edgesWidth: number;
  24122. /**
  24123. * Defines edge color used when edgesRenderer is enabled
  24124. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24125. */
  24126. edgesColor: Color4;
  24127. /** @hidden */
  24128. _edgesRenderer: Nullable<IEdgesRenderer>;
  24129. /** @hidden */
  24130. _masterMesh: Nullable<AbstractMesh>;
  24131. /** @hidden */
  24132. _boundingInfo: Nullable<BoundingInfo>;
  24133. /** @hidden */
  24134. _renderId: number;
  24135. /**
  24136. * Gets or sets the list of subMeshes
  24137. * @see http://doc.babylonjs.com/how_to/multi_materials
  24138. */
  24139. subMeshes: SubMesh[];
  24140. /** @hidden */
  24141. _intersectionsInProgress: AbstractMesh[];
  24142. /** @hidden */
  24143. _unIndexed: boolean;
  24144. /** @hidden */
  24145. _lightSources: Light[];
  24146. /** @hidden */
  24147. readonly _positions: Nullable<Vector3[]>;
  24148. /** @hidden */
  24149. _waitingActions: any;
  24150. /** @hidden */
  24151. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24152. private _skeleton;
  24153. /** @hidden */
  24154. _bonesTransformMatrices: Nullable<Float32Array>;
  24155. /**
  24156. * Gets or sets a skeleton to apply skining transformations
  24157. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24158. */
  24159. skeleton: Nullable<Skeleton>;
  24160. /**
  24161. * An event triggered when the mesh is rebuilt.
  24162. */
  24163. onRebuildObservable: Observable<AbstractMesh>;
  24164. /**
  24165. * Creates a new AbstractMesh
  24166. * @param name defines the name of the mesh
  24167. * @param scene defines the hosting scene
  24168. */
  24169. constructor(name: string, scene?: Nullable<Scene>);
  24170. /**
  24171. * Returns the string "AbstractMesh"
  24172. * @returns "AbstractMesh"
  24173. */
  24174. getClassName(): string;
  24175. /**
  24176. * Gets a string representation of the current mesh
  24177. * @param fullDetails defines a boolean indicating if full details must be included
  24178. * @returns a string representation of the current mesh
  24179. */
  24180. toString(fullDetails?: boolean): string;
  24181. /** @hidden */
  24182. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24183. /** @hidden */
  24184. _rebuild(): void;
  24185. /** @hidden */
  24186. _resyncLightSources(): void;
  24187. /** @hidden */
  24188. _resyncLighSource(light: Light): void;
  24189. /** @hidden */
  24190. _unBindEffect(): void;
  24191. /** @hidden */
  24192. _removeLightSource(light: Light): void;
  24193. private _markSubMeshesAsDirty;
  24194. /** @hidden */
  24195. _markSubMeshesAsLightDirty(): void;
  24196. /** @hidden */
  24197. _markSubMeshesAsAttributesDirty(): void;
  24198. /** @hidden */
  24199. _markSubMeshesAsMiscDirty(): void;
  24200. /**
  24201. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24202. */
  24203. scaling: Vector3;
  24204. /**
  24205. * Returns true if the mesh is blocked. Implemented by child classes
  24206. */
  24207. readonly isBlocked: boolean;
  24208. /**
  24209. * Returns the mesh itself by default. Implemented by child classes
  24210. * @param camera defines the camera to use to pick the right LOD level
  24211. * @returns the currentAbstractMesh
  24212. */
  24213. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24214. /**
  24215. * Returns 0 by default. Implemented by child classes
  24216. * @returns an integer
  24217. */
  24218. getTotalVertices(): number;
  24219. /**
  24220. * Returns a positive integer : the total number of indices in this mesh geometry.
  24221. * @returns the numner of indices or zero if the mesh has no geometry.
  24222. */
  24223. getTotalIndices(): number;
  24224. /**
  24225. * Returns null by default. Implemented by child classes
  24226. * @returns null
  24227. */
  24228. getIndices(): Nullable<IndicesArray>;
  24229. /**
  24230. * Returns the array of the requested vertex data kind. Implemented by child classes
  24231. * @param kind defines the vertex data kind to use
  24232. * @returns null
  24233. */
  24234. getVerticesData(kind: string): Nullable<FloatArray>;
  24235. /**
  24236. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24237. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24238. * Note that a new underlying VertexBuffer object is created each call.
  24239. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24240. * @param kind defines vertex data kind:
  24241. * * VertexBuffer.PositionKind
  24242. * * VertexBuffer.UVKind
  24243. * * VertexBuffer.UV2Kind
  24244. * * VertexBuffer.UV3Kind
  24245. * * VertexBuffer.UV4Kind
  24246. * * VertexBuffer.UV5Kind
  24247. * * VertexBuffer.UV6Kind
  24248. * * VertexBuffer.ColorKind
  24249. * * VertexBuffer.MatricesIndicesKind
  24250. * * VertexBuffer.MatricesIndicesExtraKind
  24251. * * VertexBuffer.MatricesWeightsKind
  24252. * * VertexBuffer.MatricesWeightsExtraKind
  24253. * @param data defines the data source
  24254. * @param updatable defines if the data must be flagged as updatable (or static)
  24255. * @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
  24256. * @returns the current mesh
  24257. */
  24258. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24259. /**
  24260. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24261. * If the mesh has no geometry, it is simply returned as it is.
  24262. * @param kind defines vertex data kind:
  24263. * * VertexBuffer.PositionKind
  24264. * * VertexBuffer.UVKind
  24265. * * VertexBuffer.UV2Kind
  24266. * * VertexBuffer.UV3Kind
  24267. * * VertexBuffer.UV4Kind
  24268. * * VertexBuffer.UV5Kind
  24269. * * VertexBuffer.UV6Kind
  24270. * * VertexBuffer.ColorKind
  24271. * * VertexBuffer.MatricesIndicesKind
  24272. * * VertexBuffer.MatricesIndicesExtraKind
  24273. * * VertexBuffer.MatricesWeightsKind
  24274. * * VertexBuffer.MatricesWeightsExtraKind
  24275. * @param data defines the data source
  24276. * @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
  24277. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24278. * @returns the current mesh
  24279. */
  24280. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24281. /**
  24282. * Sets the mesh indices,
  24283. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24284. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24285. * @param totalVertices Defines the total number of vertices
  24286. * @returns the current mesh
  24287. */
  24288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24289. /**
  24290. * Gets a boolean indicating if specific vertex data is present
  24291. * @param kind defines the vertex data kind to use
  24292. * @returns true is data kind is present
  24293. */
  24294. isVerticesDataPresent(kind: string): boolean;
  24295. /**
  24296. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24297. * @returns a BoundingInfo
  24298. */
  24299. getBoundingInfo(): BoundingInfo;
  24300. /**
  24301. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24302. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24303. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24304. * @returns the current mesh
  24305. */
  24306. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24307. /**
  24308. * Overwrite the current bounding info
  24309. * @param boundingInfo defines the new bounding info
  24310. * @returns the current mesh
  24311. */
  24312. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24313. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24314. readonly useBones: boolean;
  24315. /** @hidden */
  24316. _preActivate(): void;
  24317. /** @hidden */
  24318. _preActivateForIntermediateRendering(renderId: number): void;
  24319. /** @hidden */
  24320. _activate(renderId: number): void;
  24321. /**
  24322. * Gets the current world matrix
  24323. * @returns a Matrix
  24324. */
  24325. getWorldMatrix(): Matrix;
  24326. /** @hidden */
  24327. _getWorldMatrixDeterminant(): number;
  24328. /**
  24329. * Perform relative position change from the point of view of behind the front of the mesh.
  24330. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24331. * Supports definition of mesh facing forward or backward
  24332. * @param amountRight defines the distance on the right axis
  24333. * @param amountUp defines the distance on the up axis
  24334. * @param amountForward defines the distance on the forward axis
  24335. * @returns the current mesh
  24336. */
  24337. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24338. /**
  24339. * Calculate relative position change from the point of view of behind the front of the mesh.
  24340. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24341. * Supports definition of mesh facing forward or backward
  24342. * @param amountRight defines the distance on the right axis
  24343. * @param amountUp defines the distance on the up axis
  24344. * @param amountForward defines the distance on the forward axis
  24345. * @returns the new displacement vector
  24346. */
  24347. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24348. /**
  24349. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24350. * Supports definition of mesh facing forward or backward
  24351. * @param flipBack defines the flip
  24352. * @param twirlClockwise defines the twirl
  24353. * @param tiltRight defines the tilt
  24354. * @returns the current mesh
  24355. */
  24356. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24357. /**
  24358. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24359. * Supports definition of mesh facing forward or backward.
  24360. * @param flipBack defines the flip
  24361. * @param twirlClockwise defines the twirl
  24362. * @param tiltRight defines the tilt
  24363. * @returns the new rotation vector
  24364. */
  24365. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24366. /**
  24367. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24368. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24369. * @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
  24370. * @returns the new bounding vectors
  24371. */
  24372. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24373. min: Vector3;
  24374. max: Vector3;
  24375. };
  24376. /**
  24377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24378. * This means the mesh underlying bounding box and sphere are recomputed.
  24379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24380. * @returns the current mesh
  24381. */
  24382. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24383. /** @hidden */
  24384. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24385. /** @hidden */
  24386. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24387. /** @hidden */
  24388. _updateBoundingInfo(): AbstractMesh;
  24389. /** @hidden */
  24390. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24391. /** @hidden */
  24392. protected _afterComputeWorldMatrix(): void;
  24393. /** @hidden */
  24394. readonly _effectiveMesh: AbstractMesh;
  24395. /**
  24396. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24397. * A mesh is in the frustum if its bounding box intersects the frustum
  24398. * @param frustumPlanes defines the frustum to test
  24399. * @returns true if the mesh is in the frustum planes
  24400. */
  24401. isInFrustum(frustumPlanes: Plane[]): boolean;
  24402. /**
  24403. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24404. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24405. * @param frustumPlanes defines the frustum to test
  24406. * @returns true if the mesh is completely in the frustum planes
  24407. */
  24408. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24409. /**
  24410. * True if the mesh intersects another mesh or a SolidParticle object
  24411. * @param mesh defines a target mesh or SolidParticle to test
  24412. * @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)
  24413. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24414. * @returns true if there is an intersection
  24415. */
  24416. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24417. /**
  24418. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24419. * @param point defines the point to test
  24420. * @returns true if there is an intersection
  24421. */
  24422. intersectsPoint(point: Vector3): boolean;
  24423. /**
  24424. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24426. */
  24427. checkCollisions: boolean;
  24428. /**
  24429. * Gets Collider object used to compute collisions (not physics)
  24430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24431. */
  24432. readonly collider: Collider;
  24433. /**
  24434. * Move the mesh using collision engine
  24435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24436. * @param displacement defines the requested displacement vector
  24437. * @returns the current mesh
  24438. */
  24439. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24440. private _onCollisionPositionChange;
  24441. /** @hidden */
  24442. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24443. /** @hidden */
  24444. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24445. /** @hidden */
  24446. _checkCollision(collider: Collider): AbstractMesh;
  24447. /** @hidden */
  24448. _generatePointsArray(): boolean;
  24449. /**
  24450. * Checks if the passed Ray intersects with the mesh
  24451. * @param ray defines the ray to use
  24452. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24453. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24454. * @returns the picking info
  24455. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24456. */
  24457. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24458. /**
  24459. * Clones the current mesh
  24460. * @param name defines the mesh name
  24461. * @param newParent defines the new mesh parent
  24462. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24463. * @returns the new mesh
  24464. */
  24465. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24466. /**
  24467. * Disposes all the submeshes of the current meshnp
  24468. * @returns the current mesh
  24469. */
  24470. releaseSubMeshes(): AbstractMesh;
  24471. /**
  24472. * Releases resources associated with this abstract mesh.
  24473. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24474. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24475. */
  24476. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24477. /**
  24478. * Adds the passed mesh as a child to the current mesh
  24479. * @param mesh defines the child mesh
  24480. * @returns the current mesh
  24481. */
  24482. addChild(mesh: AbstractMesh): AbstractMesh;
  24483. /**
  24484. * Removes the passed mesh from the current mesh children list
  24485. * @param mesh defines the child mesh
  24486. * @returns the current mesh
  24487. */
  24488. removeChild(mesh: AbstractMesh): AbstractMesh;
  24489. /** @hidden */
  24490. private _initFacetData;
  24491. /**
  24492. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24493. * This method can be called within the render loop.
  24494. * 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
  24495. * @returns the current mesh
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24497. */
  24498. updateFacetData(): AbstractMesh;
  24499. /**
  24500. * Returns the facetLocalNormals array.
  24501. * The normals are expressed in the mesh local spac
  24502. * @returns an array of Vector3
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getFacetLocalNormals(): Vector3[];
  24506. /**
  24507. * Returns the facetLocalPositions array.
  24508. * The facet positions are expressed in the mesh local space
  24509. * @returns an array of Vector3
  24510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24511. */
  24512. getFacetLocalPositions(): Vector3[];
  24513. /**
  24514. * Returns the facetLocalPartioning array
  24515. * @returns an array of array of numbers
  24516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24517. */
  24518. getFacetLocalPartitioning(): number[][];
  24519. /**
  24520. * Returns the i-th facet position in the world system.
  24521. * This method allocates a new Vector3 per call
  24522. * @param i defines the facet index
  24523. * @returns a new Vector3
  24524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24525. */
  24526. getFacetPosition(i: number): Vector3;
  24527. /**
  24528. * Sets the reference Vector3 with the i-th facet position in the world system
  24529. * @param i defines the facet index
  24530. * @param ref defines the target vector
  24531. * @returns the current mesh
  24532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24533. */
  24534. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24535. /**
  24536. * Returns the i-th facet normal in the world system.
  24537. * This method allocates a new Vector3 per call
  24538. * @param i defines the facet index
  24539. * @returns a new Vector3
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24541. */
  24542. getFacetNormal(i: number): Vector3;
  24543. /**
  24544. * Sets the reference Vector3 with the i-th facet normal in the world system
  24545. * @param i defines the facet index
  24546. * @param ref defines the target vector
  24547. * @returns the current mesh
  24548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24549. */
  24550. getFacetNormalToRef(i: number, ref: Vector3): this;
  24551. /**
  24552. * 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)
  24553. * @param x defines x coordinate
  24554. * @param y defines y coordinate
  24555. * @param z defines z coordinate
  24556. * @returns the array of facet indexes
  24557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24558. */
  24559. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24560. /**
  24561. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24562. * @param projected sets as the (x,y,z) world projection on the facet
  24563. * @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
  24564. * @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
  24565. * @param x defines x coordinate
  24566. * @param y defines y coordinate
  24567. * @param z defines z coordinate
  24568. * @returns the face index if found (or null instead)
  24569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24570. */
  24571. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24572. /**
  24573. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24574. * @param projected sets as the (x,y,z) local projection on the facet
  24575. * @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
  24576. * @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
  24577. * @param x defines x coordinate
  24578. * @param y defines y coordinate
  24579. * @param z defines z coordinate
  24580. * @returns the face index if found (or null instead)
  24581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24582. */
  24583. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24584. /**
  24585. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24586. * @returns the parameters
  24587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24588. */
  24589. getFacetDataParameters(): any;
  24590. /**
  24591. * Disables the feature FacetData and frees the related memory
  24592. * @returns the current mesh
  24593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24594. */
  24595. disableFacetData(): AbstractMesh;
  24596. /**
  24597. * Updates the AbstractMesh indices array
  24598. * @param indices defines the data source
  24599. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24600. * @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)
  24601. * @returns the current mesh
  24602. */
  24603. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24604. /**
  24605. * Creates new normals data for the mesh
  24606. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24607. * @returns the current mesh
  24608. */
  24609. createNormals(updatable: boolean): AbstractMesh;
  24610. /**
  24611. * Align the mesh with a normal
  24612. * @param normal defines the normal to use
  24613. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24614. * @returns the current mesh
  24615. */
  24616. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24617. /** @hidden */
  24618. _checkOcclusionQuery(): boolean;
  24619. }
  24620. }
  24621. declare module BABYLON {
  24622. /**
  24623. * Interface used to define ActionEvent
  24624. */
  24625. export interface IActionEvent {
  24626. /** The mesh or sprite that triggered the action */
  24627. source: any;
  24628. /** The X mouse cursor position at the time of the event */
  24629. pointerX: number;
  24630. /** The Y mouse cursor position at the time of the event */
  24631. pointerY: number;
  24632. /** The mesh that is currently pointed at (can be null) */
  24633. meshUnderPointer: Nullable<AbstractMesh>;
  24634. /** the original (browser) event that triggered the ActionEvent */
  24635. sourceEvent?: any;
  24636. /** additional data for the event */
  24637. additionalData?: any;
  24638. }
  24639. /**
  24640. * ActionEvent is the event being sent when an action is triggered.
  24641. */
  24642. export class ActionEvent implements IActionEvent {
  24643. /** The mesh or sprite that triggered the action */
  24644. source: any;
  24645. /** The X mouse cursor position at the time of the event */
  24646. pointerX: number;
  24647. /** The Y mouse cursor position at the time of the event */
  24648. pointerY: number;
  24649. /** The mesh that is currently pointed at (can be null) */
  24650. meshUnderPointer: Nullable<AbstractMesh>;
  24651. /** the original (browser) event that triggered the ActionEvent */
  24652. sourceEvent?: any;
  24653. /** additional data for the event */
  24654. additionalData?: any;
  24655. /**
  24656. * Creates a new ActionEvent
  24657. * @param source The mesh or sprite that triggered the action
  24658. * @param pointerX The X mouse cursor position at the time of the event
  24659. * @param pointerY The Y mouse cursor position at the time of the event
  24660. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24661. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24662. * @param additionalData additional data for the event
  24663. */
  24664. constructor(
  24665. /** The mesh or sprite that triggered the action */
  24666. source: any,
  24667. /** The X mouse cursor position at the time of the event */
  24668. pointerX: number,
  24669. /** The Y mouse cursor position at the time of the event */
  24670. pointerY: number,
  24671. /** The mesh that is currently pointed at (can be null) */
  24672. meshUnderPointer: Nullable<AbstractMesh>,
  24673. /** the original (browser) event that triggered the ActionEvent */
  24674. sourceEvent?: any,
  24675. /** additional data for the event */
  24676. additionalData?: any);
  24677. /**
  24678. * Helper function to auto-create an ActionEvent from a source mesh.
  24679. * @param source The source mesh that triggered the event
  24680. * @param evt The original (browser) event
  24681. * @param additionalData additional data for the event
  24682. * @returns the new ActionEvent
  24683. */
  24684. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24685. /**
  24686. * Helper function to auto-create an ActionEvent from a source sprite
  24687. * @param source The source sprite that triggered the event
  24688. * @param scene Scene associated with the sprite
  24689. * @param evt The original (browser) event
  24690. * @param additionalData additional data for the event
  24691. * @returns the new ActionEvent
  24692. */
  24693. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24694. /**
  24695. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24696. * @param scene the scene where the event occurred
  24697. * @param evt The original (browser) event
  24698. * @returns the new ActionEvent
  24699. */
  24700. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24701. /**
  24702. * Helper function to auto-create an ActionEvent from a primitive
  24703. * @param prim defines the target primitive
  24704. * @param pointerPos defines the pointer position
  24705. * @param evt The original (browser) event
  24706. * @param additionalData additional data for the event
  24707. * @returns the new ActionEvent
  24708. */
  24709. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24710. }
  24711. }
  24712. declare module BABYLON {
  24713. /**
  24714. * Abstract class used to decouple action Manager from scene and meshes.
  24715. * Do not instantiate.
  24716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24717. */
  24718. export abstract class AbstractActionManager implements IDisposable {
  24719. /** Gets the list of active triggers */
  24720. static Triggers: {
  24721. [key: string]: number;
  24722. };
  24723. /** Gets the cursor to use when hovering items */
  24724. hoverCursor: string;
  24725. /** Gets the list of actions */
  24726. actions: IAction[];
  24727. /**
  24728. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24729. */
  24730. isRecursive: boolean;
  24731. /**
  24732. * Releases all associated resources
  24733. */
  24734. abstract dispose(): void;
  24735. /**
  24736. * Does this action manager has pointer triggers
  24737. */
  24738. abstract readonly hasPointerTriggers: boolean;
  24739. /**
  24740. * Does this action manager has pick triggers
  24741. */
  24742. abstract readonly hasPickTriggers: boolean;
  24743. /**
  24744. * Process a specific trigger
  24745. * @param trigger defines the trigger to process
  24746. * @param evt defines the event details to be processed
  24747. */
  24748. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24749. /**
  24750. * Does this action manager handles actions of any of the given triggers
  24751. * @param triggers defines the triggers to be tested
  24752. * @return a boolean indicating whether one (or more) of the triggers is handled
  24753. */
  24754. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24755. /**
  24756. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24757. * speed.
  24758. * @param triggerA defines the trigger to be tested
  24759. * @param triggerB defines the trigger to be tested
  24760. * @return a boolean indicating whether one (or more) of the triggers is handled
  24761. */
  24762. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24763. /**
  24764. * Does this action manager handles actions of a given trigger
  24765. * @param trigger defines the trigger to be tested
  24766. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24767. * @return whether the trigger is handled
  24768. */
  24769. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24770. /**
  24771. * Serialize this manager to a JSON object
  24772. * @param name defines the property name to store this manager
  24773. * @returns a JSON representation of this manager
  24774. */
  24775. abstract serialize(name: string): any;
  24776. /**
  24777. * Registers an action to this action manager
  24778. * @param action defines the action to be registered
  24779. * @return the action amended (prepared) after registration
  24780. */
  24781. abstract registerAction(action: IAction): Nullable<IAction>;
  24782. /**
  24783. * Unregisters an action to this action manager
  24784. * @param action defines the action to be unregistered
  24785. * @return a boolean indicating whether the action has been unregistered
  24786. */
  24787. abstract unregisterAction(action: IAction): Boolean;
  24788. /**
  24789. * Does exist one action manager with at least one trigger
  24790. **/
  24791. static readonly HasTriggers: boolean;
  24792. /**
  24793. * Does exist one action manager with at least one pick trigger
  24794. **/
  24795. static readonly HasPickTriggers: boolean;
  24796. /**
  24797. * Does exist one action manager that handles actions of a given trigger
  24798. * @param trigger defines the trigger to be tested
  24799. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24800. **/
  24801. static HasSpecificTrigger(trigger: number): boolean;
  24802. }
  24803. }
  24804. declare module BABYLON {
  24805. /**
  24806. * Defines how a node can be built from a string name.
  24807. */
  24808. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24809. /**
  24810. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24811. */
  24812. export class Node implements IBehaviorAware<Node> {
  24813. /** @hidden */
  24814. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24815. private static _NodeConstructors;
  24816. /**
  24817. * Add a new node constructor
  24818. * @param type defines the type name of the node to construct
  24819. * @param constructorFunc defines the constructor function
  24820. */
  24821. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24822. /**
  24823. * Returns a node constructor based on type name
  24824. * @param type defines the type name
  24825. * @param name defines the new node name
  24826. * @param scene defines the hosting scene
  24827. * @param options defines optional options to transmit to constructors
  24828. * @returns the new constructor or null
  24829. */
  24830. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24831. /**
  24832. * Gets or sets the name of the node
  24833. */
  24834. name: string;
  24835. /**
  24836. * Gets or sets the id of the node
  24837. */
  24838. id: string;
  24839. /**
  24840. * Gets or sets the unique id of the node
  24841. */
  24842. uniqueId: number;
  24843. /**
  24844. * Gets or sets a string used to store user defined state for the node
  24845. */
  24846. state: string;
  24847. /**
  24848. * Gets or sets an object used to store user defined information for the node
  24849. */
  24850. metadata: any;
  24851. /**
  24852. * For internal use only. Please do not use.
  24853. */
  24854. reservedDataStore: any;
  24855. /**
  24856. * List of inspectable custom properties (used by the Inspector)
  24857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24858. */
  24859. inspectableCustomProperties: IInspectable[];
  24860. /**
  24861. * Gets or sets a boolean used to define if the node must be serialized
  24862. */
  24863. doNotSerialize: boolean;
  24864. /** @hidden */
  24865. _isDisposed: boolean;
  24866. /**
  24867. * Gets a list of Animations associated with the node
  24868. */
  24869. animations: Animation[];
  24870. protected _ranges: {
  24871. [name: string]: Nullable<AnimationRange>;
  24872. };
  24873. /**
  24874. * Callback raised when the node is ready to be used
  24875. */
  24876. onReady: (node: Node) => void;
  24877. private _isEnabled;
  24878. private _isParentEnabled;
  24879. private _isReady;
  24880. /** @hidden */
  24881. _currentRenderId: number;
  24882. private _parentUpdateId;
  24883. protected _childUpdateId: number;
  24884. /** @hidden */
  24885. _waitingParentId: Nullable<string>;
  24886. /** @hidden */
  24887. _scene: Scene;
  24888. /** @hidden */
  24889. _cache: any;
  24890. private _parentNode;
  24891. private _children;
  24892. /** @hidden */
  24893. _worldMatrix: Matrix;
  24894. /** @hidden */
  24895. _worldMatrixDeterminant: number;
  24896. /** @hidden */
  24897. private _sceneRootNodesIndex;
  24898. /**
  24899. * Gets a boolean indicating if the node has been disposed
  24900. * @returns true if the node was disposed
  24901. */
  24902. isDisposed(): boolean;
  24903. /**
  24904. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24905. * @see https://doc.babylonjs.com/how_to/parenting
  24906. */
  24907. parent: Nullable<Node>;
  24908. private addToSceneRootNodes;
  24909. private removeFromSceneRootNodes;
  24910. private _animationPropertiesOverride;
  24911. /**
  24912. * Gets or sets the animation properties override
  24913. */
  24914. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24915. /**
  24916. * Gets a string idenfifying the name of the class
  24917. * @returns "Node" string
  24918. */
  24919. getClassName(): string;
  24920. /** @hidden */
  24921. readonly _isNode: boolean;
  24922. /**
  24923. * An event triggered when the mesh is disposed
  24924. */
  24925. onDisposeObservable: Observable<Node>;
  24926. private _onDisposeObserver;
  24927. /**
  24928. * Sets a callback that will be raised when the node will be disposed
  24929. */
  24930. onDispose: () => void;
  24931. /**
  24932. * Creates a new Node
  24933. * @param name the name and id to be given to this node
  24934. * @param scene the scene this node will be added to
  24935. * @param addToRootNodes the node will be added to scene.rootNodes
  24936. */
  24937. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24938. /**
  24939. * Gets the scene of the node
  24940. * @returns a scene
  24941. */
  24942. getScene(): Scene;
  24943. /**
  24944. * Gets the engine of the node
  24945. * @returns a Engine
  24946. */
  24947. getEngine(): Engine;
  24948. private _behaviors;
  24949. /**
  24950. * Attach a behavior to the node
  24951. * @see http://doc.babylonjs.com/features/behaviour
  24952. * @param behavior defines the behavior to attach
  24953. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24954. * @returns the current Node
  24955. */
  24956. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24957. /**
  24958. * Remove an attached behavior
  24959. * @see http://doc.babylonjs.com/features/behaviour
  24960. * @param behavior defines the behavior to attach
  24961. * @returns the current Node
  24962. */
  24963. removeBehavior(behavior: Behavior<Node>): Node;
  24964. /**
  24965. * Gets the list of attached behaviors
  24966. * @see http://doc.babylonjs.com/features/behaviour
  24967. */
  24968. readonly behaviors: Behavior<Node>[];
  24969. /**
  24970. * Gets an attached behavior by name
  24971. * @param name defines the name of the behavior to look for
  24972. * @see http://doc.babylonjs.com/features/behaviour
  24973. * @returns null if behavior was not found else the requested behavior
  24974. */
  24975. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24976. /**
  24977. * Returns the latest update of the World matrix
  24978. * @returns a Matrix
  24979. */
  24980. getWorldMatrix(): Matrix;
  24981. /** @hidden */
  24982. _getWorldMatrixDeterminant(): number;
  24983. /**
  24984. * Returns directly the latest state of the mesh World matrix.
  24985. * A Matrix is returned.
  24986. */
  24987. readonly worldMatrixFromCache: Matrix;
  24988. /** @hidden */
  24989. _initCache(): void;
  24990. /** @hidden */
  24991. updateCache(force?: boolean): void;
  24992. /** @hidden */
  24993. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24994. /** @hidden */
  24995. _updateCache(ignoreParentClass?: boolean): void;
  24996. /** @hidden */
  24997. _isSynchronized(): boolean;
  24998. /** @hidden */
  24999. _markSyncedWithParent(): void;
  25000. /** @hidden */
  25001. isSynchronizedWithParent(): boolean;
  25002. /** @hidden */
  25003. isSynchronized(): boolean;
  25004. /**
  25005. * Is this node ready to be used/rendered
  25006. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25007. * @return true if the node is ready
  25008. */
  25009. isReady(completeCheck?: boolean): boolean;
  25010. /**
  25011. * Is this node enabled?
  25012. * 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
  25013. * @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
  25014. * @return whether this node (and its parent) is enabled
  25015. */
  25016. isEnabled(checkAncestors?: boolean): boolean;
  25017. /** @hidden */
  25018. protected _syncParentEnabledState(): void;
  25019. /**
  25020. * Set the enabled state of this node
  25021. * @param value defines the new enabled state
  25022. */
  25023. setEnabled(value: boolean): void;
  25024. /**
  25025. * Is this node a descendant of the given node?
  25026. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25027. * @param ancestor defines the parent node to inspect
  25028. * @returns a boolean indicating if this node is a descendant of the given node
  25029. */
  25030. isDescendantOf(ancestor: Node): boolean;
  25031. /** @hidden */
  25032. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25033. /**
  25034. * Will return all nodes that have this node as ascendant
  25035. * @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
  25036. * @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
  25037. * @return all children nodes of all types
  25038. */
  25039. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25040. /**
  25041. * Get all child-meshes of this node
  25042. * @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)
  25043. * @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
  25044. * @returns an array of AbstractMesh
  25045. */
  25046. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25047. /**
  25048. * Get all direct children of this node
  25049. * @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
  25050. * @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)
  25051. * @returns an array of Node
  25052. */
  25053. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25054. /** @hidden */
  25055. _setReady(state: boolean): void;
  25056. /**
  25057. * Get an animation by name
  25058. * @param name defines the name of the animation to look for
  25059. * @returns null if not found else the requested animation
  25060. */
  25061. getAnimationByName(name: string): Nullable<Animation>;
  25062. /**
  25063. * Creates an animation range for this node
  25064. * @param name defines the name of the range
  25065. * @param from defines the starting key
  25066. * @param to defines the end key
  25067. */
  25068. createAnimationRange(name: string, from: number, to: number): void;
  25069. /**
  25070. * Delete a specific animation range
  25071. * @param name defines the name of the range to delete
  25072. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25073. */
  25074. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25075. /**
  25076. * Get an animation range by name
  25077. * @param name defines the name of the animation range to look for
  25078. * @returns null if not found else the requested animation range
  25079. */
  25080. getAnimationRange(name: string): Nullable<AnimationRange>;
  25081. /**
  25082. * Gets the list of all animation ranges defined on this node
  25083. * @returns an array
  25084. */
  25085. getAnimationRanges(): Nullable<AnimationRange>[];
  25086. /**
  25087. * Will start the animation sequence
  25088. * @param name defines the range frames for animation sequence
  25089. * @param loop defines if the animation should loop (false by default)
  25090. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25091. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25092. * @returns the object created for this animation. If range does not exist, it will return null
  25093. */
  25094. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25095. /**
  25096. * Serialize animation ranges into a JSON compatible object
  25097. * @returns serialization object
  25098. */
  25099. serializeAnimationRanges(): any;
  25100. /**
  25101. * Computes the world matrix of the node
  25102. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25103. * @returns the world matrix
  25104. */
  25105. computeWorldMatrix(force?: boolean): Matrix;
  25106. /**
  25107. * Releases resources associated with this node.
  25108. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25109. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25110. */
  25111. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25112. /**
  25113. * Parse animation range data from a serialization object and store them into a given node
  25114. * @param node defines where to store the animation ranges
  25115. * @param parsedNode defines the serialization object to read data from
  25116. * @param scene defines the hosting scene
  25117. */
  25118. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25119. }
  25120. }
  25121. declare module BABYLON {
  25122. /**
  25123. * Class used to store any kind of animation
  25124. */
  25125. export class Animation {
  25126. /**Name of the animation */
  25127. name: string;
  25128. /**Property to animate */
  25129. targetProperty: string;
  25130. /**The frames per second of the animation */
  25131. framePerSecond: number;
  25132. /**The data type of the animation */
  25133. dataType: number;
  25134. /**The loop mode of the animation */
  25135. loopMode?: number | undefined;
  25136. /**Specifies if blending should be enabled */
  25137. enableBlending?: boolean | undefined;
  25138. /**
  25139. * Use matrix interpolation instead of using direct key value when animating matrices
  25140. */
  25141. static AllowMatricesInterpolation: boolean;
  25142. /**
  25143. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25144. */
  25145. static AllowMatrixDecomposeForInterpolation: boolean;
  25146. /**
  25147. * Stores the key frames of the animation
  25148. */
  25149. private _keys;
  25150. /**
  25151. * Stores the easing function of the animation
  25152. */
  25153. private _easingFunction;
  25154. /**
  25155. * @hidden Internal use only
  25156. */
  25157. _runtimeAnimations: RuntimeAnimation[];
  25158. /**
  25159. * The set of event that will be linked to this animation
  25160. */
  25161. private _events;
  25162. /**
  25163. * Stores an array of target property paths
  25164. */
  25165. targetPropertyPath: string[];
  25166. /**
  25167. * Stores the blending speed of the animation
  25168. */
  25169. blendingSpeed: number;
  25170. /**
  25171. * Stores the animation ranges for the animation
  25172. */
  25173. private _ranges;
  25174. /**
  25175. * @hidden Internal use
  25176. */
  25177. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25178. /**
  25179. * Sets up an animation
  25180. * @param property The property to animate
  25181. * @param animationType The animation type to apply
  25182. * @param framePerSecond The frames per second of the animation
  25183. * @param easingFunction The easing function used in the animation
  25184. * @returns The created animation
  25185. */
  25186. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25187. /**
  25188. * Create and start an animation on a node
  25189. * @param name defines the name of the global animation that will be run on all nodes
  25190. * @param node defines the root node where the animation will take place
  25191. * @param targetProperty defines property to animate
  25192. * @param framePerSecond defines the number of frame per second yo use
  25193. * @param totalFrame defines the number of frames in total
  25194. * @param from defines the initial value
  25195. * @param to defines the final value
  25196. * @param loopMode defines which loop mode you want to use (off by default)
  25197. * @param easingFunction defines the easing function to use (linear by default)
  25198. * @param onAnimationEnd defines the callback to call when animation end
  25199. * @returns the animatable created for this animation
  25200. */
  25201. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25202. /**
  25203. * Create and start an animation on a node and its descendants
  25204. * @param name defines the name of the global animation that will be run on all nodes
  25205. * @param node defines the root node where the animation will take place
  25206. * @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
  25207. * @param targetProperty defines property to animate
  25208. * @param framePerSecond defines the number of frame per second to use
  25209. * @param totalFrame defines the number of frames in total
  25210. * @param from defines the initial value
  25211. * @param to defines the final value
  25212. * @param loopMode defines which loop mode you want to use (off by default)
  25213. * @param easingFunction defines the easing function to use (linear by default)
  25214. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25215. * @returns the list of animatables created for all nodes
  25216. * @example https://www.babylonjs-playground.com/#MH0VLI
  25217. */
  25218. 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[]>;
  25219. /**
  25220. * Creates a new animation, merges it with the existing animations and starts it
  25221. * @param name Name of the animation
  25222. * @param node Node which contains the scene that begins the animations
  25223. * @param targetProperty Specifies which property to animate
  25224. * @param framePerSecond The frames per second of the animation
  25225. * @param totalFrame The total number of frames
  25226. * @param from The frame at the beginning of the animation
  25227. * @param to The frame at the end of the animation
  25228. * @param loopMode Specifies the loop mode of the animation
  25229. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25230. * @param onAnimationEnd Callback to run once the animation is complete
  25231. * @returns Nullable animation
  25232. */
  25233. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25234. /**
  25235. * Transition property of an host to the target Value
  25236. * @param property The property to transition
  25237. * @param targetValue The target Value of the property
  25238. * @param host The object where the property to animate belongs
  25239. * @param scene Scene used to run the animation
  25240. * @param frameRate Framerate (in frame/s) to use
  25241. * @param transition The transition type we want to use
  25242. * @param duration The duration of the animation, in milliseconds
  25243. * @param onAnimationEnd Callback trigger at the end of the animation
  25244. * @returns Nullable animation
  25245. */
  25246. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25247. /**
  25248. * Return the array of runtime animations currently using this animation
  25249. */
  25250. readonly runtimeAnimations: RuntimeAnimation[];
  25251. /**
  25252. * Specifies if any of the runtime animations are currently running
  25253. */
  25254. readonly hasRunningRuntimeAnimations: boolean;
  25255. /**
  25256. * Initializes the animation
  25257. * @param name Name of the animation
  25258. * @param targetProperty Property to animate
  25259. * @param framePerSecond The frames per second of the animation
  25260. * @param dataType The data type of the animation
  25261. * @param loopMode The loop mode of the animation
  25262. * @param enableBlending Specifies if blending should be enabled
  25263. */
  25264. constructor(
  25265. /**Name of the animation */
  25266. name: string,
  25267. /**Property to animate */
  25268. targetProperty: string,
  25269. /**The frames per second of the animation */
  25270. framePerSecond: number,
  25271. /**The data type of the animation */
  25272. dataType: number,
  25273. /**The loop mode of the animation */
  25274. loopMode?: number | undefined,
  25275. /**Specifies if blending should be enabled */
  25276. enableBlending?: boolean | undefined);
  25277. /**
  25278. * Converts the animation to a string
  25279. * @param fullDetails support for multiple levels of logging within scene loading
  25280. * @returns String form of the animation
  25281. */
  25282. toString(fullDetails?: boolean): string;
  25283. /**
  25284. * Add an event to this animation
  25285. * @param event Event to add
  25286. */
  25287. addEvent(event: AnimationEvent): void;
  25288. /**
  25289. * Remove all events found at the given frame
  25290. * @param frame The frame to remove events from
  25291. */
  25292. removeEvents(frame: number): void;
  25293. /**
  25294. * Retrieves all the events from the animation
  25295. * @returns Events from the animation
  25296. */
  25297. getEvents(): AnimationEvent[];
  25298. /**
  25299. * Creates an animation range
  25300. * @param name Name of the animation range
  25301. * @param from Starting frame of the animation range
  25302. * @param to Ending frame of the animation
  25303. */
  25304. createRange(name: string, from: number, to: number): void;
  25305. /**
  25306. * Deletes an animation range by name
  25307. * @param name Name of the animation range to delete
  25308. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25309. */
  25310. deleteRange(name: string, deleteFrames?: boolean): void;
  25311. /**
  25312. * Gets the animation range by name, or null if not defined
  25313. * @param name Name of the animation range
  25314. * @returns Nullable animation range
  25315. */
  25316. getRange(name: string): Nullable<AnimationRange>;
  25317. /**
  25318. * Gets the key frames from the animation
  25319. * @returns The key frames of the animation
  25320. */
  25321. getKeys(): Array<IAnimationKey>;
  25322. /**
  25323. * Gets the highest frame rate of the animation
  25324. * @returns Highest frame rate of the animation
  25325. */
  25326. getHighestFrame(): number;
  25327. /**
  25328. * Gets the easing function of the animation
  25329. * @returns Easing function of the animation
  25330. */
  25331. getEasingFunction(): IEasingFunction;
  25332. /**
  25333. * Sets the easing function of the animation
  25334. * @param easingFunction A custom mathematical formula for animation
  25335. */
  25336. setEasingFunction(easingFunction: EasingFunction): void;
  25337. /**
  25338. * Interpolates a scalar linearly
  25339. * @param startValue Start value of the animation curve
  25340. * @param endValue End value of the animation curve
  25341. * @param gradient Scalar amount to interpolate
  25342. * @returns Interpolated scalar value
  25343. */
  25344. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25345. /**
  25346. * Interpolates a scalar cubically
  25347. * @param startValue Start value of the animation curve
  25348. * @param outTangent End tangent of the animation
  25349. * @param endValue End value of the animation curve
  25350. * @param inTangent Start tangent of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated scalar value
  25353. */
  25354. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25355. /**
  25356. * Interpolates a quaternion using a spherical linear interpolation
  25357. * @param startValue Start value of the animation curve
  25358. * @param endValue End value of the animation curve
  25359. * @param gradient Scalar amount to interpolate
  25360. * @returns Interpolated quaternion value
  25361. */
  25362. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25363. /**
  25364. * Interpolates a quaternion cubically
  25365. * @param startValue Start value of the animation curve
  25366. * @param outTangent End tangent of the animation curve
  25367. * @param endValue End value of the animation curve
  25368. * @param inTangent Start tangent of the animation curve
  25369. * @param gradient Scalar amount to interpolate
  25370. * @returns Interpolated quaternion value
  25371. */
  25372. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25373. /**
  25374. * Interpolates a Vector3 linearl
  25375. * @param startValue Start value of the animation curve
  25376. * @param endValue End value of the animation curve
  25377. * @param gradient Scalar amount to interpolate
  25378. * @returns Interpolated scalar value
  25379. */
  25380. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25381. /**
  25382. * Interpolates a Vector3 cubically
  25383. * @param startValue Start value of the animation curve
  25384. * @param outTangent End tangent of the animation
  25385. * @param endValue End value of the animation curve
  25386. * @param inTangent Start tangent of the animation curve
  25387. * @param gradient Scalar amount to interpolate
  25388. * @returns InterpolatedVector3 value
  25389. */
  25390. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25391. /**
  25392. * Interpolates a Vector2 linearly
  25393. * @param startValue Start value of the animation curve
  25394. * @param endValue End value of the animation curve
  25395. * @param gradient Scalar amount to interpolate
  25396. * @returns Interpolated Vector2 value
  25397. */
  25398. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25399. /**
  25400. * Interpolates a Vector2 cubically
  25401. * @param startValue Start value of the animation curve
  25402. * @param outTangent End tangent of the animation
  25403. * @param endValue End value of the animation curve
  25404. * @param inTangent Start tangent of the animation curve
  25405. * @param gradient Scalar amount to interpolate
  25406. * @returns Interpolated Vector2 value
  25407. */
  25408. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25409. /**
  25410. * Interpolates a size linearly
  25411. * @param startValue Start value of the animation curve
  25412. * @param endValue End value of the animation curve
  25413. * @param gradient Scalar amount to interpolate
  25414. * @returns Interpolated Size value
  25415. */
  25416. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25417. /**
  25418. * Interpolates a Color3 linearly
  25419. * @param startValue Start value of the animation curve
  25420. * @param endValue End value of the animation curve
  25421. * @param gradient Scalar amount to interpolate
  25422. * @returns Interpolated Color3 value
  25423. */
  25424. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25425. /**
  25426. * @hidden Internal use only
  25427. */
  25428. _getKeyValue(value: any): any;
  25429. /**
  25430. * @hidden Internal use only
  25431. */
  25432. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25433. /**
  25434. * Defines the function to use to interpolate matrices
  25435. * @param startValue defines the start matrix
  25436. * @param endValue defines the end matrix
  25437. * @param gradient defines the gradient between both matrices
  25438. * @param result defines an optional target matrix where to store the interpolation
  25439. * @returns the interpolated matrix
  25440. */
  25441. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25442. /**
  25443. * Makes a copy of the animation
  25444. * @returns Cloned animation
  25445. */
  25446. clone(): Animation;
  25447. /**
  25448. * Sets the key frames of the animation
  25449. * @param values The animation key frames to set
  25450. */
  25451. setKeys(values: Array<IAnimationKey>): void;
  25452. /**
  25453. * Serializes the animation to an object
  25454. * @returns Serialized object
  25455. */
  25456. serialize(): any;
  25457. /**
  25458. * Float animation type
  25459. */
  25460. private static _ANIMATIONTYPE_FLOAT;
  25461. /**
  25462. * Vector3 animation type
  25463. */
  25464. private static _ANIMATIONTYPE_VECTOR3;
  25465. /**
  25466. * Quaternion animation type
  25467. */
  25468. private static _ANIMATIONTYPE_QUATERNION;
  25469. /**
  25470. * Matrix animation type
  25471. */
  25472. private static _ANIMATIONTYPE_MATRIX;
  25473. /**
  25474. * Color3 animation type
  25475. */
  25476. private static _ANIMATIONTYPE_COLOR3;
  25477. /**
  25478. * Vector2 animation type
  25479. */
  25480. private static _ANIMATIONTYPE_VECTOR2;
  25481. /**
  25482. * Size animation type
  25483. */
  25484. private static _ANIMATIONTYPE_SIZE;
  25485. /**
  25486. * Relative Loop Mode
  25487. */
  25488. private static _ANIMATIONLOOPMODE_RELATIVE;
  25489. /**
  25490. * Cycle Loop Mode
  25491. */
  25492. private static _ANIMATIONLOOPMODE_CYCLE;
  25493. /**
  25494. * Constant Loop Mode
  25495. */
  25496. private static _ANIMATIONLOOPMODE_CONSTANT;
  25497. /**
  25498. * Get the float animation type
  25499. */
  25500. static readonly ANIMATIONTYPE_FLOAT: number;
  25501. /**
  25502. * Get the Vector3 animation type
  25503. */
  25504. static readonly ANIMATIONTYPE_VECTOR3: number;
  25505. /**
  25506. * Get the Vector2 animation type
  25507. */
  25508. static readonly ANIMATIONTYPE_VECTOR2: number;
  25509. /**
  25510. * Get the Size animation type
  25511. */
  25512. static readonly ANIMATIONTYPE_SIZE: number;
  25513. /**
  25514. * Get the Quaternion animation type
  25515. */
  25516. static readonly ANIMATIONTYPE_QUATERNION: number;
  25517. /**
  25518. * Get the Matrix animation type
  25519. */
  25520. static readonly ANIMATIONTYPE_MATRIX: number;
  25521. /**
  25522. * Get the Color3 animation type
  25523. */
  25524. static readonly ANIMATIONTYPE_COLOR3: number;
  25525. /**
  25526. * Get the Relative Loop Mode
  25527. */
  25528. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25529. /**
  25530. * Get the Cycle Loop Mode
  25531. */
  25532. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25533. /**
  25534. * Get the Constant Loop Mode
  25535. */
  25536. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25537. /** @hidden */
  25538. static _UniversalLerp(left: any, right: any, amount: number): any;
  25539. /**
  25540. * Parses an animation object and creates an animation
  25541. * @param parsedAnimation Parsed animation object
  25542. * @returns Animation object
  25543. */
  25544. static Parse(parsedAnimation: any): Animation;
  25545. /**
  25546. * Appends the serialized animations from the source animations
  25547. * @param source Source containing the animations
  25548. * @param destination Target to store the animations
  25549. */
  25550. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25551. }
  25552. }
  25553. declare module BABYLON {
  25554. /**
  25555. * Base class of all the textures in babylon.
  25556. * It groups all the common properties the materials, post process, lights... might need
  25557. * in order to make a correct use of the texture.
  25558. */
  25559. export class BaseTexture implements IAnimatable {
  25560. /**
  25561. * Default anisotropic filtering level for the application.
  25562. * It is set to 4 as a good tradeoff between perf and quality.
  25563. */
  25564. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25565. /**
  25566. * Gets or sets the unique id of the texture
  25567. */
  25568. uniqueId: number;
  25569. /**
  25570. * Define the name of the texture.
  25571. */
  25572. name: string;
  25573. /**
  25574. * Gets or sets an object used to store user defined information.
  25575. */
  25576. metadata: any;
  25577. /**
  25578. * For internal use only. Please do not use.
  25579. */
  25580. reservedDataStore: any;
  25581. private _hasAlpha;
  25582. /**
  25583. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25584. */
  25585. hasAlpha: boolean;
  25586. /**
  25587. * Defines if the alpha value should be determined via the rgb values.
  25588. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25589. */
  25590. getAlphaFromRGB: boolean;
  25591. /**
  25592. * Intensity or strength of the texture.
  25593. * It is commonly used by materials to fine tune the intensity of the texture
  25594. */
  25595. level: number;
  25596. /**
  25597. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25598. * This is part of the texture as textures usually maps to one uv set.
  25599. */
  25600. coordinatesIndex: number;
  25601. private _coordinatesMode;
  25602. /**
  25603. * How a texture is mapped.
  25604. *
  25605. * | Value | Type | Description |
  25606. * | ----- | ----------------------------------- | ----------- |
  25607. * | 0 | EXPLICIT_MODE | |
  25608. * | 1 | SPHERICAL_MODE | |
  25609. * | 2 | PLANAR_MODE | |
  25610. * | 3 | CUBIC_MODE | |
  25611. * | 4 | PROJECTION_MODE | |
  25612. * | 5 | SKYBOX_MODE | |
  25613. * | 6 | INVCUBIC_MODE | |
  25614. * | 7 | EQUIRECTANGULAR_MODE | |
  25615. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25616. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25617. */
  25618. coordinatesMode: number;
  25619. /**
  25620. * | Value | Type | Description |
  25621. * | ----- | ------------------ | ----------- |
  25622. * | 0 | CLAMP_ADDRESSMODE | |
  25623. * | 1 | WRAP_ADDRESSMODE | |
  25624. * | 2 | MIRROR_ADDRESSMODE | |
  25625. */
  25626. wrapU: number;
  25627. /**
  25628. * | Value | Type | Description |
  25629. * | ----- | ------------------ | ----------- |
  25630. * | 0 | CLAMP_ADDRESSMODE | |
  25631. * | 1 | WRAP_ADDRESSMODE | |
  25632. * | 2 | MIRROR_ADDRESSMODE | |
  25633. */
  25634. wrapV: number;
  25635. /**
  25636. * | Value | Type | Description |
  25637. * | ----- | ------------------ | ----------- |
  25638. * | 0 | CLAMP_ADDRESSMODE | |
  25639. * | 1 | WRAP_ADDRESSMODE | |
  25640. * | 2 | MIRROR_ADDRESSMODE | |
  25641. */
  25642. wrapR: number;
  25643. /**
  25644. * With compliant hardware and browser (supporting anisotropic filtering)
  25645. * this defines the level of anisotropic filtering in the texture.
  25646. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25647. */
  25648. anisotropicFilteringLevel: number;
  25649. /**
  25650. * Define if the texture is a cube texture or if false a 2d texture.
  25651. */
  25652. isCube: boolean;
  25653. /**
  25654. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25655. */
  25656. is3D: boolean;
  25657. /**
  25658. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25659. * HDR texture are usually stored in linear space.
  25660. * This only impacts the PBR and Background materials
  25661. */
  25662. gammaSpace: boolean;
  25663. /**
  25664. * Gets whether or not the texture contains RGBD data.
  25665. */
  25666. readonly isRGBD: boolean;
  25667. /**
  25668. * Is Z inverted in the texture (useful in a cube texture).
  25669. */
  25670. invertZ: boolean;
  25671. /**
  25672. * Are mip maps generated for this texture or not.
  25673. */
  25674. readonly noMipmap: boolean;
  25675. /**
  25676. * @hidden
  25677. */
  25678. lodLevelInAlpha: boolean;
  25679. /**
  25680. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25681. */
  25682. lodGenerationOffset: number;
  25683. /**
  25684. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25685. */
  25686. lodGenerationScale: number;
  25687. /**
  25688. * Define if the texture is a render target.
  25689. */
  25690. isRenderTarget: boolean;
  25691. /**
  25692. * Define the unique id of the texture in the scene.
  25693. */
  25694. readonly uid: string;
  25695. /**
  25696. * Return a string representation of the texture.
  25697. * @returns the texture as a string
  25698. */
  25699. toString(): string;
  25700. /**
  25701. * Get the class name of the texture.
  25702. * @returns "BaseTexture"
  25703. */
  25704. getClassName(): string;
  25705. /**
  25706. * Define the list of animation attached to the texture.
  25707. */
  25708. animations: Animation[];
  25709. /**
  25710. * An event triggered when the texture is disposed.
  25711. */
  25712. onDisposeObservable: Observable<BaseTexture>;
  25713. private _onDisposeObserver;
  25714. /**
  25715. * Callback triggered when the texture has been disposed.
  25716. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25717. */
  25718. onDispose: () => void;
  25719. /**
  25720. * Define the current state of the loading sequence when in delayed load mode.
  25721. */
  25722. delayLoadState: number;
  25723. private _scene;
  25724. /** @hidden */
  25725. _texture: Nullable<InternalTexture>;
  25726. private _uid;
  25727. /**
  25728. * Define if the texture is preventinga material to render or not.
  25729. * If not and the texture is not ready, the engine will use a default black texture instead.
  25730. */
  25731. readonly isBlocking: boolean;
  25732. /**
  25733. * Instantiates a new BaseTexture.
  25734. * Base class of all the textures in babylon.
  25735. * It groups all the common properties the materials, post process, lights... might need
  25736. * in order to make a correct use of the texture.
  25737. * @param scene Define the scene the texture blongs to
  25738. */
  25739. constructor(scene: Nullable<Scene>);
  25740. /**
  25741. * Get the scene the texture belongs to.
  25742. * @returns the scene or null if undefined
  25743. */
  25744. getScene(): Nullable<Scene>;
  25745. /**
  25746. * Get the texture transform matrix used to offset tile the texture for istance.
  25747. * @returns the transformation matrix
  25748. */
  25749. getTextureMatrix(): Matrix;
  25750. /**
  25751. * Get the texture reflection matrix used to rotate/transform the reflection.
  25752. * @returns the reflection matrix
  25753. */
  25754. getReflectionTextureMatrix(): Matrix;
  25755. /**
  25756. * Get the underlying lower level texture from Babylon.
  25757. * @returns the insternal texture
  25758. */
  25759. getInternalTexture(): Nullable<InternalTexture>;
  25760. /**
  25761. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25762. * @returns true if ready or not blocking
  25763. */
  25764. isReadyOrNotBlocking(): boolean;
  25765. /**
  25766. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25767. * @returns true if fully ready
  25768. */
  25769. isReady(): boolean;
  25770. private _cachedSize;
  25771. /**
  25772. * Get the size of the texture.
  25773. * @returns the texture size.
  25774. */
  25775. getSize(): ISize;
  25776. /**
  25777. * Get the base size of the texture.
  25778. * It can be different from the size if the texture has been resized for POT for instance
  25779. * @returns the base size
  25780. */
  25781. getBaseSize(): ISize;
  25782. /**
  25783. * Update the sampling mode of the texture.
  25784. * Default is Trilinear mode.
  25785. *
  25786. * | Value | Type | Description |
  25787. * | ----- | ------------------ | ----------- |
  25788. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25789. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25790. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25791. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25792. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25793. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25794. * | 7 | NEAREST_LINEAR | |
  25795. * | 8 | NEAREST_NEAREST | |
  25796. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25797. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25798. * | 11 | LINEAR_LINEAR | |
  25799. * | 12 | LINEAR_NEAREST | |
  25800. *
  25801. * > _mag_: magnification filter (close to the viewer)
  25802. * > _min_: minification filter (far from the viewer)
  25803. * > _mip_: filter used between mip map levels
  25804. *@param samplingMode Define the new sampling mode of the texture
  25805. */
  25806. updateSamplingMode(samplingMode: number): void;
  25807. /**
  25808. * Scales the texture if is `canRescale()`
  25809. * @param ratio the resize factor we want to use to rescale
  25810. */
  25811. scale(ratio: number): void;
  25812. /**
  25813. * Get if the texture can rescale.
  25814. */
  25815. readonly canRescale: boolean;
  25816. /** @hidden */
  25817. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25818. /** @hidden */
  25819. _rebuild(): void;
  25820. /**
  25821. * Triggers the load sequence in delayed load mode.
  25822. */
  25823. delayLoad(): void;
  25824. /**
  25825. * Clones the texture.
  25826. * @returns the cloned texture
  25827. */
  25828. clone(): Nullable<BaseTexture>;
  25829. /**
  25830. * Get the texture underlying type (INT, FLOAT...)
  25831. */
  25832. readonly textureType: number;
  25833. /**
  25834. * Get the texture underlying format (RGB, RGBA...)
  25835. */
  25836. readonly textureFormat: number;
  25837. /**
  25838. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25839. * This will returns an RGBA array buffer containing either in values (0-255) or
  25840. * float values (0-1) depending of the underlying buffer type.
  25841. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25842. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25843. * @param buffer defines a user defined buffer to fill with data (can be null)
  25844. * @returns The Array buffer containing the pixels data.
  25845. */
  25846. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25847. /**
  25848. * Release and destroy the underlying lower level texture aka internalTexture.
  25849. */
  25850. releaseInternalTexture(): void;
  25851. /**
  25852. * Get the polynomial representation of the texture data.
  25853. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25854. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25855. */
  25856. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25857. /** @hidden */
  25858. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25859. /** @hidden */
  25860. readonly _lodTextureMid: Nullable<BaseTexture>;
  25861. /** @hidden */
  25862. readonly _lodTextureLow: Nullable<BaseTexture>;
  25863. /**
  25864. * Dispose the texture and release its associated resources.
  25865. */
  25866. dispose(): void;
  25867. /**
  25868. * Serialize the texture into a JSON representation that can be parsed later on.
  25869. * @returns the JSON representation of the texture
  25870. */
  25871. serialize(): any;
  25872. /**
  25873. * Helper function to be called back once a list of texture contains only ready textures.
  25874. * @param textures Define the list of textures to wait for
  25875. * @param callback Define the callback triggered once the entire list will be ready
  25876. */
  25877. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25878. }
  25879. }
  25880. declare module BABYLON {
  25881. /**
  25882. * Uniform buffer objects.
  25883. *
  25884. * Handles blocks of uniform on the GPU.
  25885. *
  25886. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25887. *
  25888. * For more information, please refer to :
  25889. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25890. */
  25891. export class UniformBuffer {
  25892. private _engine;
  25893. private _buffer;
  25894. private _data;
  25895. private _bufferData;
  25896. private _dynamic?;
  25897. private _uniformLocations;
  25898. private _uniformSizes;
  25899. private _uniformLocationPointer;
  25900. private _needSync;
  25901. private _noUBO;
  25902. private _currentEffect;
  25903. private static _MAX_UNIFORM_SIZE;
  25904. private static _tempBuffer;
  25905. /**
  25906. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25907. * This is dynamic to allow compat with webgl 1 and 2.
  25908. * You will need to pass the name of the uniform as well as the value.
  25909. */
  25910. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25911. /**
  25912. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25913. * This is dynamic to allow compat with webgl 1 and 2.
  25914. * You will need to pass the name of the uniform as well as the value.
  25915. */
  25916. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25917. /**
  25918. * Lambda to Update a single float in a uniform buffer.
  25919. * This is dynamic to allow compat with webgl 1 and 2.
  25920. * You will need to pass the name of the uniform as well as the value.
  25921. */
  25922. updateFloat: (name: string, x: number) => void;
  25923. /**
  25924. * Lambda to Update a vec2 of float in a uniform buffer.
  25925. * This is dynamic to allow compat with webgl 1 and 2.
  25926. * You will need to pass the name of the uniform as well as the value.
  25927. */
  25928. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25929. /**
  25930. * Lambda to Update a vec3 of float in a uniform buffer.
  25931. * This is dynamic to allow compat with webgl 1 and 2.
  25932. * You will need to pass the name of the uniform as well as the value.
  25933. */
  25934. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25935. /**
  25936. * Lambda to Update a vec4 of float in a uniform buffer.
  25937. * This is dynamic to allow compat with webgl 1 and 2.
  25938. * You will need to pass the name of the uniform as well as the value.
  25939. */
  25940. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25941. /**
  25942. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25943. * This is dynamic to allow compat with webgl 1 and 2.
  25944. * You will need to pass the name of the uniform as well as the value.
  25945. */
  25946. updateMatrix: (name: string, mat: Matrix) => void;
  25947. /**
  25948. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25949. * This is dynamic to allow compat with webgl 1 and 2.
  25950. * You will need to pass the name of the uniform as well as the value.
  25951. */
  25952. updateVector3: (name: string, vector: Vector3) => void;
  25953. /**
  25954. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25955. * This is dynamic to allow compat with webgl 1 and 2.
  25956. * You will need to pass the name of the uniform as well as the value.
  25957. */
  25958. updateVector4: (name: string, vector: Vector4) => void;
  25959. /**
  25960. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25961. * This is dynamic to allow compat with webgl 1 and 2.
  25962. * You will need to pass the name of the uniform as well as the value.
  25963. */
  25964. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25965. /**
  25966. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25967. * This is dynamic to allow compat with webgl 1 and 2.
  25968. * You will need to pass the name of the uniform as well as the value.
  25969. */
  25970. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25971. /**
  25972. * Instantiates a new Uniform buffer objects.
  25973. *
  25974. * Handles blocks of uniform on the GPU.
  25975. *
  25976. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25977. *
  25978. * For more information, please refer to :
  25979. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25980. * @param engine Define the engine the buffer is associated with
  25981. * @param data Define the data contained in the buffer
  25982. * @param dynamic Define if the buffer is updatable
  25983. */
  25984. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25985. /**
  25986. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25987. * or just falling back on setUniformXXX calls.
  25988. */
  25989. readonly useUbo: boolean;
  25990. /**
  25991. * Indicates if the WebGL underlying uniform buffer is in sync
  25992. * with the javascript cache data.
  25993. */
  25994. readonly isSync: boolean;
  25995. /**
  25996. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25997. * Also, a dynamic UniformBuffer will disable cache verification and always
  25998. * update the underlying WebGL uniform buffer to the GPU.
  25999. * @returns if Dynamic, otherwise false
  26000. */
  26001. isDynamic(): boolean;
  26002. /**
  26003. * The data cache on JS side.
  26004. * @returns the underlying data as a float array
  26005. */
  26006. getData(): Float32Array;
  26007. /**
  26008. * The underlying WebGL Uniform buffer.
  26009. * @returns the webgl buffer
  26010. */
  26011. getBuffer(): Nullable<WebGLBuffer>;
  26012. /**
  26013. * std140 layout specifies how to align data within an UBO structure.
  26014. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26015. * for specs.
  26016. */
  26017. private _fillAlignment;
  26018. /**
  26019. * Adds an uniform in the buffer.
  26020. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26021. * for the layout to be correct !
  26022. * @param name Name of the uniform, as used in the uniform block in the shader.
  26023. * @param size Data size, or data directly.
  26024. */
  26025. addUniform(name: string, size: number | number[]): void;
  26026. /**
  26027. * Adds a Matrix 4x4 to the uniform buffer.
  26028. * @param name Name of the uniform, as used in the uniform block in the shader.
  26029. * @param mat A 4x4 matrix.
  26030. */
  26031. addMatrix(name: string, mat: Matrix): void;
  26032. /**
  26033. * Adds a vec2 to the uniform buffer.
  26034. * @param name Name of the uniform, as used in the uniform block in the shader.
  26035. * @param x Define the x component value of the vec2
  26036. * @param y Define the y component value of the vec2
  26037. */
  26038. addFloat2(name: string, x: number, y: number): void;
  26039. /**
  26040. * Adds a vec3 to the uniform buffer.
  26041. * @param name Name of the uniform, as used in the uniform block in the shader.
  26042. * @param x Define the x component value of the vec3
  26043. * @param y Define the y component value of the vec3
  26044. * @param z Define the z component value of the vec3
  26045. */
  26046. addFloat3(name: string, x: number, y: number, z: number): void;
  26047. /**
  26048. * Adds a vec3 to the uniform buffer.
  26049. * @param name Name of the uniform, as used in the uniform block in the shader.
  26050. * @param color Define the vec3 from a Color
  26051. */
  26052. addColor3(name: string, color: Color3): void;
  26053. /**
  26054. * Adds a vec4 to the uniform buffer.
  26055. * @param name Name of the uniform, as used in the uniform block in the shader.
  26056. * @param color Define the rgb components from a Color
  26057. * @param alpha Define the a component of the vec4
  26058. */
  26059. addColor4(name: string, color: Color3, alpha: number): void;
  26060. /**
  26061. * Adds a vec3 to the uniform buffer.
  26062. * @param name Name of the uniform, as used in the uniform block in the shader.
  26063. * @param vector Define the vec3 components from a Vector
  26064. */
  26065. addVector3(name: string, vector: Vector3): void;
  26066. /**
  26067. * Adds a Matrix 3x3 to the uniform buffer.
  26068. * @param name Name of the uniform, as used in the uniform block in the shader.
  26069. */
  26070. addMatrix3x3(name: string): void;
  26071. /**
  26072. * Adds a Matrix 2x2 to the uniform buffer.
  26073. * @param name Name of the uniform, as used in the uniform block in the shader.
  26074. */
  26075. addMatrix2x2(name: string): void;
  26076. /**
  26077. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26078. */
  26079. create(): void;
  26080. /** @hidden */
  26081. _rebuild(): void;
  26082. /**
  26083. * Updates the WebGL Uniform Buffer on the GPU.
  26084. * If the `dynamic` flag is set to true, no cache comparison is done.
  26085. * Otherwise, the buffer will be updated only if the cache differs.
  26086. */
  26087. update(): void;
  26088. /**
  26089. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26090. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26091. * @param data Define the flattened data
  26092. * @param size Define the size of the data.
  26093. */
  26094. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26095. private _updateMatrix3x3ForUniform;
  26096. private _updateMatrix3x3ForEffect;
  26097. private _updateMatrix2x2ForEffect;
  26098. private _updateMatrix2x2ForUniform;
  26099. private _updateFloatForEffect;
  26100. private _updateFloatForUniform;
  26101. private _updateFloat2ForEffect;
  26102. private _updateFloat2ForUniform;
  26103. private _updateFloat3ForEffect;
  26104. private _updateFloat3ForUniform;
  26105. private _updateFloat4ForEffect;
  26106. private _updateFloat4ForUniform;
  26107. private _updateMatrixForEffect;
  26108. private _updateMatrixForUniform;
  26109. private _updateVector3ForEffect;
  26110. private _updateVector3ForUniform;
  26111. private _updateVector4ForEffect;
  26112. private _updateVector4ForUniform;
  26113. private _updateColor3ForEffect;
  26114. private _updateColor3ForUniform;
  26115. private _updateColor4ForEffect;
  26116. private _updateColor4ForUniform;
  26117. /**
  26118. * Sets a sampler uniform on the effect.
  26119. * @param name Define the name of the sampler.
  26120. * @param texture Define the texture to set in the sampler
  26121. */
  26122. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26123. /**
  26124. * Directly updates the value of the uniform in the cache AND on the GPU.
  26125. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26126. * @param data Define the flattened data
  26127. */
  26128. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26129. /**
  26130. * Binds this uniform buffer to an effect.
  26131. * @param effect Define the effect to bind the buffer to
  26132. * @param name Name of the uniform block in the shader.
  26133. */
  26134. bindToEffect(effect: Effect, name: string): void;
  26135. /**
  26136. * Disposes the uniform buffer.
  26137. */
  26138. dispose(): void;
  26139. }
  26140. }
  26141. declare module BABYLON {
  26142. /**
  26143. * This represents the required contract to create a new type of texture loader.
  26144. */
  26145. export interface IInternalTextureLoader {
  26146. /**
  26147. * Defines wether the loader supports cascade loading the different faces.
  26148. */
  26149. supportCascades: boolean;
  26150. /**
  26151. * This returns if the loader support the current file information.
  26152. * @param extension defines the file extension of the file being loaded
  26153. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26154. * @param fallback defines the fallback internal texture if any
  26155. * @param isBase64 defines whether the texture is encoded as a base64
  26156. * @param isBuffer defines whether the texture data are stored as a buffer
  26157. * @returns true if the loader can load the specified file
  26158. */
  26159. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26160. /**
  26161. * Transform the url before loading if required.
  26162. * @param rootUrl the url of the texture
  26163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26164. * @returns the transformed texture
  26165. */
  26166. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26167. /**
  26168. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26169. * @param rootUrl the url of the texture
  26170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26171. * @returns the fallback texture
  26172. */
  26173. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26174. /**
  26175. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26176. * @param data contains the texture data
  26177. * @param texture defines the BabylonJS internal texture
  26178. * @param createPolynomials will be true if polynomials have been requested
  26179. * @param onLoad defines the callback to trigger once the texture is ready
  26180. * @param onError defines the callback to trigger in case of error
  26181. */
  26182. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26183. /**
  26184. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26185. * @param data contains the texture data
  26186. * @param texture defines the BabylonJS internal texture
  26187. * @param callback defines the method to call once ready to upload
  26188. */
  26189. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26190. }
  26191. }
  26192. declare module BABYLON {
  26193. /**
  26194. * Creation options of the multi render target texture.
  26195. */
  26196. export interface IMultiRenderTargetOptions {
  26197. /**
  26198. * Define if the texture needs to create mip maps after render.
  26199. */
  26200. generateMipMaps?: boolean;
  26201. /**
  26202. * Define the types of all the draw buffers we want to create
  26203. */
  26204. types?: number[];
  26205. /**
  26206. * Define the sampling modes of all the draw buffers we want to create
  26207. */
  26208. samplingModes?: number[];
  26209. /**
  26210. * Define if a depth buffer is required
  26211. */
  26212. generateDepthBuffer?: boolean;
  26213. /**
  26214. * Define if a stencil buffer is required
  26215. */
  26216. generateStencilBuffer?: boolean;
  26217. /**
  26218. * Define if a depth texture is required instead of a depth buffer
  26219. */
  26220. generateDepthTexture?: boolean;
  26221. /**
  26222. * Define the number of desired draw buffers
  26223. */
  26224. textureCount?: number;
  26225. /**
  26226. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26227. */
  26228. doNotChangeAspectRatio?: boolean;
  26229. /**
  26230. * Define the default type of the buffers we are creating
  26231. */
  26232. defaultType?: number;
  26233. }
  26234. /**
  26235. * A multi render target, like a render target provides the ability to render to a texture.
  26236. * Unlike the render target, it can render to several draw buffers in one draw.
  26237. * This is specially interesting in deferred rendering or for any effects requiring more than
  26238. * just one color from a single pass.
  26239. */
  26240. export class MultiRenderTarget extends RenderTargetTexture {
  26241. private _internalTextures;
  26242. private _textures;
  26243. private _multiRenderTargetOptions;
  26244. /**
  26245. * Get if draw buffers are currently supported by the used hardware and browser.
  26246. */
  26247. readonly isSupported: boolean;
  26248. /**
  26249. * Get the list of textures generated by the multi render target.
  26250. */
  26251. readonly textures: Texture[];
  26252. /**
  26253. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26254. */
  26255. readonly depthTexture: Texture;
  26256. /**
  26257. * Set the wrapping mode on U of all the textures we are rendering to.
  26258. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26259. */
  26260. wrapU: number;
  26261. /**
  26262. * Set the wrapping mode on V of all the textures we are rendering to.
  26263. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26264. */
  26265. wrapV: number;
  26266. /**
  26267. * Instantiate a new multi render target texture.
  26268. * A multi render target, like a render target provides the ability to render to a texture.
  26269. * Unlike the render target, it can render to several draw buffers in one draw.
  26270. * This is specially interesting in deferred rendering or for any effects requiring more than
  26271. * just one color from a single pass.
  26272. * @param name Define the name of the texture
  26273. * @param size Define the size of the buffers to render to
  26274. * @param count Define the number of target we are rendering into
  26275. * @param scene Define the scene the texture belongs to
  26276. * @param options Define the options used to create the multi render target
  26277. */
  26278. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26279. /** @hidden */
  26280. _rebuild(): void;
  26281. private _createInternalTextures;
  26282. private _createTextures;
  26283. /**
  26284. * Define the number of samples used if MSAA is enabled.
  26285. */
  26286. samples: number;
  26287. /**
  26288. * Resize all the textures in the multi render target.
  26289. * Be carrefull as it will recreate all the data in the new texture.
  26290. * @param size Define the new size
  26291. */
  26292. resize(size: any): void;
  26293. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26294. /**
  26295. * Dispose the render targets and their associated resources
  26296. */
  26297. dispose(): void;
  26298. /**
  26299. * Release all the underlying texture used as draw buffers.
  26300. */
  26301. releaseInternalTextures(): void;
  26302. }
  26303. }
  26304. declare module BABYLON {
  26305. /**
  26306. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26308. */
  26309. export class Analyser {
  26310. /**
  26311. * Gets or sets the smoothing
  26312. * @ignorenaming
  26313. */
  26314. SMOOTHING: number;
  26315. /**
  26316. * Gets or sets the FFT table size
  26317. * @ignorenaming
  26318. */
  26319. FFT_SIZE: number;
  26320. /**
  26321. * Gets or sets the bar graph amplitude
  26322. * @ignorenaming
  26323. */
  26324. BARGRAPHAMPLITUDE: number;
  26325. /**
  26326. * Gets or sets the position of the debug canvas
  26327. * @ignorenaming
  26328. */
  26329. DEBUGCANVASPOS: {
  26330. x: number;
  26331. y: number;
  26332. };
  26333. /**
  26334. * Gets or sets the debug canvas size
  26335. * @ignorenaming
  26336. */
  26337. DEBUGCANVASSIZE: {
  26338. width: number;
  26339. height: number;
  26340. };
  26341. private _byteFreqs;
  26342. private _byteTime;
  26343. private _floatFreqs;
  26344. private _webAudioAnalyser;
  26345. private _debugCanvas;
  26346. private _debugCanvasContext;
  26347. private _scene;
  26348. private _registerFunc;
  26349. private _audioEngine;
  26350. /**
  26351. * Creates a new analyser
  26352. * @param scene defines hosting scene
  26353. */
  26354. constructor(scene: Scene);
  26355. /**
  26356. * Get the number of data values you will have to play with for the visualization
  26357. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26358. * @returns a number
  26359. */
  26360. getFrequencyBinCount(): number;
  26361. /**
  26362. * Gets the current frequency data as a byte array
  26363. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26364. * @returns a Uint8Array
  26365. */
  26366. getByteFrequencyData(): Uint8Array;
  26367. /**
  26368. * Gets the current waveform as a byte array
  26369. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26370. * @returns a Uint8Array
  26371. */
  26372. getByteTimeDomainData(): Uint8Array;
  26373. /**
  26374. * Gets the current frequency data as a float array
  26375. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26376. * @returns a Float32Array
  26377. */
  26378. getFloatFrequencyData(): Float32Array;
  26379. /**
  26380. * Renders the debug canvas
  26381. */
  26382. drawDebugCanvas(): void;
  26383. /**
  26384. * Stops rendering the debug canvas and removes it
  26385. */
  26386. stopDebugCanvas(): void;
  26387. /**
  26388. * Connects two audio nodes
  26389. * @param inputAudioNode defines first node to connect
  26390. * @param outputAudioNode defines second node to connect
  26391. */
  26392. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26393. /**
  26394. * Releases all associated resources
  26395. */
  26396. dispose(): void;
  26397. }
  26398. }
  26399. declare module BABYLON {
  26400. /**
  26401. * This represents an audio engine and it is responsible
  26402. * to play, synchronize and analyse sounds throughout the application.
  26403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26404. */
  26405. export interface IAudioEngine extends IDisposable {
  26406. /**
  26407. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26408. */
  26409. readonly canUseWebAudio: boolean;
  26410. /**
  26411. * Gets the current AudioContext if available.
  26412. */
  26413. readonly audioContext: Nullable<AudioContext>;
  26414. /**
  26415. * The master gain node defines the global audio volume of your audio engine.
  26416. */
  26417. readonly masterGain: GainNode;
  26418. /**
  26419. * Gets whether or not mp3 are supported by your browser.
  26420. */
  26421. readonly isMP3supported: boolean;
  26422. /**
  26423. * Gets whether or not ogg are supported by your browser.
  26424. */
  26425. readonly isOGGsupported: boolean;
  26426. /**
  26427. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26428. * @ignoreNaming
  26429. */
  26430. WarnedWebAudioUnsupported: boolean;
  26431. /**
  26432. * Defines if the audio engine relies on a custom unlocked button.
  26433. * In this case, the embedded button will not be displayed.
  26434. */
  26435. useCustomUnlockedButton: boolean;
  26436. /**
  26437. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26438. */
  26439. readonly unlocked: boolean;
  26440. /**
  26441. * Event raised when audio has been unlocked on the browser.
  26442. */
  26443. onAudioUnlockedObservable: Observable<AudioEngine>;
  26444. /**
  26445. * Event raised when audio has been locked on the browser.
  26446. */
  26447. onAudioLockedObservable: Observable<AudioEngine>;
  26448. /**
  26449. * Flags the audio engine in Locked state.
  26450. * This happens due to new browser policies preventing audio to autoplay.
  26451. */
  26452. lock(): void;
  26453. /**
  26454. * Unlocks the audio engine once a user action has been done on the dom.
  26455. * This is helpful to resume play once browser policies have been satisfied.
  26456. */
  26457. unlock(): void;
  26458. }
  26459. /**
  26460. * This represents the default audio engine used in babylon.
  26461. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26463. */
  26464. export class AudioEngine implements IAudioEngine {
  26465. private _audioContext;
  26466. private _audioContextInitialized;
  26467. private _muteButton;
  26468. private _hostElement;
  26469. /**
  26470. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26471. */
  26472. canUseWebAudio: boolean;
  26473. /**
  26474. * The master gain node defines the global audio volume of your audio engine.
  26475. */
  26476. masterGain: GainNode;
  26477. /**
  26478. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26479. * @ignoreNaming
  26480. */
  26481. WarnedWebAudioUnsupported: boolean;
  26482. /**
  26483. * Gets whether or not mp3 are supported by your browser.
  26484. */
  26485. isMP3supported: boolean;
  26486. /**
  26487. * Gets whether or not ogg are supported by your browser.
  26488. */
  26489. isOGGsupported: boolean;
  26490. /**
  26491. * Gets whether audio has been unlocked on the device.
  26492. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26493. * a user interaction has happened.
  26494. */
  26495. unlocked: boolean;
  26496. /**
  26497. * Defines if the audio engine relies on a custom unlocked button.
  26498. * In this case, the embedded button will not be displayed.
  26499. */
  26500. useCustomUnlockedButton: boolean;
  26501. /**
  26502. * Event raised when audio has been unlocked on the browser.
  26503. */
  26504. onAudioUnlockedObservable: Observable<AudioEngine>;
  26505. /**
  26506. * Event raised when audio has been locked on the browser.
  26507. */
  26508. onAudioLockedObservable: Observable<AudioEngine>;
  26509. /**
  26510. * Gets the current AudioContext if available.
  26511. */
  26512. readonly audioContext: Nullable<AudioContext>;
  26513. private _connectedAnalyser;
  26514. /**
  26515. * Instantiates a new audio engine.
  26516. *
  26517. * There should be only one per page as some browsers restrict the number
  26518. * of audio contexts you can create.
  26519. * @param hostElement defines the host element where to display the mute icon if necessary
  26520. */
  26521. constructor(hostElement?: Nullable<HTMLElement>);
  26522. /**
  26523. * Flags the audio engine in Locked state.
  26524. * This happens due to new browser policies preventing audio to autoplay.
  26525. */
  26526. lock(): void;
  26527. /**
  26528. * Unlocks the audio engine once a user action has been done on the dom.
  26529. * This is helpful to resume play once browser policies have been satisfied.
  26530. */
  26531. unlock(): void;
  26532. private _resumeAudioContext;
  26533. private _initializeAudioContext;
  26534. private _tryToRun;
  26535. private _triggerRunningState;
  26536. private _triggerSuspendedState;
  26537. private _displayMuteButton;
  26538. private _moveButtonToTopLeft;
  26539. private _onResize;
  26540. private _hideMuteButton;
  26541. /**
  26542. * Destroy and release the resources associated with the audio ccontext.
  26543. */
  26544. dispose(): void;
  26545. /**
  26546. * Gets the global volume sets on the master gain.
  26547. * @returns the global volume if set or -1 otherwise
  26548. */
  26549. getGlobalVolume(): number;
  26550. /**
  26551. * Sets the global volume of your experience (sets on the master gain).
  26552. * @param newVolume Defines the new global volume of the application
  26553. */
  26554. setGlobalVolume(newVolume: number): void;
  26555. /**
  26556. * Connect the audio engine to an audio analyser allowing some amazing
  26557. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26559. * @param analyser The analyser to connect to the engine
  26560. */
  26561. connectToAnalyser(analyser: Analyser): void;
  26562. }
  26563. }
  26564. declare module BABYLON {
  26565. /**
  26566. * Interface used to present a loading screen while loading a scene
  26567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26568. */
  26569. export interface ILoadingScreen {
  26570. /**
  26571. * Function called to display the loading screen
  26572. */
  26573. displayLoadingUI: () => void;
  26574. /**
  26575. * Function called to hide the loading screen
  26576. */
  26577. hideLoadingUI: () => void;
  26578. /**
  26579. * Gets or sets the color to use for the background
  26580. */
  26581. loadingUIBackgroundColor: string;
  26582. /**
  26583. * Gets or sets the text to display while loading
  26584. */
  26585. loadingUIText: string;
  26586. }
  26587. /**
  26588. * Class used for the default loading screen
  26589. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26590. */
  26591. export class DefaultLoadingScreen implements ILoadingScreen {
  26592. private _renderingCanvas;
  26593. private _loadingText;
  26594. private _loadingDivBackgroundColor;
  26595. private _loadingDiv;
  26596. private _loadingTextDiv;
  26597. /**
  26598. * Creates a new default loading screen
  26599. * @param _renderingCanvas defines the canvas used to render the scene
  26600. * @param _loadingText defines the default text to display
  26601. * @param _loadingDivBackgroundColor defines the default background color
  26602. */
  26603. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26604. /**
  26605. * Function called to display the loading screen
  26606. */
  26607. displayLoadingUI(): void;
  26608. /**
  26609. * Function called to hide the loading screen
  26610. */
  26611. hideLoadingUI(): void;
  26612. /**
  26613. * Gets or sets the text to display while loading
  26614. */
  26615. loadingUIText: string;
  26616. /**
  26617. * Gets or sets the color to use for the background
  26618. */
  26619. loadingUIBackgroundColor: string;
  26620. private _resizeLoadingUI;
  26621. }
  26622. }
  26623. declare module BABYLON {
  26624. /**
  26625. * Settings for finer control over video usage
  26626. */
  26627. export interface VideoTextureSettings {
  26628. /**
  26629. * Applies `autoplay` to video, if specified
  26630. */
  26631. autoPlay?: boolean;
  26632. /**
  26633. * Applies `loop` to video, if specified
  26634. */
  26635. loop?: boolean;
  26636. /**
  26637. * Automatically updates internal texture from video at every frame in the render loop
  26638. */
  26639. autoUpdateTexture: boolean;
  26640. /**
  26641. * Image src displayed during the video loading or until the user interacts with the video.
  26642. */
  26643. poster?: string;
  26644. }
  26645. /**
  26646. * If you want to display a video in your scene, this is the special texture for that.
  26647. * This special texture works similar to other textures, with the exception of a few parameters.
  26648. * @see https://doc.babylonjs.com/how_to/video_texture
  26649. */
  26650. export class VideoTexture extends Texture {
  26651. /**
  26652. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26653. */
  26654. readonly autoUpdateTexture: boolean;
  26655. /**
  26656. * The video instance used by the texture internally
  26657. */
  26658. readonly video: HTMLVideoElement;
  26659. private _onUserActionRequestedObservable;
  26660. /**
  26661. * Event triggerd when a dom action is required by the user to play the video.
  26662. * This happens due to recent changes in browser policies preventing video to auto start.
  26663. */
  26664. readonly onUserActionRequestedObservable: Observable<Texture>;
  26665. private _generateMipMaps;
  26666. private _engine;
  26667. private _stillImageCaptured;
  26668. private _displayingPosterTexture;
  26669. private _settings;
  26670. private _createInternalTextureOnEvent;
  26671. /**
  26672. * Creates a video texture.
  26673. * If you want to display a video in your scene, this is the special texture for that.
  26674. * This special texture works similar to other textures, with the exception of a few parameters.
  26675. * @see https://doc.babylonjs.com/how_to/video_texture
  26676. * @param name optional name, will detect from video source, if not defined
  26677. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26678. * @param scene is obviously the current scene.
  26679. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26680. * @param invertY is false by default but can be used to invert video on Y axis
  26681. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26682. * @param settings allows finer control over video usage
  26683. */
  26684. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26685. private _getName;
  26686. private _getVideo;
  26687. private _createInternalTexture;
  26688. private reset;
  26689. /**
  26690. * @hidden Internal method to initiate `update`.
  26691. */
  26692. _rebuild(): void;
  26693. /**
  26694. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26695. */
  26696. update(): void;
  26697. /**
  26698. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26699. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26700. */
  26701. updateTexture(isVisible: boolean): void;
  26702. protected _updateInternalTexture: () => void;
  26703. /**
  26704. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26705. * @param url New url.
  26706. */
  26707. updateURL(url: string): void;
  26708. /**
  26709. * Dispose the texture and release its associated resources.
  26710. */
  26711. dispose(): void;
  26712. /**
  26713. * Creates a video texture straight from a stream.
  26714. * @param scene Define the scene the texture should be created in
  26715. * @param stream Define the stream the texture should be created from
  26716. * @returns The created video texture as a promise
  26717. */
  26718. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26719. /**
  26720. * Creates a video texture straight from your WebCam video feed.
  26721. * @param scene Define the scene the texture should be created in
  26722. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26723. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26724. * @returns The created video texture as a promise
  26725. */
  26726. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26727. minWidth: number;
  26728. maxWidth: number;
  26729. minHeight: number;
  26730. maxHeight: number;
  26731. deviceId: string;
  26732. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26733. /**
  26734. * Creates a video texture straight from your WebCam video feed.
  26735. * @param scene Define the scene the texture should be created in
  26736. * @param onReady Define a callback to triggered once the texture will be ready
  26737. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26738. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26739. */
  26740. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26741. minWidth: number;
  26742. maxWidth: number;
  26743. minHeight: number;
  26744. maxHeight: number;
  26745. deviceId: string;
  26746. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26747. }
  26748. }
  26749. declare module BABYLON {
  26750. /**
  26751. * Interface for attribute information associated with buffer instanciation
  26752. */
  26753. export class InstancingAttributeInfo {
  26754. /**
  26755. * Index/offset of the attribute in the vertex shader
  26756. */
  26757. index: number;
  26758. /**
  26759. * size of the attribute, 1, 2, 3 or 4
  26760. */
  26761. attributeSize: number;
  26762. /**
  26763. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26764. * default is FLOAT
  26765. */
  26766. attribyteType: number;
  26767. /**
  26768. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26769. */
  26770. normalized: boolean;
  26771. /**
  26772. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26773. */
  26774. offset: number;
  26775. /**
  26776. * Name of the GLSL attribute, for debugging purpose only
  26777. */
  26778. attributeName: string;
  26779. }
  26780. /**
  26781. * Define options used to create a depth texture
  26782. */
  26783. export class DepthTextureCreationOptions {
  26784. /** Specifies whether or not a stencil should be allocated in the texture */
  26785. generateStencil?: boolean;
  26786. /** Specifies whether or not bilinear filtering is enable on the texture */
  26787. bilinearFiltering?: boolean;
  26788. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26789. comparisonFunction?: number;
  26790. /** Specifies if the created texture is a cube texture */
  26791. isCube?: boolean;
  26792. }
  26793. /**
  26794. * Class used to describe the capabilities of the engine relatively to the current browser
  26795. */
  26796. export class EngineCapabilities {
  26797. /** Maximum textures units per fragment shader */
  26798. maxTexturesImageUnits: number;
  26799. /** Maximum texture units per vertex shader */
  26800. maxVertexTextureImageUnits: number;
  26801. /** Maximum textures units in the entire pipeline */
  26802. maxCombinedTexturesImageUnits: number;
  26803. /** Maximum texture size */
  26804. maxTextureSize: number;
  26805. /** Maximum cube texture size */
  26806. maxCubemapTextureSize: number;
  26807. /** Maximum render texture size */
  26808. maxRenderTextureSize: number;
  26809. /** Maximum number of vertex attributes */
  26810. maxVertexAttribs: number;
  26811. /** Maximum number of varyings */
  26812. maxVaryingVectors: number;
  26813. /** Maximum number of uniforms per vertex shader */
  26814. maxVertexUniformVectors: number;
  26815. /** Maximum number of uniforms per fragment shader */
  26816. maxFragmentUniformVectors: number;
  26817. /** Defines if standard derivates (dx/dy) are supported */
  26818. standardDerivatives: boolean;
  26819. /** Defines if s3tc texture compression is supported */
  26820. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26821. /** Defines if pvrtc texture compression is supported */
  26822. pvrtc: any;
  26823. /** Defines if etc1 texture compression is supported */
  26824. etc1: any;
  26825. /** Defines if etc2 texture compression is supported */
  26826. etc2: any;
  26827. /** Defines if astc texture compression is supported */
  26828. astc: any;
  26829. /** Defines if float textures are supported */
  26830. textureFloat: boolean;
  26831. /** Defines if vertex array objects are supported */
  26832. vertexArrayObject: boolean;
  26833. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26834. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26835. /** Gets the maximum level of anisotropy supported */
  26836. maxAnisotropy: number;
  26837. /** Defines if instancing is supported */
  26838. instancedArrays: boolean;
  26839. /** Defines if 32 bits indices are supported */
  26840. uintIndices: boolean;
  26841. /** Defines if high precision shaders are supported */
  26842. highPrecisionShaderSupported: boolean;
  26843. /** Defines if depth reading in the fragment shader is supported */
  26844. fragmentDepthSupported: boolean;
  26845. /** Defines if float texture linear filtering is supported*/
  26846. textureFloatLinearFiltering: boolean;
  26847. /** Defines if rendering to float textures is supported */
  26848. textureFloatRender: boolean;
  26849. /** Defines if half float textures are supported*/
  26850. textureHalfFloat: boolean;
  26851. /** Defines if half float texture linear filtering is supported*/
  26852. textureHalfFloatLinearFiltering: boolean;
  26853. /** Defines if rendering to half float textures is supported */
  26854. textureHalfFloatRender: boolean;
  26855. /** Defines if textureLOD shader command is supported */
  26856. textureLOD: boolean;
  26857. /** Defines if draw buffers extension is supported */
  26858. drawBuffersExtension: boolean;
  26859. /** Defines if depth textures are supported */
  26860. depthTextureExtension: boolean;
  26861. /** Defines if float color buffer are supported */
  26862. colorBufferFloat: boolean;
  26863. /** Gets disjoint timer query extension (null if not supported) */
  26864. timerQuery: EXT_disjoint_timer_query;
  26865. /** Defines if timestamp can be used with timer query */
  26866. canUseTimestampForTimerQuery: boolean;
  26867. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26868. multiview: any;
  26869. /** Function used to let the system compiles shaders in background */
  26870. parallelShaderCompile: {
  26871. COMPLETION_STATUS_KHR: number;
  26872. };
  26873. }
  26874. /** Interface defining initialization parameters for Engine class */
  26875. export interface EngineOptions extends WebGLContextAttributes {
  26876. /**
  26877. * Defines if the engine should no exceed a specified device ratio
  26878. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26879. */
  26880. limitDeviceRatio?: number;
  26881. /**
  26882. * Defines if webvr should be enabled automatically
  26883. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26884. */
  26885. autoEnableWebVR?: boolean;
  26886. /**
  26887. * Defines if webgl2 should be turned off even if supported
  26888. * @see http://doc.babylonjs.com/features/webgl2
  26889. */
  26890. disableWebGL2Support?: boolean;
  26891. /**
  26892. * Defines if webaudio should be initialized as well
  26893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26894. */
  26895. audioEngine?: boolean;
  26896. /**
  26897. * Defines if animations should run using a deterministic lock step
  26898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26899. */
  26900. deterministicLockstep?: boolean;
  26901. /** Defines the maximum steps to use with deterministic lock step mode */
  26902. lockstepMaxSteps?: number;
  26903. /**
  26904. * Defines that engine should ignore context lost events
  26905. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26906. */
  26907. doNotHandleContextLost?: boolean;
  26908. /**
  26909. * Defines that engine should ignore modifying touch action attribute and style
  26910. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26911. */
  26912. doNotHandleTouchAction?: boolean;
  26913. /**
  26914. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26915. */
  26916. useHighPrecisionFloats?: boolean;
  26917. }
  26918. /**
  26919. * Defines the interface used by display changed events
  26920. */
  26921. export interface IDisplayChangedEventArgs {
  26922. /** Gets the vrDisplay object (if any) */
  26923. vrDisplay: Nullable<any>;
  26924. /** Gets a boolean indicating if webVR is supported */
  26925. vrSupported: boolean;
  26926. }
  26927. /**
  26928. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26929. */
  26930. export class Engine {
  26931. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26932. static ExceptionList: ({
  26933. key: string;
  26934. capture: string;
  26935. captureConstraint: number;
  26936. targets: string[];
  26937. } | {
  26938. key: string;
  26939. capture: null;
  26940. captureConstraint: null;
  26941. targets: string[];
  26942. })[];
  26943. /** Gets the list of created engines */
  26944. static readonly Instances: Engine[];
  26945. /**
  26946. * Gets the latest created engine
  26947. */
  26948. static readonly LastCreatedEngine: Nullable<Engine>;
  26949. /**
  26950. * Gets the latest created scene
  26951. */
  26952. static readonly LastCreatedScene: Nullable<Scene>;
  26953. /**
  26954. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26955. * @param flag defines which part of the materials must be marked as dirty
  26956. * @param predicate defines a predicate used to filter which materials should be affected
  26957. */
  26958. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26959. /**
  26960. * Hidden
  26961. */
  26962. static _TextureLoaders: IInternalTextureLoader[];
  26963. /** Defines that alpha blending is disabled */
  26964. static readonly ALPHA_DISABLE: number;
  26965. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26966. static readonly ALPHA_ADD: number;
  26967. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26968. static readonly ALPHA_COMBINE: number;
  26969. /** Defines that alpha blending to DEST - SRC * DEST */
  26970. static readonly ALPHA_SUBTRACT: number;
  26971. /** Defines that alpha blending to SRC * DEST */
  26972. static readonly ALPHA_MULTIPLY: number;
  26973. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26974. static readonly ALPHA_MAXIMIZED: number;
  26975. /** Defines that alpha blending to SRC + DEST */
  26976. static readonly ALPHA_ONEONE: number;
  26977. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26978. static readonly ALPHA_PREMULTIPLIED: number;
  26979. /**
  26980. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26981. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26982. */
  26983. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26984. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26985. static readonly ALPHA_INTERPOLATE: number;
  26986. /**
  26987. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26988. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26989. */
  26990. static readonly ALPHA_SCREENMODE: number;
  26991. /** Defines that the ressource is not delayed*/
  26992. static readonly DELAYLOADSTATE_NONE: number;
  26993. /** Defines that the ressource was successfully delay loaded */
  26994. static readonly DELAYLOADSTATE_LOADED: number;
  26995. /** Defines that the ressource is currently delay loading */
  26996. static readonly DELAYLOADSTATE_LOADING: number;
  26997. /** Defines that the ressource is delayed and has not started loading */
  26998. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26999. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27000. static readonly NEVER: number;
  27001. /** 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 */
  27002. static readonly ALWAYS: number;
  27003. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27004. static readonly LESS: number;
  27005. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27006. static readonly EQUAL: number;
  27007. /** 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 */
  27008. static readonly LEQUAL: number;
  27009. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27010. static readonly GREATER: number;
  27011. /** 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 */
  27012. static readonly GEQUAL: number;
  27013. /** 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 */
  27014. static readonly NOTEQUAL: number;
  27015. /** Passed to stencilOperation to specify that stencil value must be kept */
  27016. static readonly KEEP: number;
  27017. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27018. static readonly REPLACE: number;
  27019. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27020. static readonly INCR: number;
  27021. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27022. static readonly DECR: number;
  27023. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27024. static readonly INVERT: number;
  27025. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27026. static readonly INCR_WRAP: number;
  27027. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27028. static readonly DECR_WRAP: number;
  27029. /** Texture is not repeating outside of 0..1 UVs */
  27030. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27031. /** Texture is repeating outside of 0..1 UVs */
  27032. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27033. /** Texture is repeating and mirrored */
  27034. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27035. /** ALPHA */
  27036. static readonly TEXTUREFORMAT_ALPHA: number;
  27037. /** LUMINANCE */
  27038. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27039. /** LUMINANCE_ALPHA */
  27040. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27041. /** RGB */
  27042. static readonly TEXTUREFORMAT_RGB: number;
  27043. /** RGBA */
  27044. static readonly TEXTUREFORMAT_RGBA: number;
  27045. /** RED */
  27046. static readonly TEXTUREFORMAT_RED: number;
  27047. /** RED (2nd reference) */
  27048. static readonly TEXTUREFORMAT_R: number;
  27049. /** RG */
  27050. static readonly TEXTUREFORMAT_RG: number;
  27051. /** RED_INTEGER */
  27052. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27053. /** RED_INTEGER (2nd reference) */
  27054. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27055. /** RG_INTEGER */
  27056. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27057. /** RGB_INTEGER */
  27058. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27059. /** RGBA_INTEGER */
  27060. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27061. /** UNSIGNED_BYTE */
  27062. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27063. /** UNSIGNED_BYTE (2nd reference) */
  27064. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27065. /** FLOAT */
  27066. static readonly TEXTURETYPE_FLOAT: number;
  27067. /** HALF_FLOAT */
  27068. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27069. /** BYTE */
  27070. static readonly TEXTURETYPE_BYTE: number;
  27071. /** SHORT */
  27072. static readonly TEXTURETYPE_SHORT: number;
  27073. /** UNSIGNED_SHORT */
  27074. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27075. /** INT */
  27076. static readonly TEXTURETYPE_INT: number;
  27077. /** UNSIGNED_INT */
  27078. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27079. /** UNSIGNED_SHORT_4_4_4_4 */
  27080. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27081. /** UNSIGNED_SHORT_5_5_5_1 */
  27082. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27083. /** UNSIGNED_SHORT_5_6_5 */
  27084. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27085. /** UNSIGNED_INT_2_10_10_10_REV */
  27086. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27087. /** UNSIGNED_INT_24_8 */
  27088. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27089. /** UNSIGNED_INT_10F_11F_11F_REV */
  27090. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27091. /** UNSIGNED_INT_5_9_9_9_REV */
  27092. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27093. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27094. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27095. /** nearest is mag = nearest and min = nearest and mip = linear */
  27096. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27097. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27098. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27099. /** Trilinear is mag = linear and min = linear and mip = linear */
  27100. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27101. /** nearest is mag = nearest and min = nearest and mip = linear */
  27102. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27103. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27104. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27105. /** Trilinear is mag = linear and min = linear and mip = linear */
  27106. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27107. /** mag = nearest and min = nearest and mip = nearest */
  27108. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27109. /** mag = nearest and min = linear and mip = nearest */
  27110. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27111. /** mag = nearest and min = linear and mip = linear */
  27112. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27113. /** mag = nearest and min = linear and mip = none */
  27114. static readonly TEXTURE_NEAREST_LINEAR: number;
  27115. /** mag = nearest and min = nearest and mip = none */
  27116. static readonly TEXTURE_NEAREST_NEAREST: number;
  27117. /** mag = linear and min = nearest and mip = nearest */
  27118. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27119. /** mag = linear and min = nearest and mip = linear */
  27120. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27121. /** mag = linear and min = linear and mip = none */
  27122. static readonly TEXTURE_LINEAR_LINEAR: number;
  27123. /** mag = linear and min = nearest and mip = none */
  27124. static readonly TEXTURE_LINEAR_NEAREST: number;
  27125. /** Explicit coordinates mode */
  27126. static readonly TEXTURE_EXPLICIT_MODE: number;
  27127. /** Spherical coordinates mode */
  27128. static readonly TEXTURE_SPHERICAL_MODE: number;
  27129. /** Planar coordinates mode */
  27130. static readonly TEXTURE_PLANAR_MODE: number;
  27131. /** Cubic coordinates mode */
  27132. static readonly TEXTURE_CUBIC_MODE: number;
  27133. /** Projection coordinates mode */
  27134. static readonly TEXTURE_PROJECTION_MODE: number;
  27135. /** Skybox coordinates mode */
  27136. static readonly TEXTURE_SKYBOX_MODE: number;
  27137. /** Inverse Cubic coordinates mode */
  27138. static readonly TEXTURE_INVCUBIC_MODE: number;
  27139. /** Equirectangular coordinates mode */
  27140. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27141. /** Equirectangular Fixed coordinates mode */
  27142. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27143. /** Equirectangular Fixed Mirrored coordinates mode */
  27144. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27145. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27146. static readonly SCALEMODE_FLOOR: number;
  27147. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27148. static readonly SCALEMODE_NEAREST: number;
  27149. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27150. static readonly SCALEMODE_CEILING: number;
  27151. /**
  27152. * Returns the current npm package of the sdk
  27153. */
  27154. static readonly NpmPackage: string;
  27155. /**
  27156. * Returns the current version of the framework
  27157. */
  27158. static readonly Version: string;
  27159. /**
  27160. * Returns a string describing the current engine
  27161. */
  27162. readonly description: string;
  27163. /**
  27164. * Gets or sets the epsilon value used by collision engine
  27165. */
  27166. static CollisionsEpsilon: number;
  27167. /**
  27168. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27169. */
  27170. static ShadersRepository: string;
  27171. /**
  27172. * Method called to create the default loading screen.
  27173. * This can be overriden in your own app.
  27174. * @param canvas The rendering canvas element
  27175. * @returns The loading screen
  27176. */
  27177. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27178. /**
  27179. * Method called to create the default rescale post process on each engine.
  27180. */
  27181. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27182. /**
  27183. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27184. */
  27185. forcePOTTextures: boolean;
  27186. /**
  27187. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27188. */
  27189. isFullscreen: boolean;
  27190. /**
  27191. * Gets a boolean indicating if the pointer is currently locked
  27192. */
  27193. isPointerLock: boolean;
  27194. /**
  27195. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27196. */
  27197. cullBackFaces: boolean;
  27198. /**
  27199. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27200. */
  27201. renderEvenInBackground: boolean;
  27202. /**
  27203. * Gets or sets a boolean indicating that cache can be kept between frames
  27204. */
  27205. preventCacheWipeBetweenFrames: boolean;
  27206. /**
  27207. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27208. **/
  27209. enableOfflineSupport: boolean;
  27210. /**
  27211. * 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)
  27212. **/
  27213. disableManifestCheck: boolean;
  27214. /**
  27215. * Gets the list of created scenes
  27216. */
  27217. scenes: Scene[];
  27218. /**
  27219. * Event raised when a new scene is created
  27220. */
  27221. onNewSceneAddedObservable: Observable<Scene>;
  27222. /**
  27223. * Gets the list of created postprocesses
  27224. */
  27225. postProcesses: PostProcess[];
  27226. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27227. validateShaderPrograms: boolean;
  27228. /**
  27229. * Observable event triggered each time the rendering canvas is resized
  27230. */
  27231. onResizeObservable: Observable<Engine>;
  27232. /**
  27233. * Observable event triggered each time the canvas loses focus
  27234. */
  27235. onCanvasBlurObservable: Observable<Engine>;
  27236. /**
  27237. * Observable event triggered each time the canvas gains focus
  27238. */
  27239. onCanvasFocusObservable: Observable<Engine>;
  27240. /**
  27241. * Observable event triggered each time the canvas receives pointerout event
  27242. */
  27243. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27244. /**
  27245. * Observable event triggered before each texture is initialized
  27246. */
  27247. onBeforeTextureInitObservable: Observable<Texture>;
  27248. private _vrDisplay;
  27249. private _vrSupported;
  27250. private _oldSize;
  27251. private _oldHardwareScaleFactor;
  27252. private _vrExclusivePointerMode;
  27253. private _webVRInitPromise;
  27254. /**
  27255. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27256. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27257. */
  27258. readonly isInVRExclusivePointerMode: boolean;
  27259. /**
  27260. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27261. */
  27262. disableUniformBuffers: boolean;
  27263. /** @hidden */
  27264. _uniformBuffers: UniformBuffer[];
  27265. /**
  27266. * Gets a boolean indicating that the engine supports uniform buffers
  27267. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27268. */
  27269. readonly supportsUniformBuffers: boolean;
  27270. /**
  27271. * Observable raised when the engine begins a new frame
  27272. */
  27273. onBeginFrameObservable: Observable<Engine>;
  27274. /**
  27275. * If set, will be used to request the next animation frame for the render loop
  27276. */
  27277. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27278. /**
  27279. * Observable raised when the engine ends the current frame
  27280. */
  27281. onEndFrameObservable: Observable<Engine>;
  27282. /**
  27283. * Observable raised when the engine is about to compile a shader
  27284. */
  27285. onBeforeShaderCompilationObservable: Observable<Engine>;
  27286. /**
  27287. * Observable raised when the engine has jsut compiled a shader
  27288. */
  27289. onAfterShaderCompilationObservable: Observable<Engine>;
  27290. /** @hidden */
  27291. _gl: WebGLRenderingContext;
  27292. private _renderingCanvas;
  27293. private _windowIsBackground;
  27294. private _webGLVersion;
  27295. protected _highPrecisionShadersAllowed: boolean;
  27296. /** @hidden */
  27297. readonly _shouldUseHighPrecisionShader: boolean;
  27298. /**
  27299. * Gets a boolean indicating that only power of 2 textures are supported
  27300. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27301. */
  27302. readonly needPOTTextures: boolean;
  27303. /** @hidden */
  27304. _badOS: boolean;
  27305. /** @hidden */
  27306. _badDesktopOS: boolean;
  27307. /**
  27308. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27309. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27310. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27311. */
  27312. disableTextureBindingOptimization: boolean;
  27313. /**
  27314. * Gets the audio engine
  27315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27316. * @ignorenaming
  27317. */
  27318. static audioEngine: IAudioEngine;
  27319. /**
  27320. * Default AudioEngine factory responsible of creating the Audio Engine.
  27321. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27322. */
  27323. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27324. /**
  27325. * Default offline support factory responsible of creating a tool used to store data locally.
  27326. * By default, this will create a Database object if the workload has been embedded.
  27327. */
  27328. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27329. private _onFocus;
  27330. private _onBlur;
  27331. private _onCanvasPointerOut;
  27332. private _onCanvasBlur;
  27333. private _onCanvasFocus;
  27334. private _onFullscreenChange;
  27335. private _onPointerLockChange;
  27336. private _onVRDisplayPointerRestricted;
  27337. private _onVRDisplayPointerUnrestricted;
  27338. private _onVrDisplayConnect;
  27339. private _onVrDisplayDisconnect;
  27340. private _onVrDisplayPresentChange;
  27341. /**
  27342. * Observable signaled when VR display mode changes
  27343. */
  27344. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27345. /**
  27346. * Observable signaled when VR request present is complete
  27347. */
  27348. onVRRequestPresentComplete: Observable<boolean>;
  27349. /**
  27350. * Observable signaled when VR request present starts
  27351. */
  27352. onVRRequestPresentStart: Observable<Engine>;
  27353. private _hardwareScalingLevel;
  27354. /** @hidden */
  27355. protected _caps: EngineCapabilities;
  27356. private _pointerLockRequested;
  27357. private _isStencilEnable;
  27358. private _colorWrite;
  27359. private _loadingScreen;
  27360. /** @hidden */
  27361. _drawCalls: PerfCounter;
  27362. /** @hidden */
  27363. _textureCollisions: PerfCounter;
  27364. private _glVersion;
  27365. private _glRenderer;
  27366. private _glVendor;
  27367. private _videoTextureSupported;
  27368. private _renderingQueueLaunched;
  27369. private _activeRenderLoops;
  27370. private _deterministicLockstep;
  27371. private _lockstepMaxSteps;
  27372. /**
  27373. * Observable signaled when a context lost event is raised
  27374. */
  27375. onContextLostObservable: Observable<Engine>;
  27376. /**
  27377. * Observable signaled when a context restored event is raised
  27378. */
  27379. onContextRestoredObservable: Observable<Engine>;
  27380. private _onContextLost;
  27381. private _onContextRestored;
  27382. private _contextWasLost;
  27383. private _doNotHandleContextLost;
  27384. /**
  27385. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27387. */
  27388. doNotHandleContextLost: boolean;
  27389. private _performanceMonitor;
  27390. private _fps;
  27391. private _deltaTime;
  27392. /**
  27393. * Turn this value on if you want to pause FPS computation when in background
  27394. */
  27395. disablePerformanceMonitorInBackground: boolean;
  27396. /**
  27397. * Gets the performance monitor attached to this engine
  27398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27399. */
  27400. readonly performanceMonitor: PerformanceMonitor;
  27401. /** @hidden */
  27402. protected _depthCullingState: _DepthCullingState;
  27403. /** @hidden */
  27404. protected _stencilState: _StencilState;
  27405. /** @hidden */
  27406. protected _alphaState: _AlphaState;
  27407. /** @hidden */
  27408. protected _alphaMode: number;
  27409. protected _internalTexturesCache: InternalTexture[];
  27410. /** @hidden */
  27411. protected _activeChannel: number;
  27412. private _currentTextureChannel;
  27413. /** @hidden */
  27414. protected _boundTexturesCache: {
  27415. [key: string]: Nullable<InternalTexture>;
  27416. };
  27417. /** @hidden */
  27418. protected _currentEffect: Nullable<Effect>;
  27419. /** @hidden */
  27420. protected _currentProgram: Nullable<WebGLProgram>;
  27421. private _compiledEffects;
  27422. private _vertexAttribArraysEnabled;
  27423. /** @hidden */
  27424. protected _cachedViewport: Nullable<Viewport>;
  27425. private _cachedVertexArrayObject;
  27426. /** @hidden */
  27427. protected _cachedVertexBuffers: any;
  27428. /** @hidden */
  27429. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27430. /** @hidden */
  27431. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27432. /** @hidden */
  27433. protected _currentRenderTarget: Nullable<InternalTexture>;
  27434. private _uintIndicesCurrentlySet;
  27435. private _currentBoundBuffer;
  27436. /** @hidden */
  27437. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27438. private _currentBufferPointers;
  27439. private _currentInstanceLocations;
  27440. private _currentInstanceBuffers;
  27441. private _textureUnits;
  27442. private _firstBoundInternalTextureTracker;
  27443. private _lastBoundInternalTextureTracker;
  27444. private _workingCanvas;
  27445. private _workingContext;
  27446. private _rescalePostProcess;
  27447. private _dummyFramebuffer;
  27448. private _externalData;
  27449. private _bindedRenderFunction;
  27450. private _vaoRecordInProgress;
  27451. private _mustWipeVertexAttributes;
  27452. private _emptyTexture;
  27453. private _emptyCubeTexture;
  27454. private _emptyTexture3D;
  27455. /** @hidden */
  27456. _frameHandler: number;
  27457. private _nextFreeTextureSlots;
  27458. private _maxSimultaneousTextures;
  27459. private _activeRequests;
  27460. private _texturesSupported;
  27461. private _textureFormatInUse;
  27462. /**
  27463. * Gets the list of texture formats supported
  27464. */
  27465. readonly texturesSupported: Array<string>;
  27466. /**
  27467. * Gets the list of texture formats in use
  27468. */
  27469. readonly textureFormatInUse: Nullable<string>;
  27470. /**
  27471. * Gets the current viewport
  27472. */
  27473. readonly currentViewport: Nullable<Viewport>;
  27474. /**
  27475. * Gets the default empty texture
  27476. */
  27477. readonly emptyTexture: InternalTexture;
  27478. /**
  27479. * Gets the default empty 3D texture
  27480. */
  27481. readonly emptyTexture3D: InternalTexture;
  27482. /**
  27483. * Gets the default empty cube texture
  27484. */
  27485. readonly emptyCubeTexture: InternalTexture;
  27486. /**
  27487. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27488. */
  27489. readonly premultipliedAlpha: boolean;
  27490. /**
  27491. * Creates a new engine
  27492. * @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
  27493. * @param antialias defines enable antialiasing (default: false)
  27494. * @param options defines further options to be sent to the getContext() function
  27495. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27496. */
  27497. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27498. private _disableTouchAction;
  27499. private _rebuildInternalTextures;
  27500. private _rebuildEffects;
  27501. /**
  27502. * Gets a boolean indicating if all created effects are ready
  27503. * @returns true if all effects are ready
  27504. */
  27505. areAllEffectsReady(): boolean;
  27506. private _rebuildBuffers;
  27507. private _initGLContext;
  27508. /**
  27509. * Gets version of the current webGL context
  27510. */
  27511. readonly webGLVersion: number;
  27512. /**
  27513. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27514. */
  27515. readonly isStencilEnable: boolean;
  27516. private _prepareWorkingCanvas;
  27517. /**
  27518. * Reset the texture cache to empty state
  27519. */
  27520. resetTextureCache(): void;
  27521. /**
  27522. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27524. * @returns true if engine is in deterministic lock step mode
  27525. */
  27526. isDeterministicLockStep(): boolean;
  27527. /**
  27528. * Gets the max steps when engine is running in deterministic lock step
  27529. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27530. * @returns the max steps
  27531. */
  27532. getLockstepMaxSteps(): number;
  27533. /**
  27534. * Gets an object containing information about the current webGL context
  27535. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27536. */
  27537. getGlInfo(): {
  27538. vendor: string;
  27539. renderer: string;
  27540. version: string;
  27541. };
  27542. /**
  27543. * Gets current aspect ratio
  27544. * @param camera defines the camera to use to get the aspect ratio
  27545. * @param useScreen defines if screen size must be used (or the current render target if any)
  27546. * @returns a number defining the aspect ratio
  27547. */
  27548. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27549. /**
  27550. * Gets current screen aspect ratio
  27551. * @returns a number defining the aspect ratio
  27552. */
  27553. getScreenAspectRatio(): number;
  27554. /**
  27555. * Gets the current render width
  27556. * @param useScreen defines if screen size must be used (or the current render target if any)
  27557. * @returns a number defining the current render width
  27558. */
  27559. getRenderWidth(useScreen?: boolean): number;
  27560. /**
  27561. * Gets the current render height
  27562. * @param useScreen defines if screen size must be used (or the current render target if any)
  27563. * @returns a number defining the current render height
  27564. */
  27565. getRenderHeight(useScreen?: boolean): number;
  27566. /**
  27567. * Gets the HTML canvas attached with the current webGL context
  27568. * @returns a HTML canvas
  27569. */
  27570. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27571. /**
  27572. * Gets the client rect of the HTML canvas attached with the current webGL context
  27573. * @returns a client rectanglee
  27574. */
  27575. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27576. /**
  27577. * Defines the hardware scaling level.
  27578. * By default the hardware scaling level is computed from the window device ratio.
  27579. * 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.
  27580. * @param level defines the level to use
  27581. */
  27582. setHardwareScalingLevel(level: number): void;
  27583. /**
  27584. * Gets the current hardware scaling level.
  27585. * By default the hardware scaling level is computed from the window device ratio.
  27586. * 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.
  27587. * @returns a number indicating the current hardware scaling level
  27588. */
  27589. getHardwareScalingLevel(): number;
  27590. /**
  27591. * Gets the list of loaded textures
  27592. * @returns an array containing all loaded textures
  27593. */
  27594. getLoadedTexturesCache(): InternalTexture[];
  27595. /**
  27596. * Gets the object containing all engine capabilities
  27597. * @returns the EngineCapabilities object
  27598. */
  27599. getCaps(): EngineCapabilities;
  27600. /**
  27601. * Gets the current depth function
  27602. * @returns a number defining the depth function
  27603. */
  27604. getDepthFunction(): Nullable<number>;
  27605. /**
  27606. * Sets the current depth function
  27607. * @param depthFunc defines the function to use
  27608. */
  27609. setDepthFunction(depthFunc: number): void;
  27610. /**
  27611. * Sets the current depth function to GREATER
  27612. */
  27613. setDepthFunctionToGreater(): void;
  27614. /**
  27615. * Sets the current depth function to GEQUAL
  27616. */
  27617. setDepthFunctionToGreaterOrEqual(): void;
  27618. /**
  27619. * Sets the current depth function to LESS
  27620. */
  27621. setDepthFunctionToLess(): void;
  27622. private _cachedStencilBuffer;
  27623. private _cachedStencilFunction;
  27624. private _cachedStencilMask;
  27625. private _cachedStencilOperationPass;
  27626. private _cachedStencilOperationFail;
  27627. private _cachedStencilOperationDepthFail;
  27628. private _cachedStencilReference;
  27629. /**
  27630. * Caches the the state of the stencil buffer
  27631. */
  27632. cacheStencilState(): void;
  27633. /**
  27634. * Restores the state of the stencil buffer
  27635. */
  27636. restoreStencilState(): void;
  27637. /**
  27638. * Sets the current depth function to LEQUAL
  27639. */
  27640. setDepthFunctionToLessOrEqual(): void;
  27641. /**
  27642. * Gets a boolean indicating if stencil buffer is enabled
  27643. * @returns the current stencil buffer state
  27644. */
  27645. getStencilBuffer(): boolean;
  27646. /**
  27647. * Enable or disable the stencil buffer
  27648. * @param enable defines if the stencil buffer must be enabled or disabled
  27649. */
  27650. setStencilBuffer(enable: boolean): void;
  27651. /**
  27652. * Gets the current stencil mask
  27653. * @returns a number defining the new stencil mask to use
  27654. */
  27655. getStencilMask(): number;
  27656. /**
  27657. * Sets the current stencil mask
  27658. * @param mask defines the new stencil mask to use
  27659. */
  27660. setStencilMask(mask: number): void;
  27661. /**
  27662. * Gets the current stencil function
  27663. * @returns a number defining the stencil function to use
  27664. */
  27665. getStencilFunction(): number;
  27666. /**
  27667. * Gets the current stencil reference value
  27668. * @returns a number defining the stencil reference value to use
  27669. */
  27670. getStencilFunctionReference(): number;
  27671. /**
  27672. * Gets the current stencil mask
  27673. * @returns a number defining the stencil mask to use
  27674. */
  27675. getStencilFunctionMask(): number;
  27676. /**
  27677. * Sets the current stencil function
  27678. * @param stencilFunc defines the new stencil function to use
  27679. */
  27680. setStencilFunction(stencilFunc: number): void;
  27681. /**
  27682. * Sets the current stencil reference
  27683. * @param reference defines the new stencil reference to use
  27684. */
  27685. setStencilFunctionReference(reference: number): void;
  27686. /**
  27687. * Sets the current stencil mask
  27688. * @param mask defines the new stencil mask to use
  27689. */
  27690. setStencilFunctionMask(mask: number): void;
  27691. /**
  27692. * Gets the current stencil operation when stencil fails
  27693. * @returns a number defining stencil operation to use when stencil fails
  27694. */
  27695. getStencilOperationFail(): number;
  27696. /**
  27697. * Gets the current stencil operation when depth fails
  27698. * @returns a number defining stencil operation to use when depth fails
  27699. */
  27700. getStencilOperationDepthFail(): number;
  27701. /**
  27702. * Gets the current stencil operation when stencil passes
  27703. * @returns a number defining stencil operation to use when stencil passes
  27704. */
  27705. getStencilOperationPass(): number;
  27706. /**
  27707. * Sets the stencil operation to use when stencil fails
  27708. * @param operation defines the stencil operation to use when stencil fails
  27709. */
  27710. setStencilOperationFail(operation: number): void;
  27711. /**
  27712. * Sets the stencil operation to use when depth fails
  27713. * @param operation defines the stencil operation to use when depth fails
  27714. */
  27715. setStencilOperationDepthFail(operation: number): void;
  27716. /**
  27717. * Sets the stencil operation to use when stencil passes
  27718. * @param operation defines the stencil operation to use when stencil passes
  27719. */
  27720. setStencilOperationPass(operation: number): void;
  27721. /**
  27722. * Sets a boolean indicating if the dithering state is enabled or disabled
  27723. * @param value defines the dithering state
  27724. */
  27725. setDitheringState(value: boolean): void;
  27726. /**
  27727. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27728. * @param value defines the rasterizer state
  27729. */
  27730. setRasterizerState(value: boolean): void;
  27731. /**
  27732. * stop executing a render loop function and remove it from the execution array
  27733. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27734. */
  27735. stopRenderLoop(renderFunction?: () => void): void;
  27736. /** @hidden */
  27737. _renderLoop(): void;
  27738. /**
  27739. * Register and execute a render loop. The engine can have more than one render function
  27740. * @param renderFunction defines the function to continuously execute
  27741. */
  27742. runRenderLoop(renderFunction: () => void): void;
  27743. /**
  27744. * Toggle full screen mode
  27745. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27746. */
  27747. switchFullscreen(requestPointerLock: boolean): void;
  27748. /**
  27749. * Enters full screen mode
  27750. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27751. */
  27752. enterFullscreen(requestPointerLock: boolean): void;
  27753. /**
  27754. * Exits full screen mode
  27755. */
  27756. exitFullscreen(): void;
  27757. /**
  27758. * Clear the current render buffer or the current render target (if any is set up)
  27759. * @param color defines the color to use
  27760. * @param backBuffer defines if the back buffer must be cleared
  27761. * @param depth defines if the depth buffer must be cleared
  27762. * @param stencil defines if the stencil buffer must be cleared
  27763. */
  27764. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27765. /**
  27766. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27767. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27768. * @param y defines the y-coordinate of the corner of the clear rectangle
  27769. * @param width defines the width of the clear rectangle
  27770. * @param height defines the height of the clear rectangle
  27771. * @param clearColor defines the clear color
  27772. */
  27773. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27774. /**
  27775. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27776. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27777. * @param y defines the y-coordinate of the corner of the clear rectangle
  27778. * @param width defines the width of the clear rectangle
  27779. * @param height defines the height of the clear rectangle
  27780. */
  27781. enableScissor(x: number, y: number, width: number, height: number): void;
  27782. /**
  27783. * Disable previously set scissor test rectangle
  27784. */
  27785. disableScissor(): void;
  27786. private _viewportCached;
  27787. /** @hidden */
  27788. _viewport(x: number, y: number, width: number, height: number): void;
  27789. /**
  27790. * Set the WebGL's viewport
  27791. * @param viewport defines the viewport element to be used
  27792. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27793. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27794. */
  27795. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27796. /**
  27797. * Directly set the WebGL Viewport
  27798. * @param x defines the x coordinate of the viewport (in screen space)
  27799. * @param y defines the y coordinate of the viewport (in screen space)
  27800. * @param width defines the width of the viewport (in screen space)
  27801. * @param height defines the height of the viewport (in screen space)
  27802. * @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
  27803. */
  27804. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27805. /**
  27806. * Begin a new frame
  27807. */
  27808. beginFrame(): void;
  27809. /**
  27810. * Enf the current frame
  27811. */
  27812. endFrame(): void;
  27813. /**
  27814. * Resize the view according to the canvas' size
  27815. */
  27816. resize(): void;
  27817. /**
  27818. * Force a specific size of the canvas
  27819. * @param width defines the new canvas' width
  27820. * @param height defines the new canvas' height
  27821. */
  27822. setSize(width: number, height: number): void;
  27823. /**
  27824. * Gets a boolean indicating if a webVR device was detected
  27825. * @returns true if a webVR device was detected
  27826. */
  27827. isVRDevicePresent(): boolean;
  27828. /**
  27829. * Gets the current webVR device
  27830. * @returns the current webVR device (or null)
  27831. */
  27832. getVRDevice(): any;
  27833. /**
  27834. * Initializes a webVR display and starts listening to display change events
  27835. * The onVRDisplayChangedObservable will be notified upon these changes
  27836. * @returns The onVRDisplayChangedObservable
  27837. */
  27838. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27839. /**
  27840. * Initializes a webVR display and starts listening to display change events
  27841. * The onVRDisplayChangedObservable will be notified upon these changes
  27842. * @returns A promise containing a VRDisplay and if vr is supported
  27843. */
  27844. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27845. /**
  27846. * Call this function to switch to webVR mode
  27847. * Will do nothing if webVR is not supported or if there is no webVR device
  27848. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27849. */
  27850. enableVR(): void;
  27851. /**
  27852. * Call this function to leave webVR mode
  27853. * Will do nothing if webVR is not supported or if there is no webVR device
  27854. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27855. */
  27856. disableVR(): void;
  27857. private _onVRFullScreenTriggered;
  27858. private _getVRDisplaysAsync;
  27859. /**
  27860. * Binds the frame buffer to the specified texture.
  27861. * @param texture The texture to render to or null for the default canvas
  27862. * @param faceIndex The face of the texture to render to in case of cube texture
  27863. * @param requiredWidth The width of the target to render to
  27864. * @param requiredHeight The height of the target to render to
  27865. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27866. * @param depthStencilTexture The depth stencil texture to use to render
  27867. * @param lodLevel defines le lod level to bind to the frame buffer
  27868. */
  27869. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27870. private bindUnboundFramebuffer;
  27871. /**
  27872. * Unbind the current render target texture from the webGL context
  27873. * @param texture defines the render target texture to unbind
  27874. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27875. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27876. */
  27877. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27878. /**
  27879. * Unbind a list of render target textures from the webGL context
  27880. * This is used only when drawBuffer extension or webGL2 are active
  27881. * @param textures defines the render target textures to unbind
  27882. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27883. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27884. */
  27885. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27886. /**
  27887. * Force the mipmap generation for the given render target texture
  27888. * @param texture defines the render target texture to use
  27889. */
  27890. generateMipMapsForCubemap(texture: InternalTexture): void;
  27891. /**
  27892. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27893. */
  27894. flushFramebuffer(): void;
  27895. /**
  27896. * Unbind the current render target and bind the default framebuffer
  27897. */
  27898. restoreDefaultFramebuffer(): void;
  27899. /**
  27900. * Create an uniform buffer
  27901. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27902. * @param elements defines the content of the uniform buffer
  27903. * @returns the webGL uniform buffer
  27904. */
  27905. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27906. /**
  27907. * Create a dynamic uniform buffer
  27908. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27909. * @param elements defines the content of the uniform buffer
  27910. * @returns the webGL uniform buffer
  27911. */
  27912. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27913. /**
  27914. * Update an existing uniform buffer
  27915. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27916. * @param uniformBuffer defines the target uniform buffer
  27917. * @param elements defines the content to update
  27918. * @param offset defines the offset in the uniform buffer where update should start
  27919. * @param count defines the size of the data to update
  27920. */
  27921. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27922. private _resetVertexBufferBinding;
  27923. /**
  27924. * Creates a vertex buffer
  27925. * @param data the data for the vertex buffer
  27926. * @returns the new WebGL static buffer
  27927. */
  27928. createVertexBuffer(data: DataArray): WebGLBuffer;
  27929. /**
  27930. * Creates a dynamic vertex buffer
  27931. * @param data the data for the dynamic vertex buffer
  27932. * @returns the new WebGL dynamic buffer
  27933. */
  27934. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27935. /**
  27936. * Update a dynamic index buffer
  27937. * @param indexBuffer defines the target index buffer
  27938. * @param indices defines the data to update
  27939. * @param offset defines the offset in the target index buffer where update should start
  27940. */
  27941. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27942. /**
  27943. * Updates a dynamic vertex buffer.
  27944. * @param vertexBuffer the vertex buffer to update
  27945. * @param data the data used to update the vertex buffer
  27946. * @param byteOffset the byte offset of the data
  27947. * @param byteLength the byte length of the data
  27948. */
  27949. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27950. private _resetIndexBufferBinding;
  27951. /**
  27952. * Creates a new index buffer
  27953. * @param indices defines the content of the index buffer
  27954. * @param updatable defines if the index buffer must be updatable
  27955. * @returns a new webGL buffer
  27956. */
  27957. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27958. /**
  27959. * Bind a webGL buffer to the webGL context
  27960. * @param buffer defines the buffer to bind
  27961. */
  27962. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27963. /**
  27964. * Bind an uniform buffer to the current webGL context
  27965. * @param buffer defines the buffer to bind
  27966. */
  27967. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27968. /**
  27969. * Bind a buffer to the current webGL context at a given location
  27970. * @param buffer defines the buffer to bind
  27971. * @param location defines the index where to bind the buffer
  27972. */
  27973. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27974. /**
  27975. * Bind a specific block at a given index in a specific shader program
  27976. * @param shaderProgram defines the shader program
  27977. * @param blockName defines the block name
  27978. * @param index defines the index where to bind the block
  27979. */
  27980. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27981. private bindIndexBuffer;
  27982. private bindBuffer;
  27983. /**
  27984. * update the bound buffer with the given data
  27985. * @param data defines the data to update
  27986. */
  27987. updateArrayBuffer(data: Float32Array): void;
  27988. private _vertexAttribPointer;
  27989. private _bindIndexBufferWithCache;
  27990. private _bindVertexBuffersAttributes;
  27991. /**
  27992. * Records a vertex array object
  27993. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27994. * @param vertexBuffers defines the list of vertex buffers to store
  27995. * @param indexBuffer defines the index buffer to store
  27996. * @param effect defines the effect to store
  27997. * @returns the new vertex array object
  27998. */
  27999. recordVertexArrayObject(vertexBuffers: {
  28000. [key: string]: VertexBuffer;
  28001. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28002. /**
  28003. * Bind a specific vertex array object
  28004. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28005. * @param vertexArrayObject defines the vertex array object to bind
  28006. * @param indexBuffer defines the index buffer to bind
  28007. */
  28008. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28009. /**
  28010. * Bind webGl buffers directly to the webGL context
  28011. * @param vertexBuffer defines the vertex buffer to bind
  28012. * @param indexBuffer defines the index buffer to bind
  28013. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28014. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28015. * @param effect defines the effect associated with the vertex buffer
  28016. */
  28017. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28018. private _unbindVertexArrayObject;
  28019. /**
  28020. * Bind a list of vertex buffers to the webGL context
  28021. * @param vertexBuffers defines the list of vertex buffers to bind
  28022. * @param indexBuffer defines the index buffer to bind
  28023. * @param effect defines the effect associated with the vertex buffers
  28024. */
  28025. bindBuffers(vertexBuffers: {
  28026. [key: string]: Nullable<VertexBuffer>;
  28027. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28028. /**
  28029. * Unbind all instance attributes
  28030. */
  28031. unbindInstanceAttributes(): void;
  28032. /**
  28033. * Release and free the memory of a vertex array object
  28034. * @param vao defines the vertex array object to delete
  28035. */
  28036. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28037. /** @hidden */
  28038. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28039. /**
  28040. * Creates a webGL buffer to use with instanciation
  28041. * @param capacity defines the size of the buffer
  28042. * @returns the webGL buffer
  28043. */
  28044. createInstancesBuffer(capacity: number): WebGLBuffer;
  28045. /**
  28046. * Delete a webGL buffer used with instanciation
  28047. * @param buffer defines the webGL buffer to delete
  28048. */
  28049. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28050. /**
  28051. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28052. * @param instancesBuffer defines the webGL buffer to update and bind
  28053. * @param data defines the data to store in the buffer
  28054. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28055. */
  28056. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28057. /**
  28058. * Apply all cached states (depth, culling, stencil and alpha)
  28059. */
  28060. applyStates(): void;
  28061. /**
  28062. * Send a draw order
  28063. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28064. * @param indexStart defines the starting index
  28065. * @param indexCount defines the number of index to draw
  28066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28067. */
  28068. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28069. /**
  28070. * Draw a list of points
  28071. * @param verticesStart defines the index of first vertex to draw
  28072. * @param verticesCount defines the count of vertices to draw
  28073. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28074. */
  28075. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28076. /**
  28077. * Draw a list of unindexed primitives
  28078. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28079. * @param verticesStart defines the index of first vertex to draw
  28080. * @param verticesCount defines the count of vertices to draw
  28081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28082. */
  28083. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28084. /**
  28085. * Draw a list of indexed primitives
  28086. * @param fillMode defines the primitive to use
  28087. * @param indexStart defines the starting index
  28088. * @param indexCount defines the number of index to draw
  28089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28090. */
  28091. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28092. /**
  28093. * Draw a list of unindexed primitives
  28094. * @param fillMode defines the primitive to use
  28095. * @param verticesStart defines the index of first vertex to draw
  28096. * @param verticesCount defines the count of vertices to draw
  28097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28098. */
  28099. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28100. private _drawMode;
  28101. /** @hidden */
  28102. _releaseEffect(effect: Effect): void;
  28103. /** @hidden */
  28104. _deleteProgram(program: WebGLProgram): void;
  28105. /**
  28106. * Create a new effect (used to store vertex/fragment shaders)
  28107. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28108. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28109. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28110. * @param samplers defines an array of string used to represent textures
  28111. * @param defines defines the string containing the defines to use to compile the shaders
  28112. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28113. * @param onCompiled defines a function to call when the effect creation is successful
  28114. * @param onError defines a function to call when the effect creation has failed
  28115. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28116. * @returns the new Effect
  28117. */
  28118. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28119. private _compileShader;
  28120. private _compileRawShader;
  28121. /**
  28122. * Directly creates a webGL program
  28123. * @param vertexCode defines the vertex shader code to use
  28124. * @param fragmentCode defines the fragment shader code to use
  28125. * @param context defines the webGL context to use (if not set, the current one will be used)
  28126. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28127. * @returns the new webGL program
  28128. */
  28129. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28130. /**
  28131. * Creates a webGL program
  28132. * @param vertexCode defines the vertex shader code to use
  28133. * @param fragmentCode defines the fragment shader code to use
  28134. * @param defines defines the string containing the defines to use to compile the shaders
  28135. * @param context defines the webGL context to use (if not set, the current one will be used)
  28136. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28137. * @returns the new webGL program
  28138. */
  28139. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28140. private _createShaderProgram;
  28141. private _finalizeProgram;
  28142. /** @hidden */
  28143. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28144. /** @hidden */
  28145. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28146. /**
  28147. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28148. * @param shaderProgram defines the webGL program to use
  28149. * @param uniformsNames defines the list of uniform names
  28150. * @returns an array of webGL uniform locations
  28151. */
  28152. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28153. /**
  28154. * Gets the lsit of active attributes for a given webGL program
  28155. * @param shaderProgram defines the webGL program to use
  28156. * @param attributesNames defines the list of attribute names to get
  28157. * @returns an array of indices indicating the offset of each attribute
  28158. */
  28159. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28160. /**
  28161. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28162. * @param effect defines the effect to activate
  28163. */
  28164. enableEffect(effect: Nullable<Effect>): void;
  28165. /**
  28166. * Set the value of an uniform to an array of int32
  28167. * @param uniform defines the webGL uniform location where to store the value
  28168. * @param array defines the array of int32 to store
  28169. */
  28170. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28171. /**
  28172. * Set the value of an uniform to an array of int32 (stored as vec2)
  28173. * @param uniform defines the webGL uniform location where to store the value
  28174. * @param array defines the array of int32 to store
  28175. */
  28176. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28177. /**
  28178. * Set the value of an uniform to an array of int32 (stored as vec3)
  28179. * @param uniform defines the webGL uniform location where to store the value
  28180. * @param array defines the array of int32 to store
  28181. */
  28182. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28183. /**
  28184. * Set the value of an uniform to an array of int32 (stored as vec4)
  28185. * @param uniform defines the webGL uniform location where to store the value
  28186. * @param array defines the array of int32 to store
  28187. */
  28188. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28189. /**
  28190. * Set the value of an uniform to an array of float32
  28191. * @param uniform defines the webGL uniform location where to store the value
  28192. * @param array defines the array of float32 to store
  28193. */
  28194. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28195. /**
  28196. * Set the value of an uniform to an array of float32 (stored as vec2)
  28197. * @param uniform defines the webGL uniform location where to store the value
  28198. * @param array defines the array of float32 to store
  28199. */
  28200. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28201. /**
  28202. * Set the value of an uniform to an array of float32 (stored as vec3)
  28203. * @param uniform defines the webGL uniform location where to store the value
  28204. * @param array defines the array of float32 to store
  28205. */
  28206. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28207. /**
  28208. * Set the value of an uniform to an array of float32 (stored as vec4)
  28209. * @param uniform defines the webGL uniform location where to store the value
  28210. * @param array defines the array of float32 to store
  28211. */
  28212. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28213. /**
  28214. * Set the value of an uniform to an array of number
  28215. * @param uniform defines the webGL uniform location where to store the value
  28216. * @param array defines the array of number to store
  28217. */
  28218. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28219. /**
  28220. * Set the value of an uniform to an array of number (stored as vec2)
  28221. * @param uniform defines the webGL uniform location where to store the value
  28222. * @param array defines the array of number to store
  28223. */
  28224. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28225. /**
  28226. * Set the value of an uniform to an array of number (stored as vec3)
  28227. * @param uniform defines the webGL uniform location where to store the value
  28228. * @param array defines the array of number to store
  28229. */
  28230. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28231. /**
  28232. * Set the value of an uniform to an array of number (stored as vec4)
  28233. * @param uniform defines the webGL uniform location where to store the value
  28234. * @param array defines the array of number to store
  28235. */
  28236. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28237. /**
  28238. * Set the value of an uniform to an array of float32 (stored as matrices)
  28239. * @param uniform defines the webGL uniform location where to store the value
  28240. * @param matrices defines the array of float32 to store
  28241. */
  28242. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28243. /**
  28244. * Set the value of an uniform to a matrix
  28245. * @param uniform defines the webGL uniform location where to store the value
  28246. * @param matrix defines the matrix to store
  28247. */
  28248. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28249. /**
  28250. * Set the value of an uniform to a matrix (3x3)
  28251. * @param uniform defines the webGL uniform location where to store the value
  28252. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28253. */
  28254. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28255. /**
  28256. * Set the value of an uniform to a matrix (2x2)
  28257. * @param uniform defines the webGL uniform location where to store the value
  28258. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28259. */
  28260. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28261. /**
  28262. * Set the value of an uniform to a number (int)
  28263. * @param uniform defines the webGL uniform location where to store the value
  28264. * @param value defines the int number to store
  28265. */
  28266. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28267. /**
  28268. * Set the value of an uniform to a number (float)
  28269. * @param uniform defines the webGL uniform location where to store the value
  28270. * @param value defines the float number to store
  28271. */
  28272. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28273. /**
  28274. * Set the value of an uniform to a vec2
  28275. * @param uniform defines the webGL uniform location where to store the value
  28276. * @param x defines the 1st component of the value
  28277. * @param y defines the 2nd component of the value
  28278. */
  28279. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28280. /**
  28281. * Set the value of an uniform to a vec3
  28282. * @param uniform defines the webGL uniform location where to store the value
  28283. * @param x defines the 1st component of the value
  28284. * @param y defines the 2nd component of the value
  28285. * @param z defines the 3rd component of the value
  28286. */
  28287. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28288. /**
  28289. * Set the value of an uniform to a boolean
  28290. * @param uniform defines the webGL uniform location where to store the value
  28291. * @param bool defines the boolean to store
  28292. */
  28293. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28294. /**
  28295. * Set the value of an uniform to a vec4
  28296. * @param uniform defines the webGL uniform location where to store the value
  28297. * @param x defines the 1st component of the value
  28298. * @param y defines the 2nd component of the value
  28299. * @param z defines the 3rd component of the value
  28300. * @param w defines the 4th component of the value
  28301. */
  28302. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28303. /**
  28304. * Set the value of an uniform to a Color3
  28305. * @param uniform defines the webGL uniform location where to store the value
  28306. * @param color3 defines the color to store
  28307. */
  28308. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28309. /**
  28310. * Set the value of an uniform to a Color3 and an alpha value
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param color3 defines the color to store
  28313. * @param alpha defines the alpha component to store
  28314. */
  28315. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28316. /**
  28317. * Sets a Color4 on a uniform variable
  28318. * @param uniform defines the uniform location
  28319. * @param color4 defines the value to be set
  28320. */
  28321. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28322. /**
  28323. * Set various states to the webGL context
  28324. * @param culling defines backface culling state
  28325. * @param zOffset defines the value to apply to zOffset (0 by default)
  28326. * @param force defines if states must be applied even if cache is up to date
  28327. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28328. */
  28329. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28330. /**
  28331. * Set the z offset to apply to current rendering
  28332. * @param value defines the offset to apply
  28333. */
  28334. setZOffset(value: number): void;
  28335. /**
  28336. * Gets the current value of the zOffset
  28337. * @returns the current zOffset state
  28338. */
  28339. getZOffset(): number;
  28340. /**
  28341. * Enable or disable depth buffering
  28342. * @param enable defines the state to set
  28343. */
  28344. setDepthBuffer(enable: boolean): void;
  28345. /**
  28346. * Gets a boolean indicating if depth writing is enabled
  28347. * @returns the current depth writing state
  28348. */
  28349. getDepthWrite(): boolean;
  28350. /**
  28351. * Enable or disable depth writing
  28352. * @param enable defines the state to set
  28353. */
  28354. setDepthWrite(enable: boolean): void;
  28355. /**
  28356. * Enable or disable color writing
  28357. * @param enable defines the state to set
  28358. */
  28359. setColorWrite(enable: boolean): void;
  28360. /**
  28361. * Gets a boolean indicating if color writing is enabled
  28362. * @returns the current color writing state
  28363. */
  28364. getColorWrite(): boolean;
  28365. /**
  28366. * Sets alpha constants used by some alpha blending modes
  28367. * @param r defines the red component
  28368. * @param g defines the green component
  28369. * @param b defines the blue component
  28370. * @param a defines the alpha component
  28371. */
  28372. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28373. /**
  28374. * Sets the current alpha mode
  28375. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28376. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28378. */
  28379. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28380. /**
  28381. * Gets the current alpha mode
  28382. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28383. * @returns the current alpha mode
  28384. */
  28385. getAlphaMode(): number;
  28386. /**
  28387. * Clears the list of texture accessible through engine.
  28388. * This can help preventing texture load conflict due to name collision.
  28389. */
  28390. clearInternalTexturesCache(): void;
  28391. /**
  28392. * Force the entire cache to be cleared
  28393. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28394. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28395. */
  28396. wipeCaches(bruteForce?: boolean): void;
  28397. /**
  28398. * Set the compressed texture format to use, based on the formats you have, and the formats
  28399. * supported by the hardware / browser.
  28400. *
  28401. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28402. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28403. * to API arguments needed to compressed textures. This puts the burden on the container
  28404. * generator to house the arcane code for determining these for current & future formats.
  28405. *
  28406. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28407. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28408. *
  28409. * Note: The result of this call is not taken into account when a texture is base64.
  28410. *
  28411. * @param formatsAvailable defines the list of those format families you have created
  28412. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28413. *
  28414. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28415. * @returns The extension selected.
  28416. */
  28417. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28418. private _getSamplingParameters;
  28419. private _partialLoadImg;
  28420. private _cascadeLoadImgs;
  28421. /** @hidden */
  28422. _createTexture(): WebGLTexture;
  28423. /**
  28424. * Usually called from Texture.ts.
  28425. * Passed information to create a WebGLTexture
  28426. * @param urlArg defines a value which contains one of the following:
  28427. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28428. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28429. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28430. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28431. * @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)
  28432. * @param scene needed for loading to the correct scene
  28433. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28434. * @param onLoad optional callback to be called upon successful completion
  28435. * @param onError optional callback to be called upon failure
  28436. * @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
  28437. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28438. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28439. * @param forcedExtension defines the extension to use to pick the right loader
  28440. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28441. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28442. */
  28443. 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;
  28444. private _rescaleTexture;
  28445. /**
  28446. * Update a raw texture
  28447. * @param texture defines the texture to update
  28448. * @param data defines the data to store in the texture
  28449. * @param format defines the format of the data
  28450. * @param invertY defines if data must be stored with Y axis inverted
  28451. * @param compression defines the compression used (null by default)
  28452. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28453. */
  28454. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28455. /**
  28456. * Creates a raw texture
  28457. * @param data defines the data to store in the texture
  28458. * @param width defines the width of the texture
  28459. * @param height defines the height of the texture
  28460. * @param format defines the format of the data
  28461. * @param generateMipMaps defines if the engine should generate the mip levels
  28462. * @param invertY defines if data must be stored with Y axis inverted
  28463. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28464. * @param compression defines the compression used (null by default)
  28465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28466. * @returns the raw texture inside an InternalTexture
  28467. */
  28468. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28469. private _unpackFlipYCached;
  28470. /**
  28471. * In case you are sharing the context with other applications, it might
  28472. * be interested to not cache the unpack flip y state to ensure a consistent
  28473. * value would be set.
  28474. */
  28475. enableUnpackFlipYCached: boolean;
  28476. /** @hidden */
  28477. _unpackFlipY(value: boolean): void;
  28478. /** @hidden */
  28479. _getUnpackAlignement(): number;
  28480. /**
  28481. * Creates a dynamic texture
  28482. * @param width defines the width of the texture
  28483. * @param height defines the height of the texture
  28484. * @param generateMipMaps defines if the engine should generate the mip levels
  28485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28486. * @returns the dynamic texture inside an InternalTexture
  28487. */
  28488. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28489. /**
  28490. * Update the sampling mode of a given texture
  28491. * @param samplingMode defines the required sampling mode
  28492. * @param texture defines the texture to update
  28493. */
  28494. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28495. /**
  28496. * Update the content of a dynamic texture
  28497. * @param texture defines the texture to update
  28498. * @param canvas defines the canvas containing the source
  28499. * @param invertY defines if data must be stored with Y axis inverted
  28500. * @param premulAlpha defines if alpha is stored as premultiplied
  28501. * @param format defines the format of the data
  28502. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28503. */
  28504. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28505. /**
  28506. * Update a video texture
  28507. * @param texture defines the texture to update
  28508. * @param video defines the video element to use
  28509. * @param invertY defines if data must be stored with Y axis inverted
  28510. */
  28511. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28512. /**
  28513. * Updates a depth texture Comparison Mode and Function.
  28514. * If the comparison Function is equal to 0, the mode will be set to none.
  28515. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28516. * @param texture The texture to set the comparison function for
  28517. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28518. */
  28519. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28520. private _setupDepthStencilTexture;
  28521. /**
  28522. * Creates a depth stencil texture.
  28523. * This is only available in WebGL 2 or with the depth texture extension available.
  28524. * @param size The size of face edge in the texture.
  28525. * @param options The options defining the texture.
  28526. * @returns The texture
  28527. */
  28528. createDepthStencilTexture(size: number | {
  28529. width: number;
  28530. height: number;
  28531. }, options: DepthTextureCreationOptions): InternalTexture;
  28532. /**
  28533. * Creates a depth stencil texture.
  28534. * This is only available in WebGL 2 or with the depth texture extension available.
  28535. * @param size The size of face edge in the texture.
  28536. * @param options The options defining the texture.
  28537. * @returns The texture
  28538. */
  28539. private _createDepthStencilTexture;
  28540. /**
  28541. * Creates a depth stencil cube texture.
  28542. * This is only available in WebGL 2.
  28543. * @param size The size of face edge in the cube texture.
  28544. * @param options The options defining the cube texture.
  28545. * @returns The cube texture
  28546. */
  28547. private _createDepthStencilCubeTexture;
  28548. /**
  28549. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28550. * @param renderTarget The render target to set the frame buffer for
  28551. */
  28552. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28553. /**
  28554. * Creates a new render target texture
  28555. * @param size defines the size of the texture
  28556. * @param options defines the options used to create the texture
  28557. * @returns a new render target texture stored in an InternalTexture
  28558. */
  28559. createRenderTargetTexture(size: number | {
  28560. width: number;
  28561. height: number;
  28562. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28563. /**
  28564. * Create a multi render target texture
  28565. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28566. * @param size defines the size of the texture
  28567. * @param options defines the creation options
  28568. * @returns the cube texture as an InternalTexture
  28569. */
  28570. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28571. private _setupFramebufferDepthAttachments;
  28572. /**
  28573. * Updates the sample count of a render target texture
  28574. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28575. * @param texture defines the texture to update
  28576. * @param samples defines the sample count to set
  28577. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28578. */
  28579. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28580. /**
  28581. * Update the sample count for a given multiple render target texture
  28582. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28583. * @param textures defines the textures to update
  28584. * @param samples defines the sample count to set
  28585. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28586. */
  28587. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28588. /** @hidden */
  28589. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28590. /** @hidden */
  28591. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28592. /** @hidden */
  28593. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28594. /** @hidden */
  28595. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28596. /**
  28597. * Creates a new multiview render target
  28598. * @param width defines the width of the texture
  28599. * @param height defines the height of the texture
  28600. * @returns the created multiview texture
  28601. */
  28602. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  28603. /**
  28604. * Binds a multiview framebuffer to be drawn to
  28605. * @param multiviewTexture texture to bind
  28606. */
  28607. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  28608. /**
  28609. * Creates a new render target cube texture
  28610. * @param size defines the size of the texture
  28611. * @param options defines the options used to create the texture
  28612. * @returns a new render target cube texture stored in an InternalTexture
  28613. */
  28614. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28615. /**
  28616. * Creates a cube texture
  28617. * @param rootUrl defines the url where the files to load is located
  28618. * @param scene defines the current scene
  28619. * @param files defines the list of files to load (1 per face)
  28620. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28621. * @param onLoad defines an optional callback raised when the texture is loaded
  28622. * @param onError defines an optional callback raised if there is an issue to load the texture
  28623. * @param format defines the format of the data
  28624. * @param forcedExtension defines the extension to use to pick the right loader
  28625. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28626. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28627. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28628. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28629. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28630. * @returns the cube texture as an InternalTexture
  28631. */
  28632. 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;
  28633. /**
  28634. * @hidden
  28635. */
  28636. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28637. /**
  28638. * Update a raw cube texture
  28639. * @param texture defines the texture to udpdate
  28640. * @param data defines the data to store
  28641. * @param format defines the data format
  28642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28643. * @param invertY defines if data must be stored with Y axis inverted
  28644. * @param compression defines the compression used (null by default)
  28645. * @param level defines which level of the texture to update
  28646. */
  28647. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28648. /**
  28649. * Creates a new raw cube texture
  28650. * @param data defines the array of data to use to create each face
  28651. * @param size defines the size of the textures
  28652. * @param format defines the format of the data
  28653. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28654. * @param generateMipMaps defines if the engine should generate the mip levels
  28655. * @param invertY defines if data must be stored with Y axis inverted
  28656. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28657. * @param compression defines the compression used (null by default)
  28658. * @returns the cube texture as an InternalTexture
  28659. */
  28660. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28661. /**
  28662. * Creates a new raw cube texture from a specified url
  28663. * @param url defines the url where the data is located
  28664. * @param scene defines the current scene
  28665. * @param size defines the size of the textures
  28666. * @param format defines the format of the data
  28667. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28668. * @param noMipmap defines if the engine should avoid generating the mip levels
  28669. * @param callback defines a callback used to extract texture data from loaded data
  28670. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28671. * @param onLoad defines a callback called when texture is loaded
  28672. * @param onError defines a callback called if there is an error
  28673. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28674. * @param invertY defines if data must be stored with Y axis inverted
  28675. * @returns the cube texture as an InternalTexture
  28676. */
  28677. 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;
  28678. /**
  28679. * Update a raw 3D texture
  28680. * @param texture defines the texture to update
  28681. * @param data defines the data to store
  28682. * @param format defines the data format
  28683. * @param invertY defines if data must be stored with Y axis inverted
  28684. * @param compression defines the used compression (can be null)
  28685. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28686. */
  28687. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28688. /**
  28689. * Creates a new raw 3D texture
  28690. * @param data defines the data used to create the texture
  28691. * @param width defines the width of the texture
  28692. * @param height defines the height of the texture
  28693. * @param depth defines the depth of the texture
  28694. * @param format defines the format of the texture
  28695. * @param generateMipMaps defines if the engine must generate mip levels
  28696. * @param invertY defines if data must be stored with Y axis inverted
  28697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28698. * @param compression defines the compressed used (can be null)
  28699. * @param textureType defines the compressed used (can be null)
  28700. * @returns a new raw 3D texture (stored in an InternalTexture)
  28701. */
  28702. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28703. private _prepareWebGLTextureContinuation;
  28704. private _prepareWebGLTexture;
  28705. private _convertRGBtoRGBATextureData;
  28706. /** @hidden */
  28707. _releaseFramebufferObjects(texture: InternalTexture): void;
  28708. /** @hidden */
  28709. _releaseTexture(texture: InternalTexture): void;
  28710. private setProgram;
  28711. private _boundUniforms;
  28712. /**
  28713. * Binds an effect to the webGL context
  28714. * @param effect defines the effect to bind
  28715. */
  28716. bindSamplers(effect: Effect): void;
  28717. private _moveBoundTextureOnTop;
  28718. private _getCorrectTextureChannel;
  28719. private _linkTrackers;
  28720. private _removeDesignatedSlot;
  28721. private _activateCurrentTexture;
  28722. /** @hidden */
  28723. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28724. /** @hidden */
  28725. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28726. /**
  28727. * Sets a texture to the webGL context from a postprocess
  28728. * @param channel defines the channel to use
  28729. * @param postProcess defines the source postprocess
  28730. */
  28731. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28732. /**
  28733. * Binds the output of the passed in post process to the texture channel specified
  28734. * @param channel The channel the texture should be bound to
  28735. * @param postProcess The post process which's output should be bound
  28736. */
  28737. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28738. /**
  28739. * Unbind all textures from the webGL context
  28740. */
  28741. unbindAllTextures(): void;
  28742. /**
  28743. * Sets a texture to the according uniform.
  28744. * @param channel The texture channel
  28745. * @param uniform The uniform to set
  28746. * @param texture The texture to apply
  28747. */
  28748. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28749. /**
  28750. * Sets a depth stencil texture from a render target to the according uniform.
  28751. * @param channel The texture channel
  28752. * @param uniform The uniform to set
  28753. * @param texture The render target texture containing the depth stencil texture to apply
  28754. */
  28755. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28756. private _bindSamplerUniformToChannel;
  28757. private _getTextureWrapMode;
  28758. private _setTexture;
  28759. /**
  28760. * Sets an array of texture to the webGL context
  28761. * @param channel defines the channel where the texture array must be set
  28762. * @param uniform defines the associated uniform location
  28763. * @param textures defines the array of textures to bind
  28764. */
  28765. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28766. /** @hidden */
  28767. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28768. private _setTextureParameterFloat;
  28769. private _setTextureParameterInteger;
  28770. /**
  28771. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28772. * @param x defines the x coordinate of the rectangle where pixels must be read
  28773. * @param y defines the y coordinate of the rectangle where pixels must be read
  28774. * @param width defines the width of the rectangle where pixels must be read
  28775. * @param height defines the height of the rectangle where pixels must be read
  28776. * @returns a Uint8Array containing RGBA colors
  28777. */
  28778. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28779. /**
  28780. * Add an externaly attached data from its key.
  28781. * This method call will fail and return false, if such key already exists.
  28782. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28783. * @param key the unique key that identifies the data
  28784. * @param data the data object to associate to the key for this Engine instance
  28785. * @return true if no such key were already present and the data was added successfully, false otherwise
  28786. */
  28787. addExternalData<T>(key: string, data: T): boolean;
  28788. /**
  28789. * Get an externaly attached data from its key
  28790. * @param key the unique key that identifies the data
  28791. * @return the associated data, if present (can be null), or undefined if not present
  28792. */
  28793. getExternalData<T>(key: string): T;
  28794. /**
  28795. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28796. * @param key the unique key that identifies the data
  28797. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28798. * @return the associated data, can be null if the factory returned null.
  28799. */
  28800. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28801. /**
  28802. * Remove an externaly attached data from the Engine instance
  28803. * @param key the unique key that identifies the data
  28804. * @return true if the data was successfully removed, false if it doesn't exist
  28805. */
  28806. removeExternalData(key: string): boolean;
  28807. /**
  28808. * Unbind all vertex attributes from the webGL context
  28809. */
  28810. unbindAllAttributes(): void;
  28811. /**
  28812. * 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
  28813. */
  28814. releaseEffects(): void;
  28815. /**
  28816. * Dispose and release all associated resources
  28817. */
  28818. dispose(): void;
  28819. /**
  28820. * Display the loading screen
  28821. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28822. */
  28823. displayLoadingUI(): void;
  28824. /**
  28825. * Hide the loading screen
  28826. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28827. */
  28828. hideLoadingUI(): void;
  28829. /**
  28830. * Gets the current loading screen object
  28831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28832. */
  28833. /**
  28834. * Sets the current loading screen object
  28835. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28836. */
  28837. loadingScreen: ILoadingScreen;
  28838. /**
  28839. * Sets the current loading screen text
  28840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28841. */
  28842. loadingUIText: string;
  28843. /**
  28844. * Sets the current loading screen background color
  28845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28846. */
  28847. loadingUIBackgroundColor: string;
  28848. /**
  28849. * Attach a new callback raised when context lost event is fired
  28850. * @param callback defines the callback to call
  28851. */
  28852. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28853. /**
  28854. * Attach a new callback raised when context restored event is fired
  28855. * @param callback defines the callback to call
  28856. */
  28857. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28858. /**
  28859. * Gets the source code of the vertex shader associated with a specific webGL program
  28860. * @param program defines the program to use
  28861. * @returns a string containing the source code of the vertex shader associated with the program
  28862. */
  28863. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28864. /**
  28865. * Gets the source code of the fragment shader associated with a specific webGL program
  28866. * @param program defines the program to use
  28867. * @returns a string containing the source code of the fragment shader associated with the program
  28868. */
  28869. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28870. /**
  28871. * Get the current error code of the webGL context
  28872. * @returns the error code
  28873. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28874. */
  28875. getError(): number;
  28876. /**
  28877. * Gets the current framerate
  28878. * @returns a number representing the framerate
  28879. */
  28880. getFps(): number;
  28881. /**
  28882. * Gets the time spent between current and previous frame
  28883. * @returns a number representing the delta time in ms
  28884. */
  28885. getDeltaTime(): number;
  28886. private _measureFps;
  28887. /** @hidden */
  28888. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28889. private _canRenderToFloatFramebuffer;
  28890. private _canRenderToHalfFloatFramebuffer;
  28891. private _canRenderToFramebuffer;
  28892. /** @hidden */
  28893. _getWebGLTextureType(type: number): number;
  28894. private _getInternalFormat;
  28895. /** @hidden */
  28896. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28897. /** @hidden */
  28898. _getRGBAMultiSampleBufferFormat(type: number): number;
  28899. /** @hidden */
  28900. _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;
  28901. /** @hidden */
  28902. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28903. private _partialLoadFile;
  28904. private _cascadeLoadFiles;
  28905. /**
  28906. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28907. * @returns true if the engine can be created
  28908. * @ignorenaming
  28909. */
  28910. static isSupported(): boolean;
  28911. }
  28912. }
  28913. declare module BABYLON {
  28914. /**
  28915. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28916. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28917. */
  28918. export class EffectFallbacks {
  28919. private _defines;
  28920. private _currentRank;
  28921. private _maxRank;
  28922. private _mesh;
  28923. /**
  28924. * Removes the fallback from the bound mesh.
  28925. */
  28926. unBindMesh(): void;
  28927. /**
  28928. * Adds a fallback on the specified property.
  28929. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28930. * @param define The name of the define in the shader
  28931. */
  28932. addFallback(rank: number, define: string): void;
  28933. /**
  28934. * Sets the mesh to use CPU skinning when needing to fallback.
  28935. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28936. * @param mesh The mesh to use the fallbacks.
  28937. */
  28938. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28939. /**
  28940. * Checks to see if more fallbacks are still availible.
  28941. */
  28942. readonly isMoreFallbacks: boolean;
  28943. /**
  28944. * Removes the defines that shoould be removed when falling back.
  28945. * @param currentDefines defines the current define statements for the shader.
  28946. * @param effect defines the current effect we try to compile
  28947. * @returns The resulting defines with defines of the current rank removed.
  28948. */
  28949. reduce(currentDefines: string, effect: Effect): string;
  28950. }
  28951. /**
  28952. * Options to be used when creating an effect.
  28953. */
  28954. export class EffectCreationOptions {
  28955. /**
  28956. * Atrributes that will be used in the shader.
  28957. */
  28958. attributes: string[];
  28959. /**
  28960. * Uniform varible names that will be set in the shader.
  28961. */
  28962. uniformsNames: string[];
  28963. /**
  28964. * Uniform buffer varible names that will be set in the shader.
  28965. */
  28966. uniformBuffersNames: string[];
  28967. /**
  28968. * Sampler texture variable names that will be set in the shader.
  28969. */
  28970. samplers: string[];
  28971. /**
  28972. * Define statements that will be set in the shader.
  28973. */
  28974. defines: any;
  28975. /**
  28976. * Possible fallbacks for this effect to improve performance when needed.
  28977. */
  28978. fallbacks: Nullable<EffectFallbacks>;
  28979. /**
  28980. * Callback that will be called when the shader is compiled.
  28981. */
  28982. onCompiled: Nullable<(effect: Effect) => void>;
  28983. /**
  28984. * Callback that will be called if an error occurs during shader compilation.
  28985. */
  28986. onError: Nullable<(effect: Effect, errors: string) => void>;
  28987. /**
  28988. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28989. */
  28990. indexParameters: any;
  28991. /**
  28992. * Max number of lights that can be used in the shader.
  28993. */
  28994. maxSimultaneousLights: number;
  28995. /**
  28996. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28997. */
  28998. transformFeedbackVaryings: Nullable<string[]>;
  28999. }
  29000. /**
  29001. * Effect containing vertex and fragment shader that can be executed on an object.
  29002. */
  29003. export class Effect {
  29004. /**
  29005. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29006. */
  29007. static ShadersRepository: string;
  29008. /**
  29009. * Name of the effect.
  29010. */
  29011. name: any;
  29012. /**
  29013. * String container all the define statements that should be set on the shader.
  29014. */
  29015. defines: string;
  29016. /**
  29017. * Callback that will be called when the shader is compiled.
  29018. */
  29019. onCompiled: Nullable<(effect: Effect) => void>;
  29020. /**
  29021. * Callback that will be called if an error occurs during shader compilation.
  29022. */
  29023. onError: Nullable<(effect: Effect, errors: string) => void>;
  29024. /**
  29025. * Callback that will be called when effect is bound.
  29026. */
  29027. onBind: Nullable<(effect: Effect) => void>;
  29028. /**
  29029. * Unique ID of the effect.
  29030. */
  29031. uniqueId: number;
  29032. /**
  29033. * Observable that will be called when the shader is compiled.
  29034. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29035. */
  29036. onCompileObservable: Observable<Effect>;
  29037. /**
  29038. * Observable that will be called if an error occurs during shader compilation.
  29039. */
  29040. onErrorObservable: Observable<Effect>;
  29041. /** @hidden */
  29042. _onBindObservable: Nullable<Observable<Effect>>;
  29043. /**
  29044. * Observable that will be called when effect is bound.
  29045. */
  29046. readonly onBindObservable: Observable<Effect>;
  29047. /** @hidden */
  29048. _bonesComputationForcedToCPU: boolean;
  29049. private static _uniqueIdSeed;
  29050. private _engine;
  29051. private _uniformBuffersNames;
  29052. private _uniformsNames;
  29053. private _samplers;
  29054. private _isReady;
  29055. private _compilationError;
  29056. private _attributesNames;
  29057. private _attributes;
  29058. private _uniforms;
  29059. /**
  29060. * Key for the effect.
  29061. * @hidden
  29062. */
  29063. _key: string;
  29064. private _indexParameters;
  29065. private _fallbacks;
  29066. private _vertexSourceCode;
  29067. private _fragmentSourceCode;
  29068. private _vertexSourceCodeOverride;
  29069. private _fragmentSourceCodeOverride;
  29070. private _transformFeedbackVaryings;
  29071. /**
  29072. * Compiled shader to webGL program.
  29073. * @hidden
  29074. */
  29075. _program: WebGLProgram;
  29076. private _valueCache;
  29077. private static _baseCache;
  29078. /**
  29079. * Instantiates an effect.
  29080. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29081. * @param baseName Name of the effect.
  29082. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29083. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29084. * @param samplers List of sampler variables that will be passed to the shader.
  29085. * @param engine Engine to be used to render the effect
  29086. * @param defines Define statements to be added to the shader.
  29087. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29088. * @param onCompiled Callback that will be called when the shader is compiled.
  29089. * @param onError Callback that will be called if an error occurs during shader compilation.
  29090. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29091. */
  29092. 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);
  29093. /**
  29094. * Unique key for this effect
  29095. */
  29096. readonly key: string;
  29097. /**
  29098. * If the effect has been compiled and prepared.
  29099. * @returns if the effect is compiled and prepared.
  29100. */
  29101. isReady(): boolean;
  29102. /**
  29103. * The engine the effect was initialized with.
  29104. * @returns the engine.
  29105. */
  29106. getEngine(): Engine;
  29107. /**
  29108. * The compiled webGL program for the effect
  29109. * @returns the webGL program.
  29110. */
  29111. getProgram(): WebGLProgram;
  29112. /**
  29113. * The set of names of attribute variables for the shader.
  29114. * @returns An array of attribute names.
  29115. */
  29116. getAttributesNames(): string[];
  29117. /**
  29118. * Returns the attribute at the given index.
  29119. * @param index The index of the attribute.
  29120. * @returns The location of the attribute.
  29121. */
  29122. getAttributeLocation(index: number): number;
  29123. /**
  29124. * Returns the attribute based on the name of the variable.
  29125. * @param name of the attribute to look up.
  29126. * @returns the attribute location.
  29127. */
  29128. getAttributeLocationByName(name: string): number;
  29129. /**
  29130. * The number of attributes.
  29131. * @returns the numnber of attributes.
  29132. */
  29133. getAttributesCount(): number;
  29134. /**
  29135. * Gets the index of a uniform variable.
  29136. * @param uniformName of the uniform to look up.
  29137. * @returns the index.
  29138. */
  29139. getUniformIndex(uniformName: string): number;
  29140. /**
  29141. * Returns the attribute based on the name of the variable.
  29142. * @param uniformName of the uniform to look up.
  29143. * @returns the location of the uniform.
  29144. */
  29145. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29146. /**
  29147. * Returns an array of sampler variable names
  29148. * @returns The array of sampler variable neames.
  29149. */
  29150. getSamplers(): string[];
  29151. /**
  29152. * The error from the last compilation.
  29153. * @returns the error string.
  29154. */
  29155. getCompilationError(): string;
  29156. /**
  29157. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29158. * @param func The callback to be used.
  29159. */
  29160. executeWhenCompiled(func: (effect: Effect) => void): void;
  29161. private _checkIsReady;
  29162. /** @hidden */
  29163. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29164. /** @hidden */
  29165. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29166. /** @hidden */
  29167. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29168. private _processShaderConversion;
  29169. private _processIncludes;
  29170. private _processPrecision;
  29171. /**
  29172. * Recompiles the webGL program
  29173. * @param vertexSourceCode The source code for the vertex shader.
  29174. * @param fragmentSourceCode The source code for the fragment shader.
  29175. * @param onCompiled Callback called when completed.
  29176. * @param onError Callback called on error.
  29177. * @hidden
  29178. */
  29179. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29180. /**
  29181. * Gets the uniform locations of the the specified variable names
  29182. * @param names THe names of the variables to lookup.
  29183. * @returns Array of locations in the same order as variable names.
  29184. */
  29185. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29186. /**
  29187. * Prepares the effect
  29188. * @hidden
  29189. */
  29190. _prepareEffect(): void;
  29191. /**
  29192. * Checks if the effect is supported. (Must be called after compilation)
  29193. */
  29194. readonly isSupported: boolean;
  29195. /**
  29196. * Binds a texture to the engine to be used as output of the shader.
  29197. * @param channel Name of the output variable.
  29198. * @param texture Texture to bind.
  29199. * @hidden
  29200. */
  29201. _bindTexture(channel: string, texture: InternalTexture): void;
  29202. /**
  29203. * Sets a texture on the engine to be used in the shader.
  29204. * @param channel Name of the sampler variable.
  29205. * @param texture Texture to set.
  29206. */
  29207. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29208. /**
  29209. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29210. * @param channel Name of the sampler variable.
  29211. * @param texture Texture to set.
  29212. */
  29213. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29214. /**
  29215. * Sets an array of textures on the engine to be used in the shader.
  29216. * @param channel Name of the variable.
  29217. * @param textures Textures to set.
  29218. */
  29219. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29220. /**
  29221. * 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)
  29222. * @param channel Name of the sampler variable.
  29223. * @param postProcess Post process to get the input texture from.
  29224. */
  29225. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29226. /**
  29227. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29228. * 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)
  29229. * @param channel Name of the sampler variable.
  29230. * @param postProcess Post process to get the output texture from.
  29231. */
  29232. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29233. /** @hidden */
  29234. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29235. /** @hidden */
  29236. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29237. /** @hidden */
  29238. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29239. /** @hidden */
  29240. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29241. /**
  29242. * Binds a buffer to a uniform.
  29243. * @param buffer Buffer to bind.
  29244. * @param name Name of the uniform variable to bind to.
  29245. */
  29246. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29247. /**
  29248. * Binds block to a uniform.
  29249. * @param blockName Name of the block to bind.
  29250. * @param index Index to bind.
  29251. */
  29252. bindUniformBlock(blockName: string, index: number): void;
  29253. /**
  29254. * Sets an interger value on a uniform variable.
  29255. * @param uniformName Name of the variable.
  29256. * @param value Value to be set.
  29257. * @returns this effect.
  29258. */
  29259. setInt(uniformName: string, value: number): Effect;
  29260. /**
  29261. * Sets an int array on a uniform variable.
  29262. * @param uniformName Name of the variable.
  29263. * @param array array to be set.
  29264. * @returns this effect.
  29265. */
  29266. setIntArray(uniformName: string, array: Int32Array): Effect;
  29267. /**
  29268. * 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)
  29269. * @param uniformName Name of the variable.
  29270. * @param array array to be set.
  29271. * @returns this effect.
  29272. */
  29273. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29274. /**
  29275. * 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)
  29276. * @param uniformName Name of the variable.
  29277. * @param array array to be set.
  29278. * @returns this effect.
  29279. */
  29280. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29281. /**
  29282. * 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)
  29283. * @param uniformName Name of the variable.
  29284. * @param array array to be set.
  29285. * @returns this effect.
  29286. */
  29287. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29288. /**
  29289. * Sets an float array on a uniform variable.
  29290. * @param uniformName Name of the variable.
  29291. * @param array array to be set.
  29292. * @returns this effect.
  29293. */
  29294. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29295. /**
  29296. * 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)
  29297. * @param uniformName Name of the variable.
  29298. * @param array array to be set.
  29299. * @returns this effect.
  29300. */
  29301. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29302. /**
  29303. * 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)
  29304. * @param uniformName Name of the variable.
  29305. * @param array array to be set.
  29306. * @returns this effect.
  29307. */
  29308. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29309. /**
  29310. * 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)
  29311. * @param uniformName Name of the variable.
  29312. * @param array array to be set.
  29313. * @returns this effect.
  29314. */
  29315. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29316. /**
  29317. * Sets an array on a uniform variable.
  29318. * @param uniformName Name of the variable.
  29319. * @param array array to be set.
  29320. * @returns this effect.
  29321. */
  29322. setArray(uniformName: string, array: number[]): Effect;
  29323. /**
  29324. * 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)
  29325. * @param uniformName Name of the variable.
  29326. * @param array array to be set.
  29327. * @returns this effect.
  29328. */
  29329. setArray2(uniformName: string, array: number[]): Effect;
  29330. /**
  29331. * 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)
  29332. * @param uniformName Name of the variable.
  29333. * @param array array to be set.
  29334. * @returns this effect.
  29335. */
  29336. setArray3(uniformName: string, array: number[]): Effect;
  29337. /**
  29338. * 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)
  29339. * @param uniformName Name of the variable.
  29340. * @param array array to be set.
  29341. * @returns this effect.
  29342. */
  29343. setArray4(uniformName: string, array: number[]): Effect;
  29344. /**
  29345. * Sets matrices on a uniform variable.
  29346. * @param uniformName Name of the variable.
  29347. * @param matrices matrices to be set.
  29348. * @returns this effect.
  29349. */
  29350. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29351. /**
  29352. * Sets matrix on a uniform variable.
  29353. * @param uniformName Name of the variable.
  29354. * @param matrix matrix to be set.
  29355. * @returns this effect.
  29356. */
  29357. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29358. /**
  29359. * 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)
  29360. * @param uniformName Name of the variable.
  29361. * @param matrix matrix to be set.
  29362. * @returns this effect.
  29363. */
  29364. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29365. /**
  29366. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29367. * @param uniformName Name of the variable.
  29368. * @param matrix matrix to be set.
  29369. * @returns this effect.
  29370. */
  29371. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29372. /**
  29373. * Sets a float on a uniform variable.
  29374. * @param uniformName Name of the variable.
  29375. * @param value value to be set.
  29376. * @returns this effect.
  29377. */
  29378. setFloat(uniformName: string, value: number): Effect;
  29379. /**
  29380. * Sets a boolean on a uniform variable.
  29381. * @param uniformName Name of the variable.
  29382. * @param bool value to be set.
  29383. * @returns this effect.
  29384. */
  29385. setBool(uniformName: string, bool: boolean): Effect;
  29386. /**
  29387. * Sets a Vector2 on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param vector2 vector2 to be set.
  29390. * @returns this effect.
  29391. */
  29392. setVector2(uniformName: string, vector2: Vector2): Effect;
  29393. /**
  29394. * Sets a float2 on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param x First float in float2.
  29397. * @param y Second float in float2.
  29398. * @returns this effect.
  29399. */
  29400. setFloat2(uniformName: string, x: number, y: number): Effect;
  29401. /**
  29402. * Sets a Vector3 on a uniform variable.
  29403. * @param uniformName Name of the variable.
  29404. * @param vector3 Value to be set.
  29405. * @returns this effect.
  29406. */
  29407. setVector3(uniformName: string, vector3: Vector3): Effect;
  29408. /**
  29409. * Sets a float3 on a uniform variable.
  29410. * @param uniformName Name of the variable.
  29411. * @param x First float in float3.
  29412. * @param y Second float in float3.
  29413. * @param z Third float in float3.
  29414. * @returns this effect.
  29415. */
  29416. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29417. /**
  29418. * Sets a Vector4 on a uniform variable.
  29419. * @param uniformName Name of the variable.
  29420. * @param vector4 Value to be set.
  29421. * @returns this effect.
  29422. */
  29423. setVector4(uniformName: string, vector4: Vector4): Effect;
  29424. /**
  29425. * Sets a float4 on a uniform variable.
  29426. * @param uniformName Name of the variable.
  29427. * @param x First float in float4.
  29428. * @param y Second float in float4.
  29429. * @param z Third float in float4.
  29430. * @param w Fourth float in float4.
  29431. * @returns this effect.
  29432. */
  29433. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29434. /**
  29435. * Sets a Color3 on a uniform variable.
  29436. * @param uniformName Name of the variable.
  29437. * @param color3 Value to be set.
  29438. * @returns this effect.
  29439. */
  29440. setColor3(uniformName: string, color3: Color3): Effect;
  29441. /**
  29442. * Sets a Color4 on a uniform variable.
  29443. * @param uniformName Name of the variable.
  29444. * @param color3 Value to be set.
  29445. * @param alpha Alpha value to be set.
  29446. * @returns this effect.
  29447. */
  29448. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29449. /**
  29450. * Sets a Color4 on a uniform variable
  29451. * @param uniformName defines the name of the variable
  29452. * @param color4 defines the value to be set
  29453. * @returns this effect.
  29454. */
  29455. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29456. /**
  29457. * This function will add a new shader to the shader store
  29458. * @param name the name of the shader
  29459. * @param pixelShader optional pixel shader content
  29460. * @param vertexShader optional vertex shader content
  29461. */
  29462. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29463. /**
  29464. * Store of each shader (The can be looked up using effect.key)
  29465. */
  29466. static ShadersStore: {
  29467. [key: string]: string;
  29468. };
  29469. /**
  29470. * Store of each included file for a shader (The can be looked up using effect.key)
  29471. */
  29472. static IncludesShadersStore: {
  29473. [key: string]: string;
  29474. };
  29475. /**
  29476. * Resets the cache of effects.
  29477. */
  29478. static ResetCache(): void;
  29479. }
  29480. }
  29481. declare module BABYLON {
  29482. /**
  29483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29485. * 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;
  29486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29487. */
  29488. export class ColorCurves {
  29489. private _dirty;
  29490. private _tempColor;
  29491. private _globalCurve;
  29492. private _highlightsCurve;
  29493. private _midtonesCurve;
  29494. private _shadowsCurve;
  29495. private _positiveCurve;
  29496. private _negativeCurve;
  29497. private _globalHue;
  29498. private _globalDensity;
  29499. private _globalSaturation;
  29500. private _globalExposure;
  29501. /**
  29502. * Gets the global Hue value.
  29503. * 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).
  29504. */
  29505. /**
  29506. * Sets the global Hue value.
  29507. * 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).
  29508. */
  29509. globalHue: number;
  29510. /**
  29511. * Gets the global 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. /**
  29516. * Sets the global Density value.
  29517. * 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.
  29518. * Values less than zero provide a filter of opposite hue.
  29519. */
  29520. globalDensity: number;
  29521. /**
  29522. * Gets the global Saturation value.
  29523. * 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.
  29524. */
  29525. /**
  29526. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  29528. */
  29529. globalSaturation: number;
  29530. /**
  29531. * Gets the global Exposure value.
  29532. * 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.
  29533. */
  29534. /**
  29535. * Sets the global Exposure value.
  29536. * 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.
  29537. */
  29538. globalExposure: number;
  29539. private _highlightsHue;
  29540. private _highlightsDensity;
  29541. private _highlightsSaturation;
  29542. private _highlightsExposure;
  29543. /**
  29544. * Gets the highlights Hue value.
  29545. * 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).
  29546. */
  29547. /**
  29548. * Sets the highlights Hue value.
  29549. * 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).
  29550. */
  29551. highlightsHue: number;
  29552. /**
  29553. * Gets the highlights 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. /**
  29558. * Sets the highlights Density value.
  29559. * 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.
  29560. * Values less than zero provide a filter of opposite hue.
  29561. */
  29562. highlightsDensity: number;
  29563. /**
  29564. * Gets the highlights Saturation value.
  29565. * 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.
  29566. */
  29567. /**
  29568. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  29570. */
  29571. highlightsSaturation: number;
  29572. /**
  29573. * Gets the highlights Exposure value.
  29574. * 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.
  29575. */
  29576. /**
  29577. * Sets the highlights Exposure value.
  29578. * 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.
  29579. */
  29580. highlightsExposure: number;
  29581. private _midtonesHue;
  29582. private _midtonesDensity;
  29583. private _midtonesSaturation;
  29584. private _midtonesExposure;
  29585. /**
  29586. * Gets the midtones Hue value.
  29587. * 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).
  29588. */
  29589. /**
  29590. * Sets the midtones Hue value.
  29591. * 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).
  29592. */
  29593. midtonesHue: number;
  29594. /**
  29595. * Gets the midtones 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. /**
  29600. * Sets the midtones Density value.
  29601. * 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.
  29602. * Values less than zero provide a filter of opposite hue.
  29603. */
  29604. midtonesDensity: number;
  29605. /**
  29606. * Gets the midtones Saturation value.
  29607. * 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.
  29608. */
  29609. /**
  29610. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  29612. */
  29613. midtonesSaturation: number;
  29614. /**
  29615. * Gets the midtones Exposure value.
  29616. * 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.
  29617. */
  29618. /**
  29619. * Sets the midtones Exposure value.
  29620. * 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.
  29621. */
  29622. midtonesExposure: number;
  29623. private _shadowsHue;
  29624. private _shadowsDensity;
  29625. private _shadowsSaturation;
  29626. private _shadowsExposure;
  29627. /**
  29628. * Gets the shadows Hue value.
  29629. * 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).
  29630. */
  29631. /**
  29632. * Sets the shadows Hue value.
  29633. * 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).
  29634. */
  29635. shadowsHue: number;
  29636. /**
  29637. * Gets the shadows Density value.
  29638. * 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.
  29639. * Values less than zero provide a filter of opposite hue.
  29640. */
  29641. /**
  29642. * Sets the shadows Density value.
  29643. * 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.
  29644. * Values less than zero provide a filter of opposite hue.
  29645. */
  29646. shadowsDensity: number;
  29647. /**
  29648. * Gets the shadows Saturation value.
  29649. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29650. */
  29651. /**
  29652. * Sets the shadows Saturation value.
  29653. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29654. */
  29655. shadowsSaturation: number;
  29656. /**
  29657. * Gets the shadows Exposure value.
  29658. * 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.
  29659. */
  29660. /**
  29661. * Sets the shadows Exposure value.
  29662. * 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.
  29663. */
  29664. shadowsExposure: number;
  29665. /**
  29666. * Returns the class name
  29667. * @returns The class name
  29668. */
  29669. getClassName(): string;
  29670. /**
  29671. * Binds the color curves to the shader.
  29672. * @param colorCurves The color curve to bind
  29673. * @param effect The effect to bind to
  29674. * @param positiveUniform The positive uniform shader parameter
  29675. * @param neutralUniform The neutral uniform shader parameter
  29676. * @param negativeUniform The negative uniform shader parameter
  29677. */
  29678. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29679. /**
  29680. * Prepare the list of uniforms associated with the ColorCurves effects.
  29681. * @param uniformsList The list of uniforms used in the effect
  29682. */
  29683. static PrepareUniforms(uniformsList: string[]): void;
  29684. /**
  29685. * Returns color grading data based on a hue, density, saturation and exposure value.
  29686. * @param filterHue The hue of the color filter.
  29687. * @param filterDensity The density of the color filter.
  29688. * @param saturation The saturation.
  29689. * @param exposure The exposure.
  29690. * @param result The result data container.
  29691. */
  29692. private getColorGradingDataToRef;
  29693. /**
  29694. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29695. * @param value The input slider value in range [-100,100].
  29696. * @returns Adjusted value.
  29697. */
  29698. private static applyColorGradingSliderNonlinear;
  29699. /**
  29700. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29701. * @param hue The hue (H) input.
  29702. * @param saturation The saturation (S) input.
  29703. * @param brightness The brightness (B) input.
  29704. * @result An RGBA color represented as Vector4.
  29705. */
  29706. private static fromHSBToRef;
  29707. /**
  29708. * Returns a value clamped between min and max
  29709. * @param value The value to clamp
  29710. * @param min The minimum of value
  29711. * @param max The maximum of value
  29712. * @returns The clamped value.
  29713. */
  29714. private static clamp;
  29715. /**
  29716. * Clones the current color curve instance.
  29717. * @return The cloned curves
  29718. */
  29719. clone(): ColorCurves;
  29720. /**
  29721. * Serializes the current color curve instance to a json representation.
  29722. * @return a JSON representation
  29723. */
  29724. serialize(): any;
  29725. /**
  29726. * Parses the color curve from a json representation.
  29727. * @param source the JSON source to parse
  29728. * @return The parsed curves
  29729. */
  29730. static Parse(source: any): ColorCurves;
  29731. }
  29732. }
  29733. declare module BABYLON {
  29734. /**
  29735. * Interface to follow in your material defines to integrate easily the
  29736. * Image proccessing functions.
  29737. * @hidden
  29738. */
  29739. export interface IImageProcessingConfigurationDefines {
  29740. IMAGEPROCESSING: boolean;
  29741. VIGNETTE: boolean;
  29742. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29743. VIGNETTEBLENDMODEOPAQUE: boolean;
  29744. TONEMAPPING: boolean;
  29745. TONEMAPPING_ACES: boolean;
  29746. CONTRAST: boolean;
  29747. EXPOSURE: boolean;
  29748. COLORCURVES: boolean;
  29749. COLORGRADING: boolean;
  29750. COLORGRADING3D: boolean;
  29751. SAMPLER3DGREENDEPTH: boolean;
  29752. SAMPLER3DBGRMAP: boolean;
  29753. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29754. }
  29755. /**
  29756. * @hidden
  29757. */
  29758. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29759. IMAGEPROCESSING: boolean;
  29760. VIGNETTE: boolean;
  29761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29762. VIGNETTEBLENDMODEOPAQUE: boolean;
  29763. TONEMAPPING: boolean;
  29764. TONEMAPPING_ACES: boolean;
  29765. CONTRAST: boolean;
  29766. COLORCURVES: boolean;
  29767. COLORGRADING: boolean;
  29768. COLORGRADING3D: boolean;
  29769. SAMPLER3DGREENDEPTH: boolean;
  29770. SAMPLER3DBGRMAP: boolean;
  29771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29772. EXPOSURE: boolean;
  29773. constructor();
  29774. }
  29775. /**
  29776. * This groups together the common properties used for image processing either in direct forward pass
  29777. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29778. * or not.
  29779. */
  29780. export class ImageProcessingConfiguration {
  29781. /**
  29782. * Default tone mapping applied in BabylonJS.
  29783. */
  29784. static readonly TONEMAPPING_STANDARD: number;
  29785. /**
  29786. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29787. * to other engines rendering to increase portability.
  29788. */
  29789. static readonly TONEMAPPING_ACES: number;
  29790. /**
  29791. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29792. */
  29793. colorCurves: Nullable<ColorCurves>;
  29794. private _colorCurvesEnabled;
  29795. /**
  29796. * Gets wether the color curves effect is enabled.
  29797. */
  29798. /**
  29799. * Sets wether the color curves effect is enabled.
  29800. */
  29801. colorCurvesEnabled: boolean;
  29802. private _colorGradingTexture;
  29803. /**
  29804. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29805. */
  29806. /**
  29807. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29808. */
  29809. colorGradingTexture: Nullable<BaseTexture>;
  29810. private _colorGradingEnabled;
  29811. /**
  29812. * Gets wether the color grading effect is enabled.
  29813. */
  29814. /**
  29815. * Sets wether the color grading effect is enabled.
  29816. */
  29817. colorGradingEnabled: boolean;
  29818. private _colorGradingWithGreenDepth;
  29819. /**
  29820. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29821. */
  29822. /**
  29823. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29824. */
  29825. colorGradingWithGreenDepth: boolean;
  29826. private _colorGradingBGR;
  29827. /**
  29828. * Gets wether the color grading texture contains BGR values.
  29829. */
  29830. /**
  29831. * Sets wether the color grading texture contains BGR values.
  29832. */
  29833. colorGradingBGR: boolean;
  29834. /** @hidden */
  29835. _exposure: number;
  29836. /**
  29837. * Gets the Exposure used in the effect.
  29838. */
  29839. /**
  29840. * Sets the Exposure used in the effect.
  29841. */
  29842. exposure: number;
  29843. private _toneMappingEnabled;
  29844. /**
  29845. * Gets wether the tone mapping effect is enabled.
  29846. */
  29847. /**
  29848. * Sets wether the tone mapping effect is enabled.
  29849. */
  29850. toneMappingEnabled: boolean;
  29851. private _toneMappingType;
  29852. /**
  29853. * Gets the type of tone mapping effect.
  29854. */
  29855. /**
  29856. * Sets the type of tone mapping effect used in BabylonJS.
  29857. */
  29858. toneMappingType: number;
  29859. protected _contrast: number;
  29860. /**
  29861. * Gets the contrast used in the effect.
  29862. */
  29863. /**
  29864. * Sets the contrast used in the effect.
  29865. */
  29866. contrast: number;
  29867. /**
  29868. * Vignette stretch size.
  29869. */
  29870. vignetteStretch: number;
  29871. /**
  29872. * Vignette centre X Offset.
  29873. */
  29874. vignetteCentreX: number;
  29875. /**
  29876. * Vignette centre Y Offset.
  29877. */
  29878. vignetteCentreY: number;
  29879. /**
  29880. * Vignette weight or intensity of the vignette effect.
  29881. */
  29882. vignetteWeight: number;
  29883. /**
  29884. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29885. * if vignetteEnabled is set to true.
  29886. */
  29887. vignetteColor: Color4;
  29888. /**
  29889. * Camera field of view used by the Vignette effect.
  29890. */
  29891. vignetteCameraFov: number;
  29892. private _vignetteBlendMode;
  29893. /**
  29894. * Gets the vignette blend mode allowing different kind of effect.
  29895. */
  29896. /**
  29897. * Sets the vignette blend mode allowing different kind of effect.
  29898. */
  29899. vignetteBlendMode: number;
  29900. private _vignetteEnabled;
  29901. /**
  29902. * Gets wether the vignette effect is enabled.
  29903. */
  29904. /**
  29905. * Sets wether the vignette effect is enabled.
  29906. */
  29907. vignetteEnabled: boolean;
  29908. private _applyByPostProcess;
  29909. /**
  29910. * Gets wether the image processing is applied through a post process or not.
  29911. */
  29912. /**
  29913. * Sets wether the image processing is applied through a post process or not.
  29914. */
  29915. applyByPostProcess: boolean;
  29916. private _isEnabled;
  29917. /**
  29918. * Gets wether the image processing is enabled or not.
  29919. */
  29920. /**
  29921. * Sets wether the image processing is enabled or not.
  29922. */
  29923. isEnabled: boolean;
  29924. /**
  29925. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29926. */
  29927. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29928. /**
  29929. * Method called each time the image processing information changes requires to recompile the effect.
  29930. */
  29931. protected _updateParameters(): void;
  29932. /**
  29933. * Gets the current class name.
  29934. * @return "ImageProcessingConfiguration"
  29935. */
  29936. getClassName(): string;
  29937. /**
  29938. * Prepare the list of uniforms associated with the Image Processing effects.
  29939. * @param uniforms The list of uniforms used in the effect
  29940. * @param defines the list of defines currently in use
  29941. */
  29942. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29943. /**
  29944. * Prepare the list of samplers associated with the Image Processing effects.
  29945. * @param samplersList The list of uniforms used in the effect
  29946. * @param defines the list of defines currently in use
  29947. */
  29948. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29949. /**
  29950. * Prepare the list of defines associated to the shader.
  29951. * @param defines the list of defines to complete
  29952. * @param forPostProcess Define if we are currently in post process mode or not
  29953. */
  29954. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29955. /**
  29956. * Returns true if all the image processing information are ready.
  29957. * @returns True if ready, otherwise, false
  29958. */
  29959. isReady(): boolean;
  29960. /**
  29961. * Binds the image processing to the shader.
  29962. * @param effect The effect to bind to
  29963. * @param aspectRatio Define the current aspect ratio of the effect
  29964. */
  29965. bind(effect: Effect, aspectRatio?: number): void;
  29966. /**
  29967. * Clones the current image processing instance.
  29968. * @return The cloned image processing
  29969. */
  29970. clone(): ImageProcessingConfiguration;
  29971. /**
  29972. * Serializes the current image processing instance to a json representation.
  29973. * @return a JSON representation
  29974. */
  29975. serialize(): any;
  29976. /**
  29977. * Parses the image processing from a json representation.
  29978. * @param source the JSON source to parse
  29979. * @return The parsed image processing
  29980. */
  29981. static Parse(source: any): ImageProcessingConfiguration;
  29982. private static _VIGNETTEMODE_MULTIPLY;
  29983. private static _VIGNETTEMODE_OPAQUE;
  29984. /**
  29985. * Used to apply the vignette as a mix with the pixel color.
  29986. */
  29987. static readonly VIGNETTEMODE_MULTIPLY: number;
  29988. /**
  29989. * Used to apply the vignette as a replacement of the pixel color.
  29990. */
  29991. static readonly VIGNETTEMODE_OPAQUE: number;
  29992. }
  29993. }
  29994. declare module BABYLON {
  29995. /**
  29996. * This represents all the required information to add a fresnel effect on a material:
  29997. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29998. */
  29999. export class FresnelParameters {
  30000. private _isEnabled;
  30001. /**
  30002. * Define if the fresnel effect is enable or not.
  30003. */
  30004. isEnabled: boolean;
  30005. /**
  30006. * Define the color used on edges (grazing angle)
  30007. */
  30008. leftColor: Color3;
  30009. /**
  30010. * Define the color used on center
  30011. */
  30012. rightColor: Color3;
  30013. /**
  30014. * Define bias applied to computed fresnel term
  30015. */
  30016. bias: number;
  30017. /**
  30018. * Defined the power exponent applied to fresnel term
  30019. */
  30020. power: number;
  30021. /**
  30022. * Clones the current fresnel and its valuues
  30023. * @returns a clone fresnel configuration
  30024. */
  30025. clone(): FresnelParameters;
  30026. /**
  30027. * Serializes the current fresnel parameters to a JSON representation.
  30028. * @return the JSON serialization
  30029. */
  30030. serialize(): any;
  30031. /**
  30032. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30033. * @param parsedFresnelParameters Define the JSON representation
  30034. * @returns the parsed parameters
  30035. */
  30036. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30037. }
  30038. }
  30039. declare module BABYLON {
  30040. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30041. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30042. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30043. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30044. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30045. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30046. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30047. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30048. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30049. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30050. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30051. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30052. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30053. /**
  30054. * Decorator used to define property that can be serialized as reference to a camera
  30055. * @param sourceName defines the name of the property to decorate
  30056. */
  30057. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30058. /**
  30059. * Class used to help serialization objects
  30060. */
  30061. export class SerializationHelper {
  30062. /** hidden */
  30063. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30064. /** hidden */
  30065. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30066. /** hidden */
  30067. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30068. /** hidden */
  30069. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30070. /**
  30071. * Appends the serialized animations from the source animations
  30072. * @param source Source containing the animations
  30073. * @param destination Target to store the animations
  30074. */
  30075. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30076. /**
  30077. * Static function used to serialized a specific entity
  30078. * @param entity defines the entity to serialize
  30079. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30080. * @returns a JSON compatible object representing the serialization of the entity
  30081. */
  30082. static Serialize<T>(entity: T, serializationObject?: any): any;
  30083. /**
  30084. * Creates a new entity from a serialization data object
  30085. * @param creationFunction defines a function used to instanciated the new entity
  30086. * @param source defines the source serialization data
  30087. * @param scene defines the hosting scene
  30088. * @param rootUrl defines the root url for resources
  30089. * @returns a new entity
  30090. */
  30091. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30092. /**
  30093. * Clones an object
  30094. * @param creationFunction defines the function used to instanciate the new object
  30095. * @param source defines the source object
  30096. * @returns the cloned object
  30097. */
  30098. static Clone<T>(creationFunction: () => T, source: T): T;
  30099. /**
  30100. * Instanciates a new object based on a source one (some data will be shared between both object)
  30101. * @param creationFunction defines the function used to instanciate the new object
  30102. * @param source defines the source object
  30103. * @returns the new object
  30104. */
  30105. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30106. }
  30107. }
  30108. declare module BABYLON {
  30109. /**
  30110. * This is the base class of all the camera used in the application.
  30111. * @see http://doc.babylonjs.com/features/cameras
  30112. */
  30113. export class Camera extends Node {
  30114. /** @hidden */
  30115. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30116. /**
  30117. * This is the default projection mode used by the cameras.
  30118. * It helps recreating a feeling of perspective and better appreciate depth.
  30119. * This is the best way to simulate real life cameras.
  30120. */
  30121. static readonly PERSPECTIVE_CAMERA: number;
  30122. /**
  30123. * This helps creating camera with an orthographic mode.
  30124. * 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.
  30125. */
  30126. static readonly ORTHOGRAPHIC_CAMERA: number;
  30127. /**
  30128. * This is the default FOV mode for perspective cameras.
  30129. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30130. */
  30131. static readonly FOVMODE_VERTICAL_FIXED: number;
  30132. /**
  30133. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30134. */
  30135. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30136. /**
  30137. * This specifies ther is no need for a camera rig.
  30138. * Basically only one eye is rendered corresponding to the camera.
  30139. */
  30140. static readonly RIG_MODE_NONE: number;
  30141. /**
  30142. * Simulates a camera Rig with one blue eye and one red eye.
  30143. * This can be use with 3d blue and red glasses.
  30144. */
  30145. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30146. /**
  30147. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30148. */
  30149. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30150. /**
  30151. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30152. */
  30153. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30154. /**
  30155. * Defines that both eyes of the camera will be rendered over under each other.
  30156. */
  30157. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30158. /**
  30159. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30160. */
  30161. static readonly RIG_MODE_VR: number;
  30162. /**
  30163. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30164. */
  30165. static readonly RIG_MODE_WEBVR: number;
  30166. /**
  30167. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30168. */
  30169. static readonly RIG_MODE_CUSTOM: number;
  30170. /**
  30171. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30172. */
  30173. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30174. /**
  30175. * Define the input manager associated with the camera.
  30176. */
  30177. inputs: CameraInputsManager<Camera>;
  30178. /** @hidden */
  30179. _position: Vector3;
  30180. /**
  30181. * Define the current local position of the camera in the scene
  30182. */
  30183. position: Vector3;
  30184. /**
  30185. * The vector the camera should consider as up.
  30186. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30187. */
  30188. upVector: Vector3;
  30189. /**
  30190. * Define the current limit on the left side for an orthographic camera
  30191. * In scene unit
  30192. */
  30193. orthoLeft: Nullable<number>;
  30194. /**
  30195. * Define the current limit on the right side for an orthographic camera
  30196. * In scene unit
  30197. */
  30198. orthoRight: Nullable<number>;
  30199. /**
  30200. * Define the current limit on the bottom side for an orthographic camera
  30201. * In scene unit
  30202. */
  30203. orthoBottom: Nullable<number>;
  30204. /**
  30205. * Define the current limit on the top side for an orthographic camera
  30206. * In scene unit
  30207. */
  30208. orthoTop: Nullable<number>;
  30209. /**
  30210. * Field Of View is set in Radians. (default is 0.8)
  30211. */
  30212. fov: number;
  30213. /**
  30214. * Define the minimum distance the camera can see from.
  30215. * This is important to note that the depth buffer are not infinite and the closer it starts
  30216. * the more your scene might encounter depth fighting issue.
  30217. */
  30218. minZ: number;
  30219. /**
  30220. * Define the maximum distance the camera can see to.
  30221. * This is important to note that the depth buffer are not infinite and the further it end
  30222. * the more your scene might encounter depth fighting issue.
  30223. */
  30224. maxZ: number;
  30225. /**
  30226. * Define the default inertia of the camera.
  30227. * This helps giving a smooth feeling to the camera movement.
  30228. */
  30229. inertia: number;
  30230. /**
  30231. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30232. */
  30233. mode: number;
  30234. /**
  30235. * Define wether the camera is intermediate.
  30236. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30237. */
  30238. isIntermediate: boolean;
  30239. /**
  30240. * Define the viewport of the camera.
  30241. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30242. */
  30243. viewport: Viewport;
  30244. /**
  30245. * Restricts the camera to viewing objects with the same layerMask.
  30246. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30247. */
  30248. layerMask: number;
  30249. /**
  30250. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30251. */
  30252. fovMode: number;
  30253. /**
  30254. * Rig mode of the camera.
  30255. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30256. * This is normally controlled byt the camera themselves as internal use.
  30257. */
  30258. cameraRigMode: number;
  30259. /**
  30260. * Defines the distance between both "eyes" in case of a RIG
  30261. */
  30262. interaxialDistance: number;
  30263. /**
  30264. * Defines if stereoscopic rendering is done side by side or over under.
  30265. */
  30266. isStereoscopicSideBySide: boolean;
  30267. /**
  30268. * 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
  30269. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30270. * else in the scene.
  30271. */
  30272. customRenderTargets: RenderTargetTexture[];
  30273. /**
  30274. * When set, the camera will render to this render target instead of the default canvas
  30275. */
  30276. outputRenderTarget: Nullable<RenderTargetTexture>;
  30277. /**
  30278. * @hidden
  30279. * 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)
  30280. */
  30281. _useMultiviewToSingleView: boolean;
  30282. /**
  30283. * @hidden
  30284. * 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)
  30285. */
  30286. _multiviewTexture: Nullable<RenderTargetTexture>;
  30287. /**
  30288. * @hidden
  30289. * ensures the multiview texture of the camera exists and has the specified width/height
  30290. * @param width height to set on the multiview texture
  30291. * @param height width to set on the multiview texture
  30292. */
  30293. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  30294. /**
  30295. * Observable triggered when the camera view matrix has changed.
  30296. */
  30297. onViewMatrixChangedObservable: Observable<Camera>;
  30298. /**
  30299. * Observable triggered when the camera Projection matrix has changed.
  30300. */
  30301. onProjectionMatrixChangedObservable: Observable<Camera>;
  30302. /**
  30303. * Observable triggered when the inputs have been processed.
  30304. */
  30305. onAfterCheckInputsObservable: Observable<Camera>;
  30306. /**
  30307. * Observable triggered when reset has been called and applied to the camera.
  30308. */
  30309. onRestoreStateObservable: Observable<Camera>;
  30310. /** @hidden */
  30311. _cameraRigParams: any;
  30312. /** @hidden */
  30313. _rigCameras: Camera[];
  30314. /** @hidden */
  30315. _rigPostProcess: Nullable<PostProcess>;
  30316. protected _webvrViewMatrix: Matrix;
  30317. /** @hidden */
  30318. _skipRendering: boolean;
  30319. /** @hidden */
  30320. _projectionMatrix: Matrix;
  30321. /** @hidden */
  30322. _postProcesses: Nullable<PostProcess>[];
  30323. /** @hidden */
  30324. _activeMeshes: SmartArray<AbstractMesh>;
  30325. protected _globalPosition: Vector3;
  30326. /** hidden */
  30327. _computedViewMatrix: Matrix;
  30328. private _doNotComputeProjectionMatrix;
  30329. private _transformMatrix;
  30330. private _frustumPlanes;
  30331. private _refreshFrustumPlanes;
  30332. private _storedFov;
  30333. private _stateStored;
  30334. /**
  30335. * Instantiates a new camera object.
  30336. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30337. * @see http://doc.babylonjs.com/features/cameras
  30338. * @param name Defines the name of the camera in the scene
  30339. * @param position Defines the position of the camera
  30340. * @param scene Defines the scene the camera belongs too
  30341. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30342. */
  30343. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30344. /**
  30345. * Store current camera state (fov, position, etc..)
  30346. * @returns the camera
  30347. */
  30348. storeState(): Camera;
  30349. /**
  30350. * Restores the camera state values if it has been stored. You must call storeState() first
  30351. */
  30352. protected _restoreStateValues(): boolean;
  30353. /**
  30354. * Restored camera state. You must call storeState() first.
  30355. * @returns true if restored and false otherwise
  30356. */
  30357. restoreState(): boolean;
  30358. /**
  30359. * Gets the class name of the camera.
  30360. * @returns the class name
  30361. */
  30362. getClassName(): string;
  30363. /** @hidden */
  30364. readonly _isCamera: boolean;
  30365. /**
  30366. * Gets a string representation of the camera useful for debug purpose.
  30367. * @param fullDetails Defines that a more verboe level of logging is required
  30368. * @returns the string representation
  30369. */
  30370. toString(fullDetails?: boolean): string;
  30371. /**
  30372. * Gets the current world space position of the camera.
  30373. */
  30374. readonly globalPosition: Vector3;
  30375. /**
  30376. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30377. * @returns the active meshe list
  30378. */
  30379. getActiveMeshes(): SmartArray<AbstractMesh>;
  30380. /**
  30381. * Check wether a mesh is part of the current active mesh list of the camera
  30382. * @param mesh Defines the mesh to check
  30383. * @returns true if active, false otherwise
  30384. */
  30385. isActiveMesh(mesh: Mesh): boolean;
  30386. /**
  30387. * Is this camera ready to be used/rendered
  30388. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30389. * @return true if the camera is ready
  30390. */
  30391. isReady(completeCheck?: boolean): boolean;
  30392. /** @hidden */
  30393. _initCache(): void;
  30394. /** @hidden */
  30395. _updateCache(ignoreParentClass?: boolean): void;
  30396. /** @hidden */
  30397. _isSynchronized(): boolean;
  30398. /** @hidden */
  30399. _isSynchronizedViewMatrix(): boolean;
  30400. /** @hidden */
  30401. _isSynchronizedProjectionMatrix(): boolean;
  30402. /**
  30403. * Attach the input controls to a specific dom element to get the input from.
  30404. * @param element Defines the element the controls should be listened from
  30405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30406. */
  30407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30408. /**
  30409. * Detach the current controls from the specified dom element.
  30410. * @param element Defines the element to stop listening the inputs from
  30411. */
  30412. detachControl(element: HTMLElement): void;
  30413. /**
  30414. * Update the camera state according to the different inputs gathered during the frame.
  30415. */
  30416. update(): void;
  30417. /** @hidden */
  30418. _checkInputs(): void;
  30419. /** @hidden */
  30420. readonly rigCameras: Camera[];
  30421. /**
  30422. * Gets the post process used by the rig cameras
  30423. */
  30424. readonly rigPostProcess: Nullable<PostProcess>;
  30425. /**
  30426. * Internal, gets the first post proces.
  30427. * @returns the first post process to be run on this camera.
  30428. */
  30429. _getFirstPostProcess(): Nullable<PostProcess>;
  30430. private _cascadePostProcessesToRigCams;
  30431. /**
  30432. * Attach a post process to the camera.
  30433. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30434. * @param postProcess The post process to attach to the camera
  30435. * @param insertAt The position of the post process in case several of them are in use in the scene
  30436. * @returns the position the post process has been inserted at
  30437. */
  30438. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30439. /**
  30440. * Detach a post process to the camera.
  30441. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30442. * @param postProcess The post process to detach from the camera
  30443. */
  30444. detachPostProcess(postProcess: PostProcess): void;
  30445. /**
  30446. * Gets the current world matrix of the camera
  30447. */
  30448. getWorldMatrix(): Matrix;
  30449. /** @hidden */
  30450. _getViewMatrix(): Matrix;
  30451. /**
  30452. * Gets the current view matrix of the camera.
  30453. * @param force forces the camera to recompute the matrix without looking at the cached state
  30454. * @returns the view matrix
  30455. */
  30456. getViewMatrix(force?: boolean): Matrix;
  30457. /**
  30458. * Freeze the projection matrix.
  30459. * It will prevent the cache check of the camera projection compute and can speed up perf
  30460. * if no parameter of the camera are meant to change
  30461. * @param projection Defines manually a projection if necessary
  30462. */
  30463. freezeProjectionMatrix(projection?: Matrix): void;
  30464. /**
  30465. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30466. */
  30467. unfreezeProjectionMatrix(): void;
  30468. /**
  30469. * Gets the current projection matrix of the camera.
  30470. * @param force forces the camera to recompute the matrix without looking at the cached state
  30471. * @returns the projection matrix
  30472. */
  30473. getProjectionMatrix(force?: boolean): Matrix;
  30474. /**
  30475. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30476. * @returns a Matrix
  30477. */
  30478. getTransformationMatrix(): Matrix;
  30479. private _updateFrustumPlanes;
  30480. /**
  30481. * Checks if a cullable object (mesh...) is in the camera frustum
  30482. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30483. * @param target The object to check
  30484. * @returns true if the object is in frustum otherwise false
  30485. */
  30486. isInFrustum(target: ICullable): boolean;
  30487. /**
  30488. * Checks if a cullable object (mesh...) is in the camera frustum
  30489. * Unlike isInFrustum this cheks the full bounding box
  30490. * @param target The object to check
  30491. * @returns true if the object is in frustum otherwise false
  30492. */
  30493. isCompletelyInFrustum(target: ICullable): boolean;
  30494. /**
  30495. * Gets a ray in the forward direction from the camera.
  30496. * @param length Defines the length of the ray to create
  30497. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30498. * @param origin Defines the start point of the ray which defaults to the camera position
  30499. * @returns the forward ray
  30500. */
  30501. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30502. /**
  30503. * Releases resources associated with this node.
  30504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30506. */
  30507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30508. /** @hidden */
  30509. _isLeftCamera: boolean;
  30510. /**
  30511. * Gets the left camera of a rig setup in case of Rigged Camera
  30512. */
  30513. readonly isLeftCamera: boolean;
  30514. /** @hidden */
  30515. _isRightCamera: boolean;
  30516. /**
  30517. * Gets the right camera of a rig setup in case of Rigged Camera
  30518. */
  30519. readonly isRightCamera: boolean;
  30520. /**
  30521. * Gets the left camera of a rig setup in case of Rigged Camera
  30522. */
  30523. readonly leftCamera: Nullable<FreeCamera>;
  30524. /**
  30525. * Gets the right camera of a rig setup in case of Rigged Camera
  30526. */
  30527. readonly rightCamera: Nullable<FreeCamera>;
  30528. /**
  30529. * Gets the left camera target of a rig setup in case of Rigged Camera
  30530. * @returns the target position
  30531. */
  30532. getLeftTarget(): Nullable<Vector3>;
  30533. /**
  30534. * Gets the right camera target of a rig setup in case of Rigged Camera
  30535. * @returns the target position
  30536. */
  30537. getRightTarget(): Nullable<Vector3>;
  30538. /**
  30539. * @hidden
  30540. */
  30541. setCameraRigMode(mode: number, rigParams: any): void;
  30542. /** @hidden */
  30543. static _setStereoscopicRigMode(camera: Camera): void;
  30544. /** @hidden */
  30545. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30546. /** @hidden */
  30547. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30548. /** @hidden */
  30549. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30550. /** @hidden */
  30551. _getVRProjectionMatrix(): Matrix;
  30552. protected _updateCameraRotationMatrix(): void;
  30553. protected _updateWebVRCameraRotationMatrix(): void;
  30554. /**
  30555. * This function MUST be overwritten by the different WebVR cameras available.
  30556. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30557. * @hidden
  30558. */
  30559. _getWebVRProjectionMatrix(): Matrix;
  30560. /**
  30561. * This function MUST be overwritten by the different WebVR cameras available.
  30562. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30563. * @hidden
  30564. */
  30565. _getWebVRViewMatrix(): Matrix;
  30566. /** @hidden */
  30567. setCameraRigParameter(name: string, value: any): void;
  30568. /**
  30569. * needs to be overridden by children so sub has required properties to be copied
  30570. * @hidden
  30571. */
  30572. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30573. /**
  30574. * May need to be overridden by children
  30575. * @hidden
  30576. */
  30577. _updateRigCameras(): void;
  30578. /** @hidden */
  30579. _setupInputs(): void;
  30580. /**
  30581. * Serialiaze the camera setup to a json represention
  30582. * @returns the JSON representation
  30583. */
  30584. serialize(): any;
  30585. /**
  30586. * Clones the current camera.
  30587. * @param name The cloned camera name
  30588. * @returns the cloned camera
  30589. */
  30590. clone(name: string): Camera;
  30591. /**
  30592. * Gets the direction of the camera relative to a given local axis.
  30593. * @param localAxis Defines the reference axis to provide a relative direction.
  30594. * @return the direction
  30595. */
  30596. getDirection(localAxis: Vector3): Vector3;
  30597. /**
  30598. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30599. * @param localAxis Defines the reference axis to provide a relative direction.
  30600. * @param result Defines the vector to store the result in
  30601. */
  30602. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30603. /**
  30604. * Gets a camera constructor for a given camera type
  30605. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30606. * @param name The name of the camera the result will be able to instantiate
  30607. * @param scene The scene the result will construct the camera in
  30608. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30609. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30610. * @returns a factory method to construc the camera
  30611. */
  30612. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30613. /**
  30614. * Compute the world matrix of the camera.
  30615. * @returns the camera workd matrix
  30616. */
  30617. computeWorldMatrix(): Matrix;
  30618. /**
  30619. * Parse a JSON and creates the camera from the parsed information
  30620. * @param parsedCamera The JSON to parse
  30621. * @param scene The scene to instantiate the camera in
  30622. * @returns the newly constructed camera
  30623. */
  30624. static Parse(parsedCamera: any, scene: Scene): Camera;
  30625. }
  30626. }
  30627. declare module BABYLON {
  30628. /**
  30629. * Interface for any object that can request an animation frame
  30630. */
  30631. export interface ICustomAnimationFrameRequester {
  30632. /**
  30633. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30634. */
  30635. renderFunction?: Function;
  30636. /**
  30637. * Called to request the next frame to render to
  30638. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30639. */
  30640. requestAnimationFrame: Function;
  30641. /**
  30642. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30643. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30644. */
  30645. requestID?: number;
  30646. }
  30647. /**
  30648. * Interface containing an array of animations
  30649. */
  30650. export interface IAnimatable {
  30651. /**
  30652. * Array of animations
  30653. */
  30654. animations: Array<Animation>;
  30655. }
  30656. /** Interface used by value gradients (color, factor, ...) */
  30657. export interface IValueGradient {
  30658. /**
  30659. * Gets or sets the gradient value (between 0 and 1)
  30660. */
  30661. gradient: number;
  30662. }
  30663. /** Class used to store color4 gradient */
  30664. export class ColorGradient implements IValueGradient {
  30665. /**
  30666. * Gets or sets the gradient value (between 0 and 1)
  30667. */
  30668. gradient: number;
  30669. /**
  30670. * Gets or sets first associated color
  30671. */
  30672. color1: Color4;
  30673. /**
  30674. * Gets or sets second associated color
  30675. */
  30676. color2?: Color4;
  30677. /**
  30678. * Will get a color picked randomly between color1 and color2.
  30679. * If color2 is undefined then color1 will be used
  30680. * @param result defines the target Color4 to store the result in
  30681. */
  30682. getColorToRef(result: Color4): void;
  30683. }
  30684. /** Class used to store color 3 gradient */
  30685. export class Color3Gradient implements IValueGradient {
  30686. /**
  30687. * Gets or sets the gradient value (between 0 and 1)
  30688. */
  30689. gradient: number;
  30690. /**
  30691. * Gets or sets the associated color
  30692. */
  30693. color: Color3;
  30694. }
  30695. /** Class used to store factor gradient */
  30696. export class FactorGradient implements IValueGradient {
  30697. /**
  30698. * Gets or sets the gradient value (between 0 and 1)
  30699. */
  30700. gradient: number;
  30701. /**
  30702. * Gets or sets first associated factor
  30703. */
  30704. factor1: number;
  30705. /**
  30706. * Gets or sets second associated factor
  30707. */
  30708. factor2?: number;
  30709. /**
  30710. * Will get a number picked randomly between factor1 and factor2.
  30711. * If factor2 is undefined then factor1 will be used
  30712. * @returns the picked number
  30713. */
  30714. getFactor(): number;
  30715. }
  30716. /**
  30717. * @ignore
  30718. * Application error to support additional information when loading a file
  30719. */
  30720. export class LoadFileError extends Error {
  30721. /** defines the optional web request */
  30722. request?: WebRequest | undefined;
  30723. private static _setPrototypeOf;
  30724. /**
  30725. * Creates a new LoadFileError
  30726. * @param message defines the message of the error
  30727. * @param request defines the optional web request
  30728. */
  30729. constructor(message: string,
  30730. /** defines the optional web request */
  30731. request?: WebRequest | undefined);
  30732. }
  30733. /**
  30734. * Class used to define a retry strategy when error happens while loading assets
  30735. */
  30736. export class RetryStrategy {
  30737. /**
  30738. * Function used to defines an exponential back off strategy
  30739. * @param maxRetries defines the maximum number of retries (3 by default)
  30740. * @param baseInterval defines the interval between retries
  30741. * @returns the strategy function to use
  30742. */
  30743. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30744. }
  30745. /**
  30746. * File request interface
  30747. */
  30748. export interface IFileRequest {
  30749. /**
  30750. * Raised when the request is complete (success or error).
  30751. */
  30752. onCompleteObservable: Observable<IFileRequest>;
  30753. /**
  30754. * Aborts the request for a file.
  30755. */
  30756. abort: () => void;
  30757. }
  30758. /**
  30759. * Class containing a set of static utilities functions
  30760. */
  30761. export class Tools {
  30762. /**
  30763. * Gets or sets the base URL to use to load assets
  30764. */
  30765. static BaseUrl: string;
  30766. /**
  30767. * Enable/Disable Custom HTTP Request Headers globally.
  30768. * default = false
  30769. * @see CustomRequestHeaders
  30770. */
  30771. static UseCustomRequestHeaders: boolean;
  30772. /**
  30773. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30774. * i.e. when loading files, where the server/service expects an Authorization header
  30775. */
  30776. static CustomRequestHeaders: {
  30777. [key: string]: string;
  30778. };
  30779. /**
  30780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30781. */
  30782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30783. /**
  30784. * Default behaviour for cors in the application.
  30785. * It can be a string if the expected behavior is identical in the entire app.
  30786. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30787. */
  30788. static CorsBehavior: string | ((url: string | string[]) => string);
  30789. /**
  30790. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30791. * @ignorenaming
  30792. */
  30793. static UseFallbackTexture: boolean;
  30794. /**
  30795. * Use this object to register external classes like custom textures or material
  30796. * to allow the laoders to instantiate them
  30797. */
  30798. static RegisteredExternalClasses: {
  30799. [key: string]: Object;
  30800. };
  30801. /**
  30802. * Texture content used if a texture cannot loaded
  30803. * @ignorenaming
  30804. */
  30805. static fallbackTexture: string;
  30806. /**
  30807. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30808. * @param u defines the coordinate on X axis
  30809. * @param v defines the coordinate on Y axis
  30810. * @param width defines the width of the source data
  30811. * @param height defines the height of the source data
  30812. * @param pixels defines the source byte array
  30813. * @param color defines the output color
  30814. */
  30815. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30816. /**
  30817. * Interpolates between a and b via alpha
  30818. * @param a The lower value (returned when alpha = 0)
  30819. * @param b The upper value (returned when alpha = 1)
  30820. * @param alpha The interpolation-factor
  30821. * @return The mixed value
  30822. */
  30823. static Mix(a: number, b: number, alpha: number): number;
  30824. /**
  30825. * Tries to instantiate a new object from a given class name
  30826. * @param className defines the class name to instantiate
  30827. * @returns the new object or null if the system was not able to do the instantiation
  30828. */
  30829. static Instantiate(className: string): any;
  30830. /**
  30831. * Provides a slice function that will work even on IE
  30832. * @param data defines the array to slice
  30833. * @param start defines the start of the data (optional)
  30834. * @param end defines the end of the data (optional)
  30835. * @returns the new sliced array
  30836. */
  30837. static Slice<T>(data: T, start?: number, end?: number): T;
  30838. /**
  30839. * Polyfill for setImmediate
  30840. * @param action defines the action to execute after the current execution block
  30841. */
  30842. static SetImmediate(action: () => void): void;
  30843. /**
  30844. * Function indicating if a number is an exponent of 2
  30845. * @param value defines the value to test
  30846. * @returns true if the value is an exponent of 2
  30847. */
  30848. static IsExponentOfTwo(value: number): boolean;
  30849. private static _tmpFloatArray;
  30850. /**
  30851. * Returns the nearest 32-bit single precision float representation of a Number
  30852. * @param value A Number. If the parameter is of a different type, it will get converted
  30853. * to a number or to NaN if it cannot be converted
  30854. * @returns number
  30855. */
  30856. static FloatRound(value: number): number;
  30857. /**
  30858. * Find the next highest power of two.
  30859. * @param x Number to start search from.
  30860. * @return Next highest power of two.
  30861. */
  30862. static CeilingPOT(x: number): number;
  30863. /**
  30864. * Find the next lowest power of two.
  30865. * @param x Number to start search from.
  30866. * @return Next lowest power of two.
  30867. */
  30868. static FloorPOT(x: number): number;
  30869. /**
  30870. * Find the nearest power of two.
  30871. * @param x Number to start search from.
  30872. * @return Next nearest power of two.
  30873. */
  30874. static NearestPOT(x: number): number;
  30875. /**
  30876. * Get the closest exponent of two
  30877. * @param value defines the value to approximate
  30878. * @param max defines the maximum value to return
  30879. * @param mode defines how to define the closest value
  30880. * @returns closest exponent of two of the given value
  30881. */
  30882. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30883. /**
  30884. * Extracts the filename from a path
  30885. * @param path defines the path to use
  30886. * @returns the filename
  30887. */
  30888. static GetFilename(path: string): string;
  30889. /**
  30890. * Extracts the "folder" part of a path (everything before the filename).
  30891. * @param uri The URI to extract the info from
  30892. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30893. * @returns The "folder" part of the path
  30894. */
  30895. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30896. /**
  30897. * Extracts text content from a DOM element hierarchy
  30898. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30899. */
  30900. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30901. /**
  30902. * Convert an angle in radians to degrees
  30903. * @param angle defines the angle to convert
  30904. * @returns the angle in degrees
  30905. */
  30906. static ToDegrees(angle: number): number;
  30907. /**
  30908. * Convert an angle in degrees to radians
  30909. * @param angle defines the angle to convert
  30910. * @returns the angle in radians
  30911. */
  30912. static ToRadians(angle: number): number;
  30913. /**
  30914. * Encode a buffer to a base64 string
  30915. * @param buffer defines the buffer to encode
  30916. * @returns the encoded string
  30917. */
  30918. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30919. /**
  30920. * Extracts minimum and maximum values from a list of indexed positions
  30921. * @param positions defines the positions to use
  30922. * @param indices defines the indices to the positions
  30923. * @param indexStart defines the start index
  30924. * @param indexCount defines the end index
  30925. * @param bias defines bias value to add to the result
  30926. * @return minimum and maximum values
  30927. */
  30928. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30929. minimum: Vector3;
  30930. maximum: Vector3;
  30931. };
  30932. /**
  30933. * Extracts minimum and maximum values from a list of positions
  30934. * @param positions defines the positions to use
  30935. * @param start defines the start index in the positions array
  30936. * @param count defines the number of positions to handle
  30937. * @param bias defines bias value to add to the result
  30938. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30939. * @return minimum and maximum values
  30940. */
  30941. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30942. minimum: Vector3;
  30943. maximum: Vector3;
  30944. };
  30945. /**
  30946. * Returns an array if obj is not an array
  30947. * @param obj defines the object to evaluate as an array
  30948. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30949. * @returns either obj directly if obj is an array or a new array containing obj
  30950. */
  30951. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30952. /**
  30953. * Gets the pointer prefix to use
  30954. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30955. */
  30956. static GetPointerPrefix(): string;
  30957. /**
  30958. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30959. * @param func - the function to be called
  30960. * @param requester - the object that will request the next frame. Falls back to window.
  30961. * @returns frame number
  30962. */
  30963. static QueueNewFrame(func: () => void, requester?: any): number;
  30964. /**
  30965. * Ask the browser to promote the current element to fullscreen rendering mode
  30966. * @param element defines the DOM element to promote
  30967. */
  30968. static RequestFullscreen(element: HTMLElement): void;
  30969. /**
  30970. * Asks the browser to exit fullscreen mode
  30971. */
  30972. static ExitFullscreen(): void;
  30973. /**
  30974. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30975. * @param url define the url we are trying
  30976. * @param element define the dom element where to configure the cors policy
  30977. */
  30978. static SetCorsBehavior(url: string | string[], element: {
  30979. crossOrigin: string | null;
  30980. }): void;
  30981. /**
  30982. * Removes unwanted characters from an url
  30983. * @param url defines the url to clean
  30984. * @returns the cleaned url
  30985. */
  30986. static CleanUrl(url: string): string;
  30987. /**
  30988. * Gets or sets a function used to pre-process url before using them to load assets
  30989. */
  30990. static PreprocessUrl: (url: string) => string;
  30991. /**
  30992. * Loads an image as an HTMLImageElement.
  30993. * @param input url string, ArrayBuffer, or Blob to load
  30994. * @param onLoad callback called when the image successfully loads
  30995. * @param onError callback called when the image fails to load
  30996. * @param offlineProvider offline provider for caching
  30997. * @returns the HTMLImageElement of the loaded image
  30998. */
  30999. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31000. /**
  31001. * Loads a file
  31002. * @param url url string, ArrayBuffer, or Blob to load
  31003. * @param onSuccess callback called when the file successfully loads
  31004. * @param onProgress callback called while file is loading (if the server supports this mode)
  31005. * @param offlineProvider defines the offline provider for caching
  31006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31007. * @param onError callback called when the file fails to load
  31008. * @returns a file request object
  31009. */
  31010. 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;
  31011. /**
  31012. * Load a script (identified by an url). When the url returns, the
  31013. * content of this file is added into a new script element, attached to the DOM (body element)
  31014. * @param scriptUrl defines the url of the script to laod
  31015. * @param onSuccess defines the callback called when the script is loaded
  31016. * @param onError defines the callback to call if an error occurs
  31017. */
  31018. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31019. /**
  31020. * Loads a file from a blob
  31021. * @param fileToLoad defines the blob to use
  31022. * @param callback defines the callback to call when data is loaded
  31023. * @param progressCallback defines the callback to call during loading process
  31024. * @returns a file request object
  31025. */
  31026. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31027. /**
  31028. * Loads a file
  31029. * @param fileToLoad defines the file to load
  31030. * @param callback defines the callback to call when data is loaded
  31031. * @param progressCallBack defines the callback to call during loading process
  31032. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31033. * @returns a file request object
  31034. */
  31035. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31036. /**
  31037. * Creates a data url from a given string content
  31038. * @param content defines the content to convert
  31039. * @returns the new data url link
  31040. */
  31041. static FileAsURL(content: string): string;
  31042. /**
  31043. * Format the given number to a specific decimal format
  31044. * @param value defines the number to format
  31045. * @param decimals defines the number of decimals to use
  31046. * @returns the formatted string
  31047. */
  31048. static Format(value: number, decimals?: number): string;
  31049. /**
  31050. * Checks if a given vector is inside a specific range
  31051. * @param v defines the vector to test
  31052. * @param min defines the minimum range
  31053. * @param max defines the maximum range
  31054. */
  31055. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31056. /**
  31057. * Tries to copy an object by duplicating every property
  31058. * @param source defines the source object
  31059. * @param destination defines the target object
  31060. * @param doNotCopyList defines a list of properties to avoid
  31061. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31062. */
  31063. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31064. /**
  31065. * Gets a boolean indicating if the given object has no own property
  31066. * @param obj defines the object to test
  31067. * @returns true if object has no own property
  31068. */
  31069. static IsEmpty(obj: any): boolean;
  31070. /**
  31071. * Function used to register events at window level
  31072. * @param events defines the events to register
  31073. */
  31074. static RegisterTopRootEvents(events: {
  31075. name: string;
  31076. handler: Nullable<(e: FocusEvent) => any>;
  31077. }[]): void;
  31078. /**
  31079. * Function used to unregister events from window level
  31080. * @param events defines the events to unregister
  31081. */
  31082. static UnregisterTopRootEvents(events: {
  31083. name: string;
  31084. handler: Nullable<(e: FocusEvent) => any>;
  31085. }[]): void;
  31086. /**
  31087. * @ignore
  31088. */
  31089. static _ScreenshotCanvas: HTMLCanvasElement;
  31090. /**
  31091. * Dumps the current bound framebuffer
  31092. * @param width defines the rendering width
  31093. * @param height defines the rendering height
  31094. * @param engine defines the hosting engine
  31095. * @param successCallback defines the callback triggered once the data are available
  31096. * @param mimeType defines the mime type of the result
  31097. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31098. */
  31099. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31100. /**
  31101. * Converts the canvas data to blob.
  31102. * This acts as a polyfill for browsers not supporting the to blob function.
  31103. * @param canvas Defines the canvas to extract the data from
  31104. * @param successCallback Defines the callback triggered once the data are available
  31105. * @param mimeType Defines the mime type of the result
  31106. */
  31107. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31108. /**
  31109. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31110. * @param successCallback defines the callback triggered once the data are available
  31111. * @param mimeType defines the mime type of the result
  31112. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31113. */
  31114. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31115. /**
  31116. * Downloads a blob in the browser
  31117. * @param blob defines the blob to download
  31118. * @param fileName defines the name of the downloaded file
  31119. */
  31120. static Download(blob: Blob, fileName: string): void;
  31121. /**
  31122. * Captures a screenshot of the current rendering
  31123. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31124. * @param engine defines the rendering engine
  31125. * @param camera defines the source camera
  31126. * @param size This parameter can be set to a single number or to an object with the
  31127. * following (optional) properties: precision, width, height. If a single number is passed,
  31128. * it will be used for both width and height. If an object is passed, the screenshot size
  31129. * will be derived from the parameters. The precision property is a multiplier allowing
  31130. * rendering at a higher or lower resolution
  31131. * @param successCallback defines the callback receives a single parameter which contains the
  31132. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31133. * src parameter of an <img> to display it
  31134. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31135. * Check your browser for supported MIME types
  31136. */
  31137. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31138. /**
  31139. * Generates an image screenshot from the specified camera.
  31140. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31141. * @param engine The engine to use for rendering
  31142. * @param camera The camera to use for rendering
  31143. * @param size This parameter can be set to a single number or to an object with the
  31144. * following (optional) properties: precision, width, height. If a single number is passed,
  31145. * it will be used for both width and height. If an object is passed, the screenshot size
  31146. * will be derived from the parameters. The precision property is a multiplier allowing
  31147. * rendering at a higher or lower resolution
  31148. * @param successCallback The callback receives a single parameter which contains the
  31149. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31150. * src parameter of an <img> to display it
  31151. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31152. * Check your browser for supported MIME types
  31153. * @param samples Texture samples (default: 1)
  31154. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31155. * @param fileName A name for for the downloaded file.
  31156. */
  31157. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31158. /**
  31159. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31160. * Be aware Math.random() could cause collisions, but:
  31161. * "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"
  31162. * @returns a pseudo random id
  31163. */
  31164. static RandomId(): string;
  31165. /**
  31166. * Test if the given uri is a base64 string
  31167. * @param uri The uri to test
  31168. * @return True if the uri is a base64 string or false otherwise
  31169. */
  31170. static IsBase64(uri: string): boolean;
  31171. /**
  31172. * Decode the given base64 uri.
  31173. * @param uri The uri to decode
  31174. * @return The decoded base64 data.
  31175. */
  31176. static DecodeBase64(uri: string): ArrayBuffer;
  31177. /**
  31178. * No log
  31179. */
  31180. static readonly NoneLogLevel: number;
  31181. /**
  31182. * Only message logs
  31183. */
  31184. static readonly MessageLogLevel: number;
  31185. /**
  31186. * Only warning logs
  31187. */
  31188. static readonly WarningLogLevel: number;
  31189. /**
  31190. * Only error logs
  31191. */
  31192. static readonly ErrorLogLevel: number;
  31193. /**
  31194. * All logs
  31195. */
  31196. static readonly AllLogLevel: number;
  31197. /**
  31198. * Gets a value indicating the number of loading errors
  31199. * @ignorenaming
  31200. */
  31201. static readonly errorsCount: number;
  31202. /**
  31203. * Callback called when a new log is added
  31204. */
  31205. static OnNewCacheEntry: (entry: string) => void;
  31206. /**
  31207. * Log a message to the console
  31208. * @param message defines the message to log
  31209. */
  31210. static Log(message: string): void;
  31211. /**
  31212. * Write a warning message to the console
  31213. * @param message defines the message to log
  31214. */
  31215. static Warn(message: string): void;
  31216. /**
  31217. * Write an error message to the console
  31218. * @param message defines the message to log
  31219. */
  31220. static Error(message: string): void;
  31221. /**
  31222. * Gets current log cache (list of logs)
  31223. */
  31224. static readonly LogCache: string;
  31225. /**
  31226. * Clears the log cache
  31227. */
  31228. static ClearLogCache(): void;
  31229. /**
  31230. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31231. */
  31232. static LogLevels: number;
  31233. /**
  31234. * Checks if the loaded document was accessed via `file:`-Protocol.
  31235. * @returns boolean
  31236. */
  31237. static IsFileURL(): boolean;
  31238. /**
  31239. * Checks if the window object exists
  31240. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31241. */
  31242. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31243. /**
  31244. * No performance log
  31245. */
  31246. static readonly PerformanceNoneLogLevel: number;
  31247. /**
  31248. * Use user marks to log performance
  31249. */
  31250. static readonly PerformanceUserMarkLogLevel: number;
  31251. /**
  31252. * Log performance to the console
  31253. */
  31254. static readonly PerformanceConsoleLogLevel: number;
  31255. private static _performance;
  31256. /**
  31257. * Sets the current performance log level
  31258. */
  31259. static PerformanceLogLevel: number;
  31260. private static _StartPerformanceCounterDisabled;
  31261. private static _EndPerformanceCounterDisabled;
  31262. private static _StartUserMark;
  31263. private static _EndUserMark;
  31264. private static _StartPerformanceConsole;
  31265. private static _EndPerformanceConsole;
  31266. /**
  31267. * Starts a performance counter
  31268. */
  31269. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31270. /**
  31271. * Ends a specific performance coutner
  31272. */
  31273. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31274. /**
  31275. * Gets either window.performance.now() if supported or Date.now() else
  31276. */
  31277. static readonly Now: number;
  31278. /**
  31279. * This method will return the name of the class used to create the instance of the given object.
  31280. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31281. * @param object the object to get the class name from
  31282. * @param isType defines if the object is actually a type
  31283. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31284. */
  31285. static GetClassName(object: any, isType?: boolean): string;
  31286. /**
  31287. * Gets the first element of an array satisfying a given predicate
  31288. * @param array defines the array to browse
  31289. * @param predicate defines the predicate to use
  31290. * @returns null if not found or the element
  31291. */
  31292. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31293. /**
  31294. * This method will return the name of the full name of the class, including its owning module (if any).
  31295. * 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).
  31296. * @param object the object to get the class name from
  31297. * @param isType defines if the object is actually a type
  31298. * @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.
  31299. * @ignorenaming
  31300. */
  31301. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31302. /**
  31303. * Returns a promise that resolves after the given amount of time.
  31304. * @param delay Number of milliseconds to delay
  31305. * @returns Promise that resolves after the given amount of time
  31306. */
  31307. static DelayAsync(delay: number): Promise<void>;
  31308. /**
  31309. * Gets the current gradient from an array of IValueGradient
  31310. * @param ratio defines the current ratio to get
  31311. * @param gradients defines the array of IValueGradient
  31312. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31313. */
  31314. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31315. }
  31316. /**
  31317. * This class is used to track a performance counter which is number based.
  31318. * The user has access to many properties which give statistics of different nature.
  31319. *
  31320. * The implementer can track two kinds of Performance Counter: time and count.
  31321. * 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.
  31322. * 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.
  31323. */
  31324. export class PerfCounter {
  31325. /**
  31326. * Gets or sets a global boolean to turn on and off all the counters
  31327. */
  31328. static Enabled: boolean;
  31329. /**
  31330. * Returns the smallest value ever
  31331. */
  31332. readonly min: number;
  31333. /**
  31334. * Returns the biggest value ever
  31335. */
  31336. readonly max: number;
  31337. /**
  31338. * Returns the average value since the performance counter is running
  31339. */
  31340. readonly average: number;
  31341. /**
  31342. * Returns the average value of the last second the counter was monitored
  31343. */
  31344. readonly lastSecAverage: number;
  31345. /**
  31346. * Returns the current value
  31347. */
  31348. readonly current: number;
  31349. /**
  31350. * Gets the accumulated total
  31351. */
  31352. readonly total: number;
  31353. /**
  31354. * Gets the total value count
  31355. */
  31356. readonly count: number;
  31357. /**
  31358. * Creates a new counter
  31359. */
  31360. constructor();
  31361. /**
  31362. * Call this method to start monitoring a new frame.
  31363. * 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.
  31364. */
  31365. fetchNewFrame(): void;
  31366. /**
  31367. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31368. * @param newCount the count value to add to the monitored count
  31369. * @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.
  31370. */
  31371. addCount(newCount: number, fetchResult: boolean): void;
  31372. /**
  31373. * Start monitoring this performance counter
  31374. */
  31375. beginMonitoring(): void;
  31376. /**
  31377. * Compute the time lapsed since the previous beginMonitoring() call.
  31378. * @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
  31379. */
  31380. endMonitoring(newFrame?: boolean): void;
  31381. private _fetchResult;
  31382. private _startMonitoringTime;
  31383. private _min;
  31384. private _max;
  31385. private _average;
  31386. private _current;
  31387. private _totalValueCount;
  31388. private _totalAccumulated;
  31389. private _lastSecAverage;
  31390. private _lastSecAccumulated;
  31391. private _lastSecTime;
  31392. private _lastSecValueCount;
  31393. }
  31394. /**
  31395. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31396. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31397. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31398. * @param name The name of the class, case should be preserved
  31399. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31400. */
  31401. export function className(name: string, module?: string): (target: Object) => void;
  31402. /**
  31403. * An implementation of a loop for asynchronous functions.
  31404. */
  31405. export class AsyncLoop {
  31406. /**
  31407. * Defines the number of iterations for the loop
  31408. */
  31409. iterations: number;
  31410. /**
  31411. * Defines the current index of the loop.
  31412. */
  31413. index: number;
  31414. private _done;
  31415. private _fn;
  31416. private _successCallback;
  31417. /**
  31418. * Constructor.
  31419. * @param iterations the number of iterations.
  31420. * @param func the function to run each iteration
  31421. * @param successCallback the callback that will be called upon succesful execution
  31422. * @param offset starting offset.
  31423. */
  31424. constructor(
  31425. /**
  31426. * Defines the number of iterations for the loop
  31427. */
  31428. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31429. /**
  31430. * Execute the next iteration. Must be called after the last iteration was finished.
  31431. */
  31432. executeNext(): void;
  31433. /**
  31434. * Break the loop and run the success callback.
  31435. */
  31436. breakLoop(): void;
  31437. /**
  31438. * Create and run an async loop.
  31439. * @param iterations the number of iterations.
  31440. * @param fn the function to run each iteration
  31441. * @param successCallback the callback that will be called upon succesful execution
  31442. * @param offset starting offset.
  31443. * @returns the created async loop object
  31444. */
  31445. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31446. /**
  31447. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31448. * @param iterations total number of iterations
  31449. * @param syncedIterations number of synchronous iterations in each async iteration.
  31450. * @param fn the function to call each iteration.
  31451. * @param callback a success call back that will be called when iterating stops.
  31452. * @param breakFunction a break condition (optional)
  31453. * @param timeout timeout settings for the setTimeout function. default - 0.
  31454. * @returns the created async loop object
  31455. */
  31456. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31457. }
  31458. }
  31459. declare module BABYLON {
  31460. /** @hidden */
  31461. export interface ICollisionCoordinator {
  31462. createCollider(): Collider;
  31463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31464. init(scene: Scene): void;
  31465. }
  31466. /** @hidden */
  31467. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31468. private _scene;
  31469. private _scaledPosition;
  31470. private _scaledVelocity;
  31471. private _finalPosition;
  31472. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31473. createCollider(): Collider;
  31474. init(scene: Scene): void;
  31475. private _collideWithWorld;
  31476. }
  31477. }
  31478. declare module BABYLON {
  31479. /**
  31480. * This class defines the direct association between an animation and a target
  31481. */
  31482. export class TargetedAnimation {
  31483. /**
  31484. * Animation to perform
  31485. */
  31486. animation: Animation;
  31487. /**
  31488. * Target to animate
  31489. */
  31490. target: any;
  31491. }
  31492. /**
  31493. * Use this class to create coordinated animations on multiple targets
  31494. */
  31495. export class AnimationGroup implements IDisposable {
  31496. /** The name of the animation group */
  31497. name: string;
  31498. private _scene;
  31499. private _targetedAnimations;
  31500. private _animatables;
  31501. private _from;
  31502. private _to;
  31503. private _isStarted;
  31504. private _isPaused;
  31505. private _speedRatio;
  31506. /**
  31507. * Gets or sets the unique id of the node
  31508. */
  31509. uniqueId: number;
  31510. /**
  31511. * This observable will notify when one animation have ended
  31512. */
  31513. onAnimationEndObservable: Observable<TargetedAnimation>;
  31514. /**
  31515. * Observer raised when one animation loops
  31516. */
  31517. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31518. /**
  31519. * This observable will notify when all animations have ended.
  31520. */
  31521. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31522. /**
  31523. * This observable will notify when all animations have paused.
  31524. */
  31525. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31526. /**
  31527. * This observable will notify when all animations are playing.
  31528. */
  31529. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31530. /**
  31531. * Gets the first frame
  31532. */
  31533. readonly from: number;
  31534. /**
  31535. * Gets the last frame
  31536. */
  31537. readonly to: number;
  31538. /**
  31539. * Define if the animations are started
  31540. */
  31541. readonly isStarted: boolean;
  31542. /**
  31543. * Gets a value indicating that the current group is playing
  31544. */
  31545. readonly isPlaying: boolean;
  31546. /**
  31547. * Gets or sets the speed ratio to use for all animations
  31548. */
  31549. /**
  31550. * Gets or sets the speed ratio to use for all animations
  31551. */
  31552. speedRatio: number;
  31553. /**
  31554. * Gets the targeted animations for this animation group
  31555. */
  31556. readonly targetedAnimations: Array<TargetedAnimation>;
  31557. /**
  31558. * returning the list of animatables controlled by this animation group.
  31559. */
  31560. readonly animatables: Array<Animatable>;
  31561. /**
  31562. * Instantiates a new Animation Group.
  31563. * This helps managing several animations at once.
  31564. * @see http://doc.babylonjs.com/how_to/group
  31565. * @param name Defines the name of the group
  31566. * @param scene Defines the scene the group belongs to
  31567. */
  31568. constructor(
  31569. /** The name of the animation group */
  31570. name: string, scene?: Nullable<Scene>);
  31571. /**
  31572. * Add an animation (with its target) in the group
  31573. * @param animation defines the animation we want to add
  31574. * @param target defines the target of the animation
  31575. * @returns the TargetedAnimation object
  31576. */
  31577. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31578. /**
  31579. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31580. * It can add constant keys at begin or end
  31581. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31582. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31583. * @returns the animation group
  31584. */
  31585. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31586. /**
  31587. * Start all animations on given targets
  31588. * @param loop defines if animations must loop
  31589. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31590. * @param from defines the from key (optional)
  31591. * @param to defines the to key (optional)
  31592. * @returns the current animation group
  31593. */
  31594. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31595. /**
  31596. * Pause all animations
  31597. * @returns the animation group
  31598. */
  31599. pause(): AnimationGroup;
  31600. /**
  31601. * Play all animations to initial state
  31602. * This function will start() the animations if they were not started or will restart() them if they were paused
  31603. * @param loop defines if animations must loop
  31604. * @returns the animation group
  31605. */
  31606. play(loop?: boolean): AnimationGroup;
  31607. /**
  31608. * Reset all animations to initial state
  31609. * @returns the animation group
  31610. */
  31611. reset(): AnimationGroup;
  31612. /**
  31613. * Restart animations from key 0
  31614. * @returns the animation group
  31615. */
  31616. restart(): AnimationGroup;
  31617. /**
  31618. * Stop all animations
  31619. * @returns the animation group
  31620. */
  31621. stop(): AnimationGroup;
  31622. /**
  31623. * Set animation weight for all animatables
  31624. * @param weight defines the weight to use
  31625. * @return the animationGroup
  31626. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31627. */
  31628. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31629. /**
  31630. * Synchronize and normalize all animatables with a source animatable
  31631. * @param root defines the root animatable to synchronize with
  31632. * @return the animationGroup
  31633. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31634. */
  31635. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31636. /**
  31637. * Goes to a specific frame in this animation group
  31638. * @param frame the frame number to go to
  31639. * @return the animationGroup
  31640. */
  31641. goToFrame(frame: number): AnimationGroup;
  31642. /**
  31643. * Dispose all associated resources
  31644. */
  31645. dispose(): void;
  31646. private _checkAnimationGroupEnded;
  31647. /**
  31648. * Clone the current animation group and returns a copy
  31649. * @param newName defines the name of the new group
  31650. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31651. * @returns the new aniamtion group
  31652. */
  31653. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31654. /**
  31655. * Returns a new AnimationGroup object parsed from the source provided.
  31656. * @param parsedAnimationGroup defines the source
  31657. * @param scene defines the scene that will receive the animationGroup
  31658. * @returns a new AnimationGroup
  31659. */
  31660. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31661. /**
  31662. * Returns the string "AnimationGroup"
  31663. * @returns "AnimationGroup"
  31664. */
  31665. getClassName(): string;
  31666. /**
  31667. * Creates a detailled string about the object
  31668. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31669. * @returns a string representing the object
  31670. */
  31671. toString(fullDetails?: boolean): string;
  31672. }
  31673. }
  31674. declare module BABYLON {
  31675. /**
  31676. * Define an interface for all classes that will hold resources
  31677. */
  31678. export interface IDisposable {
  31679. /**
  31680. * Releases all held resources
  31681. */
  31682. dispose(): void;
  31683. }
  31684. /** Interface defining initialization parameters for Scene class */
  31685. export interface SceneOptions {
  31686. /**
  31687. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31688. * It will improve performance when the number of geometries becomes important.
  31689. */
  31690. useGeometryUniqueIdsMap?: boolean;
  31691. /**
  31692. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31693. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31694. */
  31695. useMaterialMeshMap?: boolean;
  31696. /**
  31697. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31698. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31699. */
  31700. useClonedMeshhMap?: boolean;
  31701. }
  31702. /**
  31703. * Represents a scene to be rendered by the engine.
  31704. * @see http://doc.babylonjs.com/features/scene
  31705. */
  31706. export class Scene extends AbstractScene implements IAnimatable {
  31707. private static _uniqueIdCounter;
  31708. /** The fog is deactivated */
  31709. static readonly FOGMODE_NONE: number;
  31710. /** The fog density is following an exponential function */
  31711. static readonly FOGMODE_EXP: number;
  31712. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31713. static readonly FOGMODE_EXP2: number;
  31714. /** The fog density is following a linear function. */
  31715. static readonly FOGMODE_LINEAR: number;
  31716. /**
  31717. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31719. */
  31720. static MinDeltaTime: number;
  31721. /**
  31722. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31724. */
  31725. static MaxDeltaTime: number;
  31726. /**
  31727. * Factory used to create the default material.
  31728. * @param name The name of the material to create
  31729. * @param scene The scene to create the material for
  31730. * @returns The default material
  31731. */
  31732. static DefaultMaterialFactory(scene: Scene): Material;
  31733. /**
  31734. * Factory used to create the a collision coordinator.
  31735. * @returns The collision coordinator
  31736. */
  31737. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31738. /** @hidden */
  31739. readonly _isScene: boolean;
  31740. /**
  31741. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31742. */
  31743. autoClear: boolean;
  31744. /**
  31745. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31746. */
  31747. autoClearDepthAndStencil: boolean;
  31748. /**
  31749. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31750. */
  31751. clearColor: Color4;
  31752. /**
  31753. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31754. */
  31755. ambientColor: Color3;
  31756. /**
  31757. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31758. * It should only be one of the following (if not the default embedded one):
  31759. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31760. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31761. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31762. * The material properties need to be setup according to the type of texture in use.
  31763. */
  31764. environmentBRDFTexture: BaseTexture;
  31765. /** @hidden */
  31766. protected _environmentTexture: Nullable<BaseTexture>;
  31767. /**
  31768. * Texture used in all pbr material as the reflection texture.
  31769. * As in the majority of the scene they are the same (exception for multi room and so on),
  31770. * this is easier to reference from here than from all the materials.
  31771. */
  31772. /**
  31773. * Texture used in all pbr material as the reflection texture.
  31774. * As in the majority of the scene they are the same (exception for multi room and so on),
  31775. * this is easier to set here than in all the materials.
  31776. */
  31777. environmentTexture: Nullable<BaseTexture>;
  31778. /** @hidden */
  31779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31780. /**
  31781. * Default image processing configuration used either in the rendering
  31782. * Forward main pass or through the imageProcessingPostProcess if present.
  31783. * As in the majority of the scene they are the same (exception for multi camera),
  31784. * this is easier to reference from here than from all the materials and post process.
  31785. *
  31786. * No setter as we it is a shared configuration, you can set the values instead.
  31787. */
  31788. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31789. private _forceWireframe;
  31790. /**
  31791. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31792. */
  31793. forceWireframe: boolean;
  31794. private _forcePointsCloud;
  31795. /**
  31796. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31797. */
  31798. forcePointsCloud: boolean;
  31799. /**
  31800. * Gets or sets the active clipplane 1
  31801. */
  31802. clipPlane: Nullable<Plane>;
  31803. /**
  31804. * Gets or sets the active clipplane 2
  31805. */
  31806. clipPlane2: Nullable<Plane>;
  31807. /**
  31808. * Gets or sets the active clipplane 3
  31809. */
  31810. clipPlane3: Nullable<Plane>;
  31811. /**
  31812. * Gets or sets the active clipplane 4
  31813. */
  31814. clipPlane4: Nullable<Plane>;
  31815. /**
  31816. * Gets or sets a boolean indicating if animations are enabled
  31817. */
  31818. animationsEnabled: boolean;
  31819. private _animationPropertiesOverride;
  31820. /**
  31821. * Gets or sets the animation properties override
  31822. */
  31823. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31824. /**
  31825. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31826. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31827. */
  31828. useConstantAnimationDeltaTime: boolean;
  31829. /**
  31830. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31831. * Please note that it requires to run a ray cast through the scene on every frame
  31832. */
  31833. constantlyUpdateMeshUnderPointer: boolean;
  31834. /**
  31835. * Defines the HTML cursor to use when hovering over interactive elements
  31836. */
  31837. hoverCursor: string;
  31838. /**
  31839. * Defines the HTML default cursor to use (empty by default)
  31840. */
  31841. defaultCursor: string;
  31842. /**
  31843. * This is used to call preventDefault() on pointer down
  31844. * in order to block unwanted artifacts like system double clicks
  31845. */
  31846. preventDefaultOnPointerDown: boolean;
  31847. /**
  31848. * This is used to call preventDefault() on pointer up
  31849. * in order to block unwanted artifacts like system double clicks
  31850. */
  31851. preventDefaultOnPointerUp: boolean;
  31852. /**
  31853. * Gets or sets user defined metadata
  31854. */
  31855. metadata: any;
  31856. /**
  31857. * For internal use only. Please do not use.
  31858. */
  31859. reservedDataStore: any;
  31860. /**
  31861. * Gets the name of the plugin used to load this scene (null by default)
  31862. */
  31863. loadingPluginName: string;
  31864. /**
  31865. * Use this array to add regular expressions used to disable offline support for specific urls
  31866. */
  31867. disableOfflineSupportExceptionRules: RegExp[];
  31868. /**
  31869. * An event triggered when the scene is disposed.
  31870. */
  31871. onDisposeObservable: Observable<Scene>;
  31872. private _onDisposeObserver;
  31873. /** Sets a function to be executed when this scene is disposed. */
  31874. onDispose: () => void;
  31875. /**
  31876. * An event triggered before rendering the scene (right after animations and physics)
  31877. */
  31878. onBeforeRenderObservable: Observable<Scene>;
  31879. private _onBeforeRenderObserver;
  31880. /** Sets a function to be executed before rendering this scene */
  31881. beforeRender: Nullable<() => void>;
  31882. /**
  31883. * An event triggered after rendering the scene
  31884. */
  31885. onAfterRenderObservable: Observable<Scene>;
  31886. private _onAfterRenderObserver;
  31887. /** Sets a function to be executed after rendering this scene */
  31888. afterRender: Nullable<() => void>;
  31889. /**
  31890. * An event triggered before animating the scene
  31891. */
  31892. onBeforeAnimationsObservable: Observable<Scene>;
  31893. /**
  31894. * An event triggered after animations processing
  31895. */
  31896. onAfterAnimationsObservable: Observable<Scene>;
  31897. /**
  31898. * An event triggered before draw calls are ready to be sent
  31899. */
  31900. onBeforeDrawPhaseObservable: Observable<Scene>;
  31901. /**
  31902. * An event triggered after draw calls have been sent
  31903. */
  31904. onAfterDrawPhaseObservable: Observable<Scene>;
  31905. /**
  31906. * An event triggered when the scene is ready
  31907. */
  31908. onReadyObservable: Observable<Scene>;
  31909. /**
  31910. * An event triggered before rendering a camera
  31911. */
  31912. onBeforeCameraRenderObservable: Observable<Camera>;
  31913. private _onBeforeCameraRenderObserver;
  31914. /** Sets a function to be executed before rendering a camera*/
  31915. beforeCameraRender: () => void;
  31916. /**
  31917. * An event triggered after rendering a camera
  31918. */
  31919. onAfterCameraRenderObservable: Observable<Camera>;
  31920. private _onAfterCameraRenderObserver;
  31921. /** Sets a function to be executed after rendering a camera*/
  31922. afterCameraRender: () => void;
  31923. /**
  31924. * An event triggered when active meshes evaluation is about to start
  31925. */
  31926. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31927. /**
  31928. * An event triggered when active meshes evaluation is done
  31929. */
  31930. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31931. /**
  31932. * An event triggered when particles rendering is about to start
  31933. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31934. */
  31935. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31936. /**
  31937. * An event triggered when particles rendering is done
  31938. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31939. */
  31940. onAfterParticlesRenderingObservable: Observable<Scene>;
  31941. /**
  31942. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31943. */
  31944. onDataLoadedObservable: Observable<Scene>;
  31945. /**
  31946. * An event triggered when a camera is created
  31947. */
  31948. onNewCameraAddedObservable: Observable<Camera>;
  31949. /**
  31950. * An event triggered when a camera is removed
  31951. */
  31952. onCameraRemovedObservable: Observable<Camera>;
  31953. /**
  31954. * An event triggered when a light is created
  31955. */
  31956. onNewLightAddedObservable: Observable<Light>;
  31957. /**
  31958. * An event triggered when a light is removed
  31959. */
  31960. onLightRemovedObservable: Observable<Light>;
  31961. /**
  31962. * An event triggered when a geometry is created
  31963. */
  31964. onNewGeometryAddedObservable: Observable<Geometry>;
  31965. /**
  31966. * An event triggered when a geometry is removed
  31967. */
  31968. onGeometryRemovedObservable: Observable<Geometry>;
  31969. /**
  31970. * An event triggered when a transform node is created
  31971. */
  31972. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31973. /**
  31974. * An event triggered when a transform node is removed
  31975. */
  31976. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31977. /**
  31978. * An event triggered when a mesh is created
  31979. */
  31980. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31981. /**
  31982. * An event triggered when a mesh is removed
  31983. */
  31984. onMeshRemovedObservable: Observable<AbstractMesh>;
  31985. /**
  31986. * An event triggered when a skeleton is created
  31987. */
  31988. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31989. /**
  31990. * An event triggered when a skeleton is removed
  31991. */
  31992. onSkeletonRemovedObservable: Observable<Skeleton>;
  31993. /**
  31994. * An event triggered when a material is created
  31995. */
  31996. onNewMaterialAddedObservable: Observable<Material>;
  31997. /**
  31998. * An event triggered when a material is removed
  31999. */
  32000. onMaterialRemovedObservable: Observable<Material>;
  32001. /**
  32002. * An event triggered when a texture is created
  32003. */
  32004. onNewTextureAddedObservable: Observable<BaseTexture>;
  32005. /**
  32006. * An event triggered when a texture is removed
  32007. */
  32008. onTextureRemovedObservable: Observable<BaseTexture>;
  32009. /**
  32010. * An event triggered when render targets are about to be rendered
  32011. * Can happen multiple times per frame.
  32012. */
  32013. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32014. /**
  32015. * An event triggered when render targets were rendered.
  32016. * Can happen multiple times per frame.
  32017. */
  32018. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32019. /**
  32020. * An event triggered before calculating deterministic simulation step
  32021. */
  32022. onBeforeStepObservable: Observable<Scene>;
  32023. /**
  32024. * An event triggered after calculating deterministic simulation step
  32025. */
  32026. onAfterStepObservable: Observable<Scene>;
  32027. /**
  32028. * An event triggered when the activeCamera property is updated
  32029. */
  32030. onActiveCameraChanged: Observable<Scene>;
  32031. /**
  32032. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32034. * 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)
  32035. */
  32036. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32037. /**
  32038. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32039. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32040. * 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)
  32041. */
  32042. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32043. /**
  32044. * This Observable will when a mesh has been imported into the scene.
  32045. */
  32046. onMeshImportedObservable: Observable<AbstractMesh>;
  32047. /**
  32048. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32049. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32050. */
  32051. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32052. /** @hidden */
  32053. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32054. /**
  32055. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32056. */
  32057. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32058. /**
  32059. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32060. */
  32061. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32062. /**
  32063. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32064. */
  32065. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32066. private _onPointerMove;
  32067. private _onPointerDown;
  32068. private _onPointerUp;
  32069. /** Callback called when a pointer move is detected */
  32070. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32071. /** Callback called when a pointer down is detected */
  32072. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32073. /** Callback called when a pointer up is detected */
  32074. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32075. /** Callback called when a pointer pick is detected */
  32076. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32077. /**
  32078. * 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).
  32079. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32080. */
  32081. onPrePointerObservable: Observable<PointerInfoPre>;
  32082. /**
  32083. * Observable event triggered each time an input event is received from the rendering canvas
  32084. */
  32085. onPointerObservable: Observable<PointerInfo>;
  32086. /**
  32087. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32088. */
  32089. readonly unTranslatedPointer: Vector2;
  32090. /** The distance in pixel that you have to move to prevent some events */
  32091. static DragMovementThreshold: number;
  32092. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32093. static LongPressDelay: number;
  32094. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32095. static DoubleClickDelay: number;
  32096. /** If you need to check double click without raising a single click at first click, enable this flag */
  32097. static ExclusiveDoubleClickMode: boolean;
  32098. private _initClickEvent;
  32099. private _initActionManager;
  32100. private _delayedSimpleClick;
  32101. private _delayedSimpleClickTimeout;
  32102. private _previousDelayedSimpleClickTimeout;
  32103. private _meshPickProceed;
  32104. private _previousButtonPressed;
  32105. private _currentPickResult;
  32106. private _previousPickResult;
  32107. private _totalPointersPressed;
  32108. private _doubleClickOccured;
  32109. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32110. cameraToUseForPointers: Nullable<Camera>;
  32111. private _pointerX;
  32112. private _pointerY;
  32113. private _unTranslatedPointerX;
  32114. private _unTranslatedPointerY;
  32115. private _startingPointerPosition;
  32116. private _previousStartingPointerPosition;
  32117. private _startingPointerTime;
  32118. private _previousStartingPointerTime;
  32119. private _pointerCaptures;
  32120. private _timeAccumulator;
  32121. private _currentStepId;
  32122. private _currentInternalStep;
  32123. /** @hidden */
  32124. _mirroredCameraPosition: Nullable<Vector3>;
  32125. /**
  32126. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32127. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32128. */
  32129. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32130. /**
  32131. * Observable event triggered each time an keyboard event is received from the hosting window
  32132. */
  32133. onKeyboardObservable: Observable<KeyboardInfo>;
  32134. private _onKeyDown;
  32135. private _onKeyUp;
  32136. private _onCanvasFocusObserver;
  32137. private _onCanvasBlurObserver;
  32138. private _useRightHandedSystem;
  32139. /**
  32140. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32141. */
  32142. useRightHandedSystem: boolean;
  32143. /**
  32144. * Sets the step Id used by deterministic lock step
  32145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32146. * @param newStepId defines the step Id
  32147. */
  32148. setStepId(newStepId: number): void;
  32149. /**
  32150. * Gets the step Id used by deterministic lock step
  32151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32152. * @returns the step Id
  32153. */
  32154. getStepId(): number;
  32155. /**
  32156. * Gets the internal step used by deterministic lock step
  32157. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32158. * @returns the internal step
  32159. */
  32160. getInternalStep(): number;
  32161. private _fogEnabled;
  32162. /**
  32163. * Gets or sets a boolean indicating if fog is enabled on this scene
  32164. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32165. * (Default is true)
  32166. */
  32167. fogEnabled: boolean;
  32168. private _fogMode;
  32169. /**
  32170. * Gets or sets the fog mode to use
  32171. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32172. * | mode | value |
  32173. * | --- | --- |
  32174. * | FOGMODE_NONE | 0 |
  32175. * | FOGMODE_EXP | 1 |
  32176. * | FOGMODE_EXP2 | 2 |
  32177. * | FOGMODE_LINEAR | 3 |
  32178. */
  32179. fogMode: number;
  32180. /**
  32181. * Gets or sets the fog color to use
  32182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32183. * (Default is Color3(0.2, 0.2, 0.3))
  32184. */
  32185. fogColor: Color3;
  32186. /**
  32187. * Gets or sets the fog density to use
  32188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32189. * (Default is 0.1)
  32190. */
  32191. fogDensity: number;
  32192. /**
  32193. * Gets or sets the fog start distance to use
  32194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32195. * (Default is 0)
  32196. */
  32197. fogStart: number;
  32198. /**
  32199. * Gets or sets the fog end distance to use
  32200. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32201. * (Default is 1000)
  32202. */
  32203. fogEnd: number;
  32204. private _shadowsEnabled;
  32205. /**
  32206. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32207. */
  32208. shadowsEnabled: boolean;
  32209. private _lightsEnabled;
  32210. /**
  32211. * Gets or sets a boolean indicating if lights are enabled on this scene
  32212. */
  32213. lightsEnabled: boolean;
  32214. /** All of the active cameras added to this scene. */
  32215. activeCameras: Camera[];
  32216. private _activeCamera;
  32217. /** Gets or sets the current active camera */
  32218. activeCamera: Nullable<Camera>;
  32219. private _defaultMaterial;
  32220. /** The default material used on meshes when no material is affected */
  32221. /** The default material used on meshes when no material is affected */
  32222. defaultMaterial: Material;
  32223. private _texturesEnabled;
  32224. /**
  32225. * Gets or sets a boolean indicating if textures are enabled on this scene
  32226. */
  32227. texturesEnabled: boolean;
  32228. /**
  32229. * Gets or sets a boolean indicating if particles are enabled on this scene
  32230. */
  32231. particlesEnabled: boolean;
  32232. /**
  32233. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32234. */
  32235. spritesEnabled: boolean;
  32236. private _skeletonsEnabled;
  32237. /**
  32238. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32239. */
  32240. skeletonsEnabled: boolean;
  32241. /**
  32242. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32243. */
  32244. lensFlaresEnabled: boolean;
  32245. /**
  32246. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32248. */
  32249. collisionsEnabled: boolean;
  32250. private _collisionCoordinator;
  32251. /** @hidden */
  32252. readonly collisionCoordinator: ICollisionCoordinator;
  32253. /**
  32254. * Defines the gravity applied to this scene (used only for collisions)
  32255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32256. */
  32257. gravity: Vector3;
  32258. /**
  32259. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32260. */
  32261. postProcessesEnabled: boolean;
  32262. /**
  32263. * The list of postprocesses added to the scene
  32264. */
  32265. postProcesses: PostProcess[];
  32266. /**
  32267. * Gets the current postprocess manager
  32268. */
  32269. postProcessManager: PostProcessManager;
  32270. /**
  32271. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32272. */
  32273. renderTargetsEnabled: boolean;
  32274. /**
  32275. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32276. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32277. */
  32278. dumpNextRenderTargets: boolean;
  32279. /**
  32280. * The list of user defined render targets added to the scene
  32281. */
  32282. customRenderTargets: RenderTargetTexture[];
  32283. /**
  32284. * Defines if texture loading must be delayed
  32285. * If true, textures will only be loaded when they need to be rendered
  32286. */
  32287. useDelayedTextureLoading: boolean;
  32288. /**
  32289. * Gets the list of meshes imported to the scene through SceneLoader
  32290. */
  32291. importedMeshesFiles: String[];
  32292. /**
  32293. * Gets or sets a boolean indicating if probes are enabled on this scene
  32294. */
  32295. probesEnabled: boolean;
  32296. /**
  32297. * Gets or sets the current offline provider to use to store scene data
  32298. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32299. */
  32300. offlineProvider: IOfflineProvider;
  32301. /**
  32302. * Gets or sets the action manager associated with the scene
  32303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32304. */
  32305. actionManager: AbstractActionManager;
  32306. private _meshesForIntersections;
  32307. /**
  32308. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32309. */
  32310. proceduralTexturesEnabled: boolean;
  32311. private _engine;
  32312. private _totalVertices;
  32313. /** @hidden */
  32314. _activeIndices: PerfCounter;
  32315. /** @hidden */
  32316. _activeParticles: PerfCounter;
  32317. /** @hidden */
  32318. _activeBones: PerfCounter;
  32319. private _animationRatio;
  32320. /** @hidden */
  32321. _animationTimeLast: number;
  32322. /** @hidden */
  32323. _animationTime: number;
  32324. /**
  32325. * Gets or sets a general scale for animation speed
  32326. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32327. */
  32328. animationTimeScale: number;
  32329. /** @hidden */
  32330. _cachedMaterial: Nullable<Material>;
  32331. /** @hidden */
  32332. _cachedEffect: Nullable<Effect>;
  32333. /** @hidden */
  32334. _cachedVisibility: Nullable<number>;
  32335. private _renderId;
  32336. private _frameId;
  32337. private _executeWhenReadyTimeoutId;
  32338. private _intermediateRendering;
  32339. private _viewUpdateFlag;
  32340. private _projectionUpdateFlag;
  32341. /** @hidden */
  32342. _toBeDisposed: Nullable<IDisposable>[];
  32343. private _activeRequests;
  32344. /** @hidden */
  32345. _pendingData: any[];
  32346. private _isDisposed;
  32347. /**
  32348. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32349. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32350. */
  32351. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32352. private _activeMeshes;
  32353. private _processedMaterials;
  32354. private _renderTargets;
  32355. /** @hidden */
  32356. _activeParticleSystems: SmartArray<IParticleSystem>;
  32357. private _activeSkeletons;
  32358. private _softwareSkinnedMeshes;
  32359. private _renderingManager;
  32360. /** @hidden */
  32361. _activeAnimatables: Animatable[];
  32362. private _transformMatrix;
  32363. private _transformMatrixR;
  32364. private _sceneUbo;
  32365. private _multiviewSceneUbo;
  32366. private _viewMatrix;
  32367. private _projectionMatrix;
  32368. private _wheelEventName;
  32369. /** @hidden */
  32370. _forcedViewPosition: Nullable<Vector3>;
  32371. private _frustumPlanes;
  32372. /**
  32373. * Gets the list of frustum planes (built from the active camera)
  32374. */
  32375. readonly frustumPlanes: Plane[];
  32376. /**
  32377. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32378. * This is useful if there are more lights that the maximum simulteanous authorized
  32379. */
  32380. requireLightSorting: boolean;
  32381. /** @hidden */
  32382. readonly useMaterialMeshMap: boolean;
  32383. /** @hidden */
  32384. readonly useClonedMeshhMap: boolean;
  32385. private _pointerOverMesh;
  32386. private _pickedDownMesh;
  32387. private _pickedUpMesh;
  32388. private _externalData;
  32389. private _uid;
  32390. /**
  32391. * @hidden
  32392. * Backing store of defined scene components.
  32393. */
  32394. _components: ISceneComponent[];
  32395. /**
  32396. * @hidden
  32397. * Backing store of defined scene components.
  32398. */
  32399. _serializableComponents: ISceneSerializableComponent[];
  32400. /**
  32401. * List of components to register on the next registration step.
  32402. */
  32403. private _transientComponents;
  32404. /**
  32405. * Registers the transient components if needed.
  32406. */
  32407. private _registerTransientComponents;
  32408. /**
  32409. * @hidden
  32410. * Add a component to the scene.
  32411. * Note that the ccomponent could be registered on th next frame if this is called after
  32412. * the register component stage.
  32413. * @param component Defines the component to add to the scene
  32414. */
  32415. _addComponent(component: ISceneComponent): void;
  32416. /**
  32417. * @hidden
  32418. * Gets a component from the scene.
  32419. * @param name defines the name of the component to retrieve
  32420. * @returns the component or null if not present
  32421. */
  32422. _getComponent(name: string): Nullable<ISceneComponent>;
  32423. /**
  32424. * @hidden
  32425. * Defines the actions happening before camera updates.
  32426. */
  32427. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32428. /**
  32429. * @hidden
  32430. * Defines the actions happening before clear the canvas.
  32431. */
  32432. _beforeClearStage: Stage<SimpleStageAction>;
  32433. /**
  32434. * @hidden
  32435. * Defines the actions when collecting render targets for the frame.
  32436. */
  32437. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32438. /**
  32439. * @hidden
  32440. * Defines the actions happening for one camera in the frame.
  32441. */
  32442. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32443. /**
  32444. * @hidden
  32445. * Defines the actions happening during the per mesh ready checks.
  32446. */
  32447. _isReadyForMeshStage: Stage<MeshStageAction>;
  32448. /**
  32449. * @hidden
  32450. * Defines the actions happening before evaluate active mesh checks.
  32451. */
  32452. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32453. /**
  32454. * @hidden
  32455. * Defines the actions happening during the evaluate sub mesh checks.
  32456. */
  32457. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32458. /**
  32459. * @hidden
  32460. * Defines the actions happening during the active mesh stage.
  32461. */
  32462. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32463. /**
  32464. * @hidden
  32465. * Defines the actions happening during the per camera render target step.
  32466. */
  32467. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32468. /**
  32469. * @hidden
  32470. * Defines the actions happening just before the active camera is drawing.
  32471. */
  32472. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32473. /**
  32474. * @hidden
  32475. * Defines the actions happening just before a render target is drawing.
  32476. */
  32477. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32478. /**
  32479. * @hidden
  32480. * Defines the actions happening just before a rendering group is drawing.
  32481. */
  32482. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32483. /**
  32484. * @hidden
  32485. * Defines the actions happening just before a mesh is drawing.
  32486. */
  32487. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32488. /**
  32489. * @hidden
  32490. * Defines the actions happening just after a mesh has been drawn.
  32491. */
  32492. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32493. /**
  32494. * @hidden
  32495. * Defines the actions happening just after a rendering group has been drawn.
  32496. */
  32497. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32498. /**
  32499. * @hidden
  32500. * Defines the actions happening just after the active camera has been drawn.
  32501. */
  32502. _afterCameraDrawStage: Stage<CameraStageAction>;
  32503. /**
  32504. * @hidden
  32505. * Defines the actions happening just after a render target has been drawn.
  32506. */
  32507. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32508. /**
  32509. * @hidden
  32510. * Defines the actions happening just after rendering all cameras and computing intersections.
  32511. */
  32512. _afterRenderStage: Stage<SimpleStageAction>;
  32513. /**
  32514. * @hidden
  32515. * Defines the actions happening when a pointer move event happens.
  32516. */
  32517. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32518. /**
  32519. * @hidden
  32520. * Defines the actions happening when a pointer down event happens.
  32521. */
  32522. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32523. /**
  32524. * @hidden
  32525. * Defines the actions happening when a pointer up event happens.
  32526. */
  32527. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32528. /**
  32529. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32530. */
  32531. private geometriesByUniqueId;
  32532. /**
  32533. * Creates a new Scene
  32534. * @param engine defines the engine to use to render this scene
  32535. * @param options defines the scene options
  32536. */
  32537. constructor(engine: Engine, options?: SceneOptions);
  32538. /**
  32539. * Gets a string idenfifying the name of the class
  32540. * @returns "Scene" string
  32541. */
  32542. getClassName(): string;
  32543. private _defaultMeshCandidates;
  32544. /**
  32545. * @hidden
  32546. */
  32547. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32548. private _defaultSubMeshCandidates;
  32549. /**
  32550. * @hidden
  32551. */
  32552. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32553. /**
  32554. * Sets the default candidate providers for the scene.
  32555. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32556. * and getCollidingSubMeshCandidates to their default function
  32557. */
  32558. setDefaultCandidateProviders(): void;
  32559. /**
  32560. * Gets the mesh that is currently under the pointer
  32561. */
  32562. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32563. /**
  32564. * Gets or sets the current on-screen X position of the pointer
  32565. */
  32566. pointerX: number;
  32567. /**
  32568. * Gets or sets the current on-screen Y position of the pointer
  32569. */
  32570. pointerY: number;
  32571. /**
  32572. * Gets the cached material (ie. the latest rendered one)
  32573. * @returns the cached material
  32574. */
  32575. getCachedMaterial(): Nullable<Material>;
  32576. /**
  32577. * Gets the cached effect (ie. the latest rendered one)
  32578. * @returns the cached effect
  32579. */
  32580. getCachedEffect(): Nullable<Effect>;
  32581. /**
  32582. * Gets the cached visibility state (ie. the latest rendered one)
  32583. * @returns the cached visibility state
  32584. */
  32585. getCachedVisibility(): Nullable<number>;
  32586. /**
  32587. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32588. * @param material defines the current material
  32589. * @param effect defines the current effect
  32590. * @param visibility defines the current visibility state
  32591. * @returns true if one parameter is not cached
  32592. */
  32593. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32594. /**
  32595. * Gets the engine associated with the scene
  32596. * @returns an Engine
  32597. */
  32598. getEngine(): Engine;
  32599. /**
  32600. * Gets the total number of vertices rendered per frame
  32601. * @returns the total number of vertices rendered per frame
  32602. */
  32603. getTotalVertices(): number;
  32604. /**
  32605. * Gets the performance counter for total vertices
  32606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32607. */
  32608. readonly totalVerticesPerfCounter: PerfCounter;
  32609. /**
  32610. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32611. * @returns the total number of active indices rendered per frame
  32612. */
  32613. getActiveIndices(): number;
  32614. /**
  32615. * Gets the performance counter for active indices
  32616. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32617. */
  32618. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32619. /**
  32620. * Gets the total number of active particles rendered per frame
  32621. * @returns the total number of active particles rendered per frame
  32622. */
  32623. getActiveParticles(): number;
  32624. /**
  32625. * Gets the performance counter for active particles
  32626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32627. */
  32628. readonly activeParticlesPerfCounter: PerfCounter;
  32629. /**
  32630. * Gets the total number of active bones rendered per frame
  32631. * @returns the total number of active bones rendered per frame
  32632. */
  32633. getActiveBones(): number;
  32634. /**
  32635. * Gets the performance counter for active bones
  32636. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32637. */
  32638. readonly activeBonesPerfCounter: PerfCounter;
  32639. /**
  32640. * Gets the array of active meshes
  32641. * @returns an array of AbstractMesh
  32642. */
  32643. getActiveMeshes(): SmartArray<AbstractMesh>;
  32644. /**
  32645. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32646. * @returns a number
  32647. */
  32648. getAnimationRatio(): number;
  32649. /**
  32650. * Gets an unique Id for the current render phase
  32651. * @returns a number
  32652. */
  32653. getRenderId(): number;
  32654. /**
  32655. * Gets an unique Id for the current frame
  32656. * @returns a number
  32657. */
  32658. getFrameId(): number;
  32659. /** Call this function if you want to manually increment the render Id*/
  32660. incrementRenderId(): void;
  32661. private _updatePointerPosition;
  32662. private _createUbo;
  32663. private _createMultiviewUbo;
  32664. private _setRayOnPointerInfo;
  32665. /**
  32666. * Use this method to simulate a pointer move on a mesh
  32667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32670. * @returns the current scene
  32671. */
  32672. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32673. private _processPointerMove;
  32674. private _checkPrePointerObservable;
  32675. /**
  32676. * Use this method to simulate a pointer down on a mesh
  32677. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32678. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32679. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32680. * @returns the current scene
  32681. */
  32682. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32683. private _processPointerDown;
  32684. /**
  32685. * Use this method to simulate a pointer up on a mesh
  32686. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32687. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32688. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32689. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32690. * @returns the current scene
  32691. */
  32692. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32693. private _processPointerUp;
  32694. /**
  32695. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32696. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32697. * @returns true if the pointer was captured
  32698. */
  32699. isPointerCaptured(pointerId?: number): boolean;
  32700. /** @hidden */
  32701. _isPointerSwiping(): boolean;
  32702. /**
  32703. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32704. * @param attachUp defines if you want to attach events to pointerup
  32705. * @param attachDown defines if you want to attach events to pointerdown
  32706. * @param attachMove defines if you want to attach events to pointermove
  32707. */
  32708. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32709. /** Detaches all event handlers*/
  32710. detachControl(): void;
  32711. /**
  32712. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32713. * Delay loaded resources are not taking in account
  32714. * @return true if all required resources are ready
  32715. */
  32716. isReady(): boolean;
  32717. /** Resets all cached information relative to material (including effect and visibility) */
  32718. resetCachedMaterial(): void;
  32719. /**
  32720. * Registers a function to be called before every frame render
  32721. * @param func defines the function to register
  32722. */
  32723. registerBeforeRender(func: () => void): void;
  32724. /**
  32725. * Unregisters a function called before every frame render
  32726. * @param func defines the function to unregister
  32727. */
  32728. unregisterBeforeRender(func: () => void): void;
  32729. /**
  32730. * Registers a function to be called after every frame render
  32731. * @param func defines the function to register
  32732. */
  32733. registerAfterRender(func: () => void): void;
  32734. /**
  32735. * Unregisters a function called after every frame render
  32736. * @param func defines the function to unregister
  32737. */
  32738. unregisterAfterRender(func: () => void): void;
  32739. private _executeOnceBeforeRender;
  32740. /**
  32741. * The provided function will run before render once and will be disposed afterwards.
  32742. * A timeout delay can be provided so that the function will be executed in N ms.
  32743. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32744. * @param func The function to be executed.
  32745. * @param timeout optional delay in ms
  32746. */
  32747. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32748. /** @hidden */
  32749. _addPendingData(data: any): void;
  32750. /** @hidden */
  32751. _removePendingData(data: any): void;
  32752. /**
  32753. * Returns the number of items waiting to be loaded
  32754. * @returns the number of items waiting to be loaded
  32755. */
  32756. getWaitingItemsCount(): number;
  32757. /**
  32758. * Returns a boolean indicating if the scene is still loading data
  32759. */
  32760. readonly isLoading: boolean;
  32761. /**
  32762. * Registers a function to be executed when the scene is ready
  32763. * @param {Function} func - the function to be executed
  32764. */
  32765. executeWhenReady(func: () => void): void;
  32766. /**
  32767. * Returns a promise that resolves when the scene is ready
  32768. * @returns A promise that resolves when the scene is ready
  32769. */
  32770. whenReadyAsync(): Promise<void>;
  32771. /** @hidden */
  32772. _checkIsReady(): void;
  32773. /**
  32774. * Gets all animatable attached to the scene
  32775. */
  32776. readonly animatables: Animatable[];
  32777. /**
  32778. * Resets the last animation time frame.
  32779. * Useful to override when animations start running when loading a scene for the first time.
  32780. */
  32781. resetLastAnimationTimeFrame(): void;
  32782. /**
  32783. * Gets the current view matrix
  32784. * @returns a Matrix
  32785. */
  32786. getViewMatrix(): Matrix;
  32787. /**
  32788. * Gets the current projection matrix
  32789. * @returns a Matrix
  32790. */
  32791. getProjectionMatrix(): Matrix;
  32792. /**
  32793. * Gets the current transform matrix
  32794. * @returns a Matrix made of View * Projection
  32795. */
  32796. getTransformMatrix(): Matrix;
  32797. /**
  32798. * Sets the current transform matrix
  32799. * @param viewL defines the View matrix to use
  32800. * @param projectionL defines the Projection matrix to use
  32801. * @param viewR defines the right View matrix to use (if provided)
  32802. * @param projectionR defines the right Projection matrix to use (if provided)
  32803. */
  32804. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32805. /**
  32806. * Gets the uniform buffer used to store scene data
  32807. * @returns a UniformBuffer
  32808. */
  32809. getSceneUniformBuffer(): UniformBuffer;
  32810. /**
  32811. * Gets an unique (relatively to the current scene) Id
  32812. * @returns an unique number for the scene
  32813. */
  32814. getUniqueId(): number;
  32815. /**
  32816. * Add a mesh to the list of scene's meshes
  32817. * @param newMesh defines the mesh to add
  32818. * @param recursive if all child meshes should also be added to the scene
  32819. */
  32820. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32821. /**
  32822. * Remove a mesh for the list of scene's meshes
  32823. * @param toRemove defines the mesh to remove
  32824. * @param recursive if all child meshes should also be removed from the scene
  32825. * @returns the index where the mesh was in the mesh list
  32826. */
  32827. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32828. /**
  32829. * Add a transform node to the list of scene's transform nodes
  32830. * @param newTransformNode defines the transform node to add
  32831. */
  32832. addTransformNode(newTransformNode: TransformNode): void;
  32833. /**
  32834. * Remove a transform node for the list of scene's transform nodes
  32835. * @param toRemove defines the transform node to remove
  32836. * @returns the index where the transform node was in the transform node list
  32837. */
  32838. removeTransformNode(toRemove: TransformNode): number;
  32839. /**
  32840. * Remove a skeleton for the list of scene's skeletons
  32841. * @param toRemove defines the skeleton to remove
  32842. * @returns the index where the skeleton was in the skeleton list
  32843. */
  32844. removeSkeleton(toRemove: Skeleton): number;
  32845. /**
  32846. * Remove a morph target for the list of scene's morph targets
  32847. * @param toRemove defines the morph target to remove
  32848. * @returns the index where the morph target was in the morph target list
  32849. */
  32850. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32851. /**
  32852. * Remove a light for the list of scene's lights
  32853. * @param toRemove defines the light to remove
  32854. * @returns the index where the light was in the light list
  32855. */
  32856. removeLight(toRemove: Light): number;
  32857. /**
  32858. * Remove a camera for the list of scene's cameras
  32859. * @param toRemove defines the camera to remove
  32860. * @returns the index where the camera was in the camera list
  32861. */
  32862. removeCamera(toRemove: Camera): number;
  32863. /**
  32864. * Remove a particle system for the list of scene's particle systems
  32865. * @param toRemove defines the particle system to remove
  32866. * @returns the index where the particle system was in the particle system list
  32867. */
  32868. removeParticleSystem(toRemove: IParticleSystem): number;
  32869. /**
  32870. * Remove a animation for the list of scene's animations
  32871. * @param toRemove defines the animation to remove
  32872. * @returns the index where the animation was in the animation list
  32873. */
  32874. removeAnimation(toRemove: Animation): number;
  32875. /**
  32876. * Removes the given animation group from this scene.
  32877. * @param toRemove The animation group to remove
  32878. * @returns The index of the removed animation group
  32879. */
  32880. removeAnimationGroup(toRemove: AnimationGroup): number;
  32881. /**
  32882. * Removes the given multi-material from this scene.
  32883. * @param toRemove The multi-material to remove
  32884. * @returns The index of the removed multi-material
  32885. */
  32886. removeMultiMaterial(toRemove: MultiMaterial): number;
  32887. /**
  32888. * Removes the given material from this scene.
  32889. * @param toRemove The material to remove
  32890. * @returns The index of the removed material
  32891. */
  32892. removeMaterial(toRemove: Material): number;
  32893. /**
  32894. * Removes the given action manager from this scene.
  32895. * @param toRemove The action manager to remove
  32896. * @returns The index of the removed action manager
  32897. */
  32898. removeActionManager(toRemove: AbstractActionManager): number;
  32899. /**
  32900. * Removes the given texture from this scene.
  32901. * @param toRemove The texture to remove
  32902. * @returns The index of the removed texture
  32903. */
  32904. removeTexture(toRemove: BaseTexture): number;
  32905. /**
  32906. * Adds the given light to this scene
  32907. * @param newLight The light to add
  32908. */
  32909. addLight(newLight: Light): void;
  32910. /**
  32911. * Sorts the list list based on light priorities
  32912. */
  32913. sortLightsByPriority(): void;
  32914. /**
  32915. * Adds the given camera to this scene
  32916. * @param newCamera The camera to add
  32917. */
  32918. addCamera(newCamera: Camera): void;
  32919. /**
  32920. * Adds the given skeleton to this scene
  32921. * @param newSkeleton The skeleton to add
  32922. */
  32923. addSkeleton(newSkeleton: Skeleton): void;
  32924. /**
  32925. * Adds the given particle system to this scene
  32926. * @param newParticleSystem The particle system to add
  32927. */
  32928. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32929. /**
  32930. * Adds the given animation to this scene
  32931. * @param newAnimation The animation to add
  32932. */
  32933. addAnimation(newAnimation: Animation): void;
  32934. /**
  32935. * Adds the given animation group to this scene.
  32936. * @param newAnimationGroup The animation group to add
  32937. */
  32938. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32939. /**
  32940. * Adds the given multi-material to this scene
  32941. * @param newMultiMaterial The multi-material to add
  32942. */
  32943. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32944. /**
  32945. * Adds the given material to this scene
  32946. * @param newMaterial The material to add
  32947. */
  32948. addMaterial(newMaterial: Material): void;
  32949. /**
  32950. * Adds the given morph target to this scene
  32951. * @param newMorphTargetManager The morph target to add
  32952. */
  32953. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32954. /**
  32955. * Adds the given geometry to this scene
  32956. * @param newGeometry The geometry to add
  32957. */
  32958. addGeometry(newGeometry: Geometry): void;
  32959. /**
  32960. * Adds the given action manager to this scene
  32961. * @param newActionManager The action manager to add
  32962. */
  32963. addActionManager(newActionManager: AbstractActionManager): void;
  32964. /**
  32965. * Adds the given texture to this scene.
  32966. * @param newTexture The texture to add
  32967. */
  32968. addTexture(newTexture: BaseTexture): void;
  32969. /**
  32970. * Switch active camera
  32971. * @param newCamera defines the new active camera
  32972. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32973. */
  32974. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32975. /**
  32976. * sets the active camera of the scene using its ID
  32977. * @param id defines the camera's ID
  32978. * @return the new active camera or null if none found.
  32979. */
  32980. setActiveCameraByID(id: string): Nullable<Camera>;
  32981. /**
  32982. * sets the active camera of the scene using its name
  32983. * @param name defines the camera's name
  32984. * @returns the new active camera or null if none found.
  32985. */
  32986. setActiveCameraByName(name: string): Nullable<Camera>;
  32987. /**
  32988. * get an animation group using its name
  32989. * @param name defines the material's name
  32990. * @return the animation group or null if none found.
  32991. */
  32992. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32993. /**
  32994. * Get a material using its unique id
  32995. * @param uniqueId defines the material's unique id
  32996. * @return the material or null if none found.
  32997. */
  32998. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32999. /**
  33000. * get a material using its id
  33001. * @param id defines the material's ID
  33002. * @return the material or null if none found.
  33003. */
  33004. getMaterialByID(id: string): Nullable<Material>;
  33005. /**
  33006. * Gets a material using its name
  33007. * @param name defines the material's name
  33008. * @return the material or null if none found.
  33009. */
  33010. getMaterialByName(name: string): Nullable<Material>;
  33011. /**
  33012. * Gets a camera using its id
  33013. * @param id defines the id to look for
  33014. * @returns the camera or null if not found
  33015. */
  33016. getCameraByID(id: string): Nullable<Camera>;
  33017. /**
  33018. * Gets a camera using its unique id
  33019. * @param uniqueId defines the unique id to look for
  33020. * @returns the camera or null if not found
  33021. */
  33022. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33023. /**
  33024. * Gets a camera using its name
  33025. * @param name defines the camera's name
  33026. * @return the camera or null if none found.
  33027. */
  33028. getCameraByName(name: string): Nullable<Camera>;
  33029. /**
  33030. * Gets a bone using its id
  33031. * @param id defines the bone's id
  33032. * @return the bone or null if not found
  33033. */
  33034. getBoneByID(id: string): Nullable<Bone>;
  33035. /**
  33036. * Gets a bone using its id
  33037. * @param name defines the bone's name
  33038. * @return the bone or null if not found
  33039. */
  33040. getBoneByName(name: string): Nullable<Bone>;
  33041. /**
  33042. * Gets a light node using its name
  33043. * @param name defines the the light's name
  33044. * @return the light or null if none found.
  33045. */
  33046. getLightByName(name: string): Nullable<Light>;
  33047. /**
  33048. * Gets a light node using its id
  33049. * @param id defines the light's id
  33050. * @return the light or null if none found.
  33051. */
  33052. getLightByID(id: string): Nullable<Light>;
  33053. /**
  33054. * Gets a light node using its scene-generated unique ID
  33055. * @param uniqueId defines the light's unique id
  33056. * @return the light or null if none found.
  33057. */
  33058. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33059. /**
  33060. * Gets a particle system by id
  33061. * @param id defines the particle system id
  33062. * @return the corresponding system or null if none found
  33063. */
  33064. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33065. /**
  33066. * Gets a geometry using its ID
  33067. * @param id defines the geometry's id
  33068. * @return the geometry or null if none found.
  33069. */
  33070. getGeometryByID(id: string): Nullable<Geometry>;
  33071. private _getGeometryByUniqueID;
  33072. /**
  33073. * Add a new geometry to this scene
  33074. * @param geometry defines the geometry to be added to the scene.
  33075. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33076. * @return a boolean defining if the geometry was added or not
  33077. */
  33078. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33079. /**
  33080. * Removes an existing geometry
  33081. * @param geometry defines the geometry to be removed from the scene
  33082. * @return a boolean defining if the geometry was removed or not
  33083. */
  33084. removeGeometry(geometry: Geometry): boolean;
  33085. /**
  33086. * Gets the list of geometries attached to the scene
  33087. * @returns an array of Geometry
  33088. */
  33089. getGeometries(): Geometry[];
  33090. /**
  33091. * Gets the first added mesh found of a given ID
  33092. * @param id defines the id to search for
  33093. * @return the mesh found or null if not found at all
  33094. */
  33095. getMeshByID(id: string): Nullable<AbstractMesh>;
  33096. /**
  33097. * Gets a list of meshes using their id
  33098. * @param id defines the id to search for
  33099. * @returns a list of meshes
  33100. */
  33101. getMeshesByID(id: string): Array<AbstractMesh>;
  33102. /**
  33103. * Gets the first added transform node found of a given ID
  33104. * @param id defines the id to search for
  33105. * @return the found transform node or null if not found at all.
  33106. */
  33107. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33108. /**
  33109. * Gets a transform node with its auto-generated unique id
  33110. * @param uniqueId efines the unique id to search for
  33111. * @return the found transform node or null if not found at all.
  33112. */
  33113. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33114. /**
  33115. * Gets a list of transform nodes using their id
  33116. * @param id defines the id to search for
  33117. * @returns a list of transform nodes
  33118. */
  33119. getTransformNodesByID(id: string): Array<TransformNode>;
  33120. /**
  33121. * Gets a mesh with its auto-generated unique id
  33122. * @param uniqueId defines the unique id to search for
  33123. * @return the found mesh or null if not found at all.
  33124. */
  33125. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33126. /**
  33127. * Gets a the last added mesh using a given id
  33128. * @param id defines the id to search for
  33129. * @return the found mesh or null if not found at all.
  33130. */
  33131. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33132. /**
  33133. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33134. * @param id defines the id to search for
  33135. * @return the found node or null if not found at all
  33136. */
  33137. getLastEntryByID(id: string): Nullable<Node>;
  33138. /**
  33139. * Gets a node (Mesh, Camera, Light) using a given id
  33140. * @param id defines the id to search for
  33141. * @return the found node or null if not found at all
  33142. */
  33143. getNodeByID(id: string): Nullable<Node>;
  33144. /**
  33145. * Gets a node (Mesh, Camera, Light) using a given name
  33146. * @param name defines the name to search for
  33147. * @return the found node or null if not found at all.
  33148. */
  33149. getNodeByName(name: string): Nullable<Node>;
  33150. /**
  33151. * Gets a mesh using a given name
  33152. * @param name defines the name to search for
  33153. * @return the found mesh or null if not found at all.
  33154. */
  33155. getMeshByName(name: string): Nullable<AbstractMesh>;
  33156. /**
  33157. * Gets a transform node using a given name
  33158. * @param name defines the name to search for
  33159. * @return the found transform node or null if not found at all.
  33160. */
  33161. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33162. /**
  33163. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33164. * @param id defines the id to search for
  33165. * @return the found skeleton or null if not found at all.
  33166. */
  33167. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33168. /**
  33169. * Gets a skeleton using a given auto generated unique id
  33170. * @param uniqueId defines the unique id to search for
  33171. * @return the found skeleton or null if not found at all.
  33172. */
  33173. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33174. /**
  33175. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33176. * @param id defines the id to search for
  33177. * @return the found skeleton or null if not found at all.
  33178. */
  33179. getSkeletonById(id: string): Nullable<Skeleton>;
  33180. /**
  33181. * Gets a skeleton using a given name
  33182. * @param name defines the name to search for
  33183. * @return the found skeleton or null if not found at all.
  33184. */
  33185. getSkeletonByName(name: string): Nullable<Skeleton>;
  33186. /**
  33187. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33188. * @param id defines the id to search for
  33189. * @return the found morph target manager or null if not found at all.
  33190. */
  33191. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33192. /**
  33193. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33194. * @param id defines the id to search for
  33195. * @return the found morph target or null if not found at all.
  33196. */
  33197. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33198. /**
  33199. * Gets a boolean indicating if the given mesh is active
  33200. * @param mesh defines the mesh to look for
  33201. * @returns true if the mesh is in the active list
  33202. */
  33203. isActiveMesh(mesh: AbstractMesh): boolean;
  33204. /**
  33205. * Return a unique id as a string which can serve as an identifier for the scene
  33206. */
  33207. readonly uid: string;
  33208. /**
  33209. * Add an externaly attached data from its key.
  33210. * This method call will fail and return false, if such key already exists.
  33211. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33212. * @param key the unique key that identifies the data
  33213. * @param data the data object to associate to the key for this Engine instance
  33214. * @return true if no such key were already present and the data was added successfully, false otherwise
  33215. */
  33216. addExternalData<T>(key: string, data: T): boolean;
  33217. /**
  33218. * Get an externaly attached data from its key
  33219. * @param key the unique key that identifies the data
  33220. * @return the associated data, if present (can be null), or undefined if not present
  33221. */
  33222. getExternalData<T>(key: string): Nullable<T>;
  33223. /**
  33224. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33225. * @param key the unique key that identifies the data
  33226. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33227. * @return the associated data, can be null if the factory returned null.
  33228. */
  33229. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33230. /**
  33231. * Remove an externaly attached data from the Engine instance
  33232. * @param key the unique key that identifies the data
  33233. * @return true if the data was successfully removed, false if it doesn't exist
  33234. */
  33235. removeExternalData(key: string): boolean;
  33236. private _evaluateSubMesh;
  33237. /**
  33238. * Clear the processed materials smart array preventing retention point in material dispose.
  33239. */
  33240. freeProcessedMaterials(): void;
  33241. private _preventFreeActiveMeshesAndRenderingGroups;
  33242. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33243. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33244. * when disposing several meshes in a row or a hierarchy of meshes.
  33245. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33246. */
  33247. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33248. /**
  33249. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33250. */
  33251. freeActiveMeshes(): void;
  33252. /**
  33253. * Clear the info related to rendering groups preventing retention points during dispose.
  33254. */
  33255. freeRenderingGroups(): void;
  33256. /** @hidden */
  33257. _isInIntermediateRendering(): boolean;
  33258. /**
  33259. * Lambda returning the list of potentially active meshes.
  33260. */
  33261. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33262. /**
  33263. * Lambda returning the list of potentially active sub meshes.
  33264. */
  33265. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33266. /**
  33267. * Lambda returning the list of potentially intersecting sub meshes.
  33268. */
  33269. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33270. /**
  33271. * Lambda returning the list of potentially colliding sub meshes.
  33272. */
  33273. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33274. private _activeMeshesFrozen;
  33275. /**
  33276. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33277. * @returns the current scene
  33278. */
  33279. freezeActiveMeshes(): Scene;
  33280. /**
  33281. * Use this function to restart evaluating active meshes on every frame
  33282. * @returns the current scene
  33283. */
  33284. unfreezeActiveMeshes(): Scene;
  33285. private _evaluateActiveMeshes;
  33286. private _activeMesh;
  33287. /**
  33288. * Update the transform matrix to update from the current active camera
  33289. * @param force defines a boolean used to force the update even if cache is up to date
  33290. */
  33291. updateTransformMatrix(force?: boolean): void;
  33292. private _bindFrameBuffer;
  33293. /** @hidden */
  33294. _allowPostProcessClearColor: boolean;
  33295. private _renderForCamera;
  33296. private _processSubCameras;
  33297. private _checkIntersections;
  33298. /** @hidden */
  33299. _advancePhysicsEngineStep(step: number): void;
  33300. /**
  33301. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33302. */
  33303. getDeterministicFrameTime: () => number;
  33304. /** @hidden */
  33305. _animate(): void;
  33306. /**
  33307. * Render the scene
  33308. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33309. */
  33310. render(updateCameras?: boolean): void;
  33311. /**
  33312. * Freeze all materials
  33313. * A frozen material will not be updatable but should be faster to render
  33314. */
  33315. freezeMaterials(): void;
  33316. /**
  33317. * Unfreeze all materials
  33318. * A frozen material will not be updatable but should be faster to render
  33319. */
  33320. unfreezeMaterials(): void;
  33321. /**
  33322. * Releases all held ressources
  33323. */
  33324. dispose(): void;
  33325. /**
  33326. * Gets if the scene is already disposed
  33327. */
  33328. readonly isDisposed: boolean;
  33329. /**
  33330. * Call this function to reduce memory footprint of the scene.
  33331. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33332. */
  33333. clearCachedVertexData(): void;
  33334. /**
  33335. * This function will remove the local cached buffer data from texture.
  33336. * It will save memory but will prevent the texture from being rebuilt
  33337. */
  33338. cleanCachedTextureBuffer(): void;
  33339. /**
  33340. * Get the world extend vectors with an optional filter
  33341. *
  33342. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33343. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33344. */
  33345. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33346. min: Vector3;
  33347. max: Vector3;
  33348. };
  33349. /**
  33350. * Creates a ray that can be used to pick in the scene
  33351. * @param x defines the x coordinate of the origin (on-screen)
  33352. * @param y defines the y coordinate of the origin (on-screen)
  33353. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33354. * @param camera defines the camera to use for the picking
  33355. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33356. * @returns a Ray
  33357. */
  33358. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33359. /**
  33360. * Creates a ray that can be used to pick in the scene
  33361. * @param x defines the x coordinate of the origin (on-screen)
  33362. * @param y defines the y coordinate of the origin (on-screen)
  33363. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33364. * @param result defines the ray where to store the picking ray
  33365. * @param camera defines the camera to use for the picking
  33366. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33367. * @returns the current scene
  33368. */
  33369. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33370. /**
  33371. * Creates a ray that can be used to pick in the scene
  33372. * @param x defines the x coordinate of the origin (on-screen)
  33373. * @param y defines the y coordinate of the origin (on-screen)
  33374. * @param camera defines the camera to use for the picking
  33375. * @returns a Ray
  33376. */
  33377. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33378. /**
  33379. * Creates a ray that can be used to pick in the scene
  33380. * @param x defines the x coordinate of the origin (on-screen)
  33381. * @param y defines the y coordinate of the origin (on-screen)
  33382. * @param result defines the ray where to store the picking ray
  33383. * @param camera defines the camera to use for the picking
  33384. * @returns the current scene
  33385. */
  33386. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33387. /** Launch a ray to try to pick a mesh in the scene
  33388. * @param x position on screen
  33389. * @param y position on screen
  33390. * @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
  33391. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33392. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33394. * @returns a PickingInfo
  33395. */
  33396. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33397. /** Use the given ray to pick a mesh in the scene
  33398. * @param ray The ray to use to pick meshes
  33399. * @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
  33400. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33402. * @returns a PickingInfo
  33403. */
  33404. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33405. /**
  33406. * Launch a ray to try to pick a mesh in the scene
  33407. * @param x X position on screen
  33408. * @param y Y position on screen
  33409. * @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
  33410. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33412. * @returns an array of PickingInfo
  33413. */
  33414. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33415. /**
  33416. * Launch a ray to try to pick a mesh in the scene
  33417. * @param ray Ray to use
  33418. * @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
  33419. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33420. * @returns an array of PickingInfo
  33421. */
  33422. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33423. /**
  33424. * Force the value of meshUnderPointer
  33425. * @param mesh defines the mesh to use
  33426. */
  33427. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33428. /**
  33429. * Gets the mesh under the pointer
  33430. * @returns a Mesh or null if no mesh is under the pointer
  33431. */
  33432. getPointerOverMesh(): Nullable<AbstractMesh>;
  33433. /** @hidden */
  33434. _rebuildGeometries(): void;
  33435. /** @hidden */
  33436. _rebuildTextures(): void;
  33437. private _getByTags;
  33438. /**
  33439. * Get a list of meshes by tags
  33440. * @param tagsQuery defines the tags query to use
  33441. * @param forEach defines a predicate used to filter results
  33442. * @returns an array of Mesh
  33443. */
  33444. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33445. /**
  33446. * Get a list of cameras by tags
  33447. * @param tagsQuery defines the tags query to use
  33448. * @param forEach defines a predicate used to filter results
  33449. * @returns an array of Camera
  33450. */
  33451. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33452. /**
  33453. * Get a list of lights by tags
  33454. * @param tagsQuery defines the tags query to use
  33455. * @param forEach defines a predicate used to filter results
  33456. * @returns an array of Light
  33457. */
  33458. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33459. /**
  33460. * Get a list of materials by tags
  33461. * @param tagsQuery defines the tags query to use
  33462. * @param forEach defines a predicate used to filter results
  33463. * @returns an array of Material
  33464. */
  33465. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33466. /**
  33467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33468. * This allowed control for front to back rendering or reversly depending of the special needs.
  33469. *
  33470. * @param renderingGroupId The rendering group id corresponding to its index
  33471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33474. */
  33475. 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;
  33476. /**
  33477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33478. *
  33479. * @param renderingGroupId The rendering group id corresponding to its index
  33480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33481. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33482. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33483. */
  33484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33485. /**
  33486. * Gets the current auto clear configuration for one rendering group of the rendering
  33487. * manager.
  33488. * @param index the rendering group index to get the information for
  33489. * @returns The auto clear setup for the requested rendering group
  33490. */
  33491. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33492. private _blockMaterialDirtyMechanism;
  33493. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33494. blockMaterialDirtyMechanism: boolean;
  33495. /**
  33496. * Will flag all materials as dirty to trigger new shader compilation
  33497. * @param flag defines the flag used to specify which material part must be marked as dirty
  33498. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33499. */
  33500. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33501. /** @hidden */
  33502. _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;
  33503. /** @hidden */
  33504. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33505. }
  33506. }
  33507. declare module BABYLON {
  33508. /**
  33509. * Set of assets to keep when moving a scene into an asset container.
  33510. */
  33511. export class KeepAssets extends AbstractScene {
  33512. }
  33513. /**
  33514. * Container with a set of assets that can be added or removed from a scene.
  33515. */
  33516. export class AssetContainer extends AbstractScene {
  33517. /**
  33518. * The scene the AssetContainer belongs to.
  33519. */
  33520. scene: Scene;
  33521. /**
  33522. * Instantiates an AssetContainer.
  33523. * @param scene The scene the AssetContainer belongs to.
  33524. */
  33525. constructor(scene: Scene);
  33526. /**
  33527. * Adds all the assets from the container to the scene.
  33528. */
  33529. addAllToScene(): void;
  33530. /**
  33531. * Removes all the assets in the container from the scene
  33532. */
  33533. removeAllFromScene(): void;
  33534. /**
  33535. * Disposes all the assets in the container
  33536. */
  33537. dispose(): void;
  33538. private _moveAssets;
  33539. /**
  33540. * Removes all the assets contained in the scene and adds them to the container.
  33541. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33542. */
  33543. moveAllFromScene(keepAssets?: KeepAssets): void;
  33544. /**
  33545. * 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.
  33546. * @returns the root mesh
  33547. */
  33548. createRootMesh(): Mesh;
  33549. }
  33550. }
  33551. declare module BABYLON {
  33552. /**
  33553. * Defines how the parser contract is defined.
  33554. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33555. */
  33556. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33557. /**
  33558. * Defines how the individual parser contract is defined.
  33559. * These parser can parse an individual asset
  33560. */
  33561. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33562. /**
  33563. * Base class of the scene acting as a container for the different elements composing a scene.
  33564. * This class is dynamically extended by the different components of the scene increasing
  33565. * flexibility and reducing coupling
  33566. */
  33567. export abstract class AbstractScene {
  33568. /**
  33569. * Stores the list of available parsers in the application.
  33570. */
  33571. private static _BabylonFileParsers;
  33572. /**
  33573. * Stores the list of available individual parsers in the application.
  33574. */
  33575. private static _IndividualBabylonFileParsers;
  33576. /**
  33577. * Adds a parser in the list of available ones
  33578. * @param name Defines the name of the parser
  33579. * @param parser Defines the parser to add
  33580. */
  33581. static AddParser(name: string, parser: BabylonFileParser): void;
  33582. /**
  33583. * Gets a general parser from the list of avaialble ones
  33584. * @param name Defines the name of the parser
  33585. * @returns the requested parser or null
  33586. */
  33587. static GetParser(name: string): Nullable<BabylonFileParser>;
  33588. /**
  33589. * Adds n individual parser in the list of available ones
  33590. * @param name Defines the name of the parser
  33591. * @param parser Defines the parser to add
  33592. */
  33593. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33594. /**
  33595. * Gets an individual parser from the list of avaialble ones
  33596. * @param name Defines the name of the parser
  33597. * @returns the requested parser or null
  33598. */
  33599. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33600. /**
  33601. * Parser json data and populate both a scene and its associated container object
  33602. * @param jsonData Defines the data to parse
  33603. * @param scene Defines the scene to parse the data for
  33604. * @param container Defines the container attached to the parsing sequence
  33605. * @param rootUrl Defines the root url of the data
  33606. */
  33607. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33608. /**
  33609. * Gets the list of root nodes (ie. nodes with no parent)
  33610. */
  33611. rootNodes: Node[];
  33612. /** All of the cameras added to this scene
  33613. * @see http://doc.babylonjs.com/babylon101/cameras
  33614. */
  33615. cameras: Camera[];
  33616. /**
  33617. * All of the lights added to this scene
  33618. * @see http://doc.babylonjs.com/babylon101/lights
  33619. */
  33620. lights: Light[];
  33621. /**
  33622. * All of the (abstract) meshes added to this scene
  33623. */
  33624. meshes: AbstractMesh[];
  33625. /**
  33626. * The list of skeletons added to the scene
  33627. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33628. */
  33629. skeletons: Skeleton[];
  33630. /**
  33631. * All of the particle systems added to this scene
  33632. * @see http://doc.babylonjs.com/babylon101/particles
  33633. */
  33634. particleSystems: IParticleSystem[];
  33635. /**
  33636. * Gets a list of Animations associated with the scene
  33637. */
  33638. animations: Animation[];
  33639. /**
  33640. * All of the animation groups added to this scene
  33641. * @see http://doc.babylonjs.com/how_to/group
  33642. */
  33643. animationGroups: AnimationGroup[];
  33644. /**
  33645. * All of the multi-materials added to this scene
  33646. * @see http://doc.babylonjs.com/how_to/multi_materials
  33647. */
  33648. multiMaterials: MultiMaterial[];
  33649. /**
  33650. * All of the materials added to this scene
  33651. * In the context of a Scene, it is not supposed to be modified manually.
  33652. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33653. * Note also that the order of the Material wihin the array is not significant and might change.
  33654. * @see http://doc.babylonjs.com/babylon101/materials
  33655. */
  33656. materials: Material[];
  33657. /**
  33658. * The list of morph target managers added to the scene
  33659. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33660. */
  33661. morphTargetManagers: MorphTargetManager[];
  33662. /**
  33663. * The list of geometries used in the scene.
  33664. */
  33665. geometries: Geometry[];
  33666. /**
  33667. * All of the tranform nodes added to this scene
  33668. * In the context of a Scene, it is not supposed to be modified manually.
  33669. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33670. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33671. * @see http://doc.babylonjs.com/how_to/transformnode
  33672. */
  33673. transformNodes: TransformNode[];
  33674. /**
  33675. * ActionManagers available on the scene.
  33676. */
  33677. actionManagers: AbstractActionManager[];
  33678. /**
  33679. * Textures to keep.
  33680. */
  33681. textures: BaseTexture[];
  33682. /**
  33683. * Environment texture for the scene
  33684. */
  33685. environmentTexture: Nullable<BaseTexture>;
  33686. }
  33687. }
  33688. declare module BABYLON {
  33689. /**
  33690. * Defines a sound that can be played in the application.
  33691. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33693. */
  33694. export class Sound {
  33695. /**
  33696. * The name of the sound in the scene.
  33697. */
  33698. name: string;
  33699. /**
  33700. * Does the sound autoplay once loaded.
  33701. */
  33702. autoplay: boolean;
  33703. /**
  33704. * Does the sound loop after it finishes playing once.
  33705. */
  33706. loop: boolean;
  33707. /**
  33708. * Does the sound use a custom attenuation curve to simulate the falloff
  33709. * happening when the source gets further away from the camera.
  33710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33711. */
  33712. useCustomAttenuation: boolean;
  33713. /**
  33714. * The sound track id this sound belongs to.
  33715. */
  33716. soundTrackId: number;
  33717. /**
  33718. * Is this sound currently played.
  33719. */
  33720. isPlaying: boolean;
  33721. /**
  33722. * Is this sound currently paused.
  33723. */
  33724. isPaused: boolean;
  33725. /**
  33726. * Does this sound enables spatial sound.
  33727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33728. */
  33729. spatialSound: boolean;
  33730. /**
  33731. * Define the reference distance the sound should be heard perfectly.
  33732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33733. */
  33734. refDistance: number;
  33735. /**
  33736. * Define the roll off factor of spatial sounds.
  33737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33738. */
  33739. rolloffFactor: number;
  33740. /**
  33741. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33743. */
  33744. maxDistance: number;
  33745. /**
  33746. * Define the distance attenuation model the sound will follow.
  33747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33748. */
  33749. distanceModel: string;
  33750. /**
  33751. * @hidden
  33752. * Back Compat
  33753. **/
  33754. onended: () => any;
  33755. /**
  33756. * Observable event when the current playing sound finishes.
  33757. */
  33758. onEndedObservable: Observable<Sound>;
  33759. private _panningModel;
  33760. private _playbackRate;
  33761. private _streaming;
  33762. private _startTime;
  33763. private _startOffset;
  33764. private _position;
  33765. /** @hidden */
  33766. _positionInEmitterSpace: boolean;
  33767. private _localDirection;
  33768. private _volume;
  33769. private _isReadyToPlay;
  33770. private _isDirectional;
  33771. private _readyToPlayCallback;
  33772. private _audioBuffer;
  33773. private _soundSource;
  33774. private _streamingSource;
  33775. private _soundPanner;
  33776. private _soundGain;
  33777. private _inputAudioNode;
  33778. private _outputAudioNode;
  33779. private _coneInnerAngle;
  33780. private _coneOuterAngle;
  33781. private _coneOuterGain;
  33782. private _scene;
  33783. private _connectedTransformNode;
  33784. private _customAttenuationFunction;
  33785. private _registerFunc;
  33786. private _isOutputConnected;
  33787. private _htmlAudioElement;
  33788. private _urlType;
  33789. /** @hidden */
  33790. static _SceneComponentInitialization: (scene: Scene) => void;
  33791. /**
  33792. * Create a sound and attach it to a scene
  33793. * @param name Name of your sound
  33794. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33795. * @param scene defines the scene the sound belongs to
  33796. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33797. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33798. */
  33799. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33800. /**
  33801. * Release the sound and its associated resources
  33802. */
  33803. dispose(): void;
  33804. /**
  33805. * Gets if the sounds is ready to be played or not.
  33806. * @returns true if ready, otherwise false
  33807. */
  33808. isReady(): boolean;
  33809. private _soundLoaded;
  33810. /**
  33811. * Sets the data of the sound from an audiobuffer
  33812. * @param audioBuffer The audioBuffer containing the data
  33813. */
  33814. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33815. /**
  33816. * Updates the current sounds options such as maxdistance, loop...
  33817. * @param options A JSON object containing values named as the object properties
  33818. */
  33819. updateOptions(options: any): void;
  33820. private _createSpatialParameters;
  33821. private _updateSpatialParameters;
  33822. /**
  33823. * Switch the panning model to HRTF:
  33824. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33826. */
  33827. switchPanningModelToHRTF(): void;
  33828. /**
  33829. * Switch the panning model to Equal Power:
  33830. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33832. */
  33833. switchPanningModelToEqualPower(): void;
  33834. private _switchPanningModel;
  33835. /**
  33836. * Connect this sound to a sound track audio node like gain...
  33837. * @param soundTrackAudioNode the sound track audio node to connect to
  33838. */
  33839. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33840. /**
  33841. * Transform this sound into a directional source
  33842. * @param coneInnerAngle Size of the inner cone in degree
  33843. * @param coneOuterAngle Size of the outer cone in degree
  33844. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33845. */
  33846. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33847. /**
  33848. * Gets or sets the inner angle for the directional cone.
  33849. */
  33850. /**
  33851. * Gets or sets the inner angle for the directional cone.
  33852. */
  33853. directionalConeInnerAngle: number;
  33854. /**
  33855. * Gets or sets the outer angle for the directional cone.
  33856. */
  33857. /**
  33858. * Gets or sets the outer angle for the directional cone.
  33859. */
  33860. directionalConeOuterAngle: number;
  33861. /**
  33862. * Sets the position of the emitter if spatial sound is enabled
  33863. * @param newPosition Defines the new posisiton
  33864. */
  33865. setPosition(newPosition: Vector3): void;
  33866. /**
  33867. * Sets the local direction of the emitter if spatial sound is enabled
  33868. * @param newLocalDirection Defines the new local direction
  33869. */
  33870. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33871. private _updateDirection;
  33872. /** @hidden */
  33873. updateDistanceFromListener(): void;
  33874. /**
  33875. * Sets a new custom attenuation function for the sound.
  33876. * @param callback Defines the function used for the attenuation
  33877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33878. */
  33879. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33880. /**
  33881. * Play the sound
  33882. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33883. * @param offset (optional) Start the sound setting it at a specific time
  33884. */
  33885. play(time?: number, offset?: number): void;
  33886. private _onended;
  33887. /**
  33888. * Stop the sound
  33889. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33890. */
  33891. stop(time?: number): void;
  33892. /**
  33893. * Put the sound in pause
  33894. */
  33895. pause(): void;
  33896. /**
  33897. * Sets a dedicated volume for this sounds
  33898. * @param newVolume Define the new volume of the sound
  33899. * @param time Define in how long the sound should be at this value
  33900. */
  33901. setVolume(newVolume: number, time?: number): void;
  33902. /**
  33903. * Set the sound play back rate
  33904. * @param newPlaybackRate Define the playback rate the sound should be played at
  33905. */
  33906. setPlaybackRate(newPlaybackRate: number): void;
  33907. /**
  33908. * Gets the volume of the sound.
  33909. * @returns the volume of the sound
  33910. */
  33911. getVolume(): number;
  33912. /**
  33913. * Attach the sound to a dedicated mesh
  33914. * @param transformNode The transform node to connect the sound with
  33915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33916. */
  33917. attachToMesh(transformNode: TransformNode): void;
  33918. /**
  33919. * Detach the sound from the previously attached mesh
  33920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33921. */
  33922. detachFromMesh(): void;
  33923. private _onRegisterAfterWorldMatrixUpdate;
  33924. /**
  33925. * Clone the current sound in the scene.
  33926. * @returns the new sound clone
  33927. */
  33928. clone(): Nullable<Sound>;
  33929. /**
  33930. * Gets the current underlying audio buffer containing the data
  33931. * @returns the audio buffer
  33932. */
  33933. getAudioBuffer(): Nullable<AudioBuffer>;
  33934. /**
  33935. * Serializes the Sound in a JSON representation
  33936. * @returns the JSON representation of the sound
  33937. */
  33938. serialize(): any;
  33939. /**
  33940. * Parse a JSON representation of a sound to innstantiate in a given scene
  33941. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33942. * @param scene Define the scene the new parsed sound should be created in
  33943. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33944. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33945. * @returns the newly parsed sound
  33946. */
  33947. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33948. }
  33949. }
  33950. declare module BABYLON {
  33951. /**
  33952. * This defines an action helpful to play a defined sound on a triggered action.
  33953. */
  33954. export class PlaySoundAction extends Action {
  33955. private _sound;
  33956. /**
  33957. * Instantiate the action
  33958. * @param triggerOptions defines the trigger options
  33959. * @param sound defines the sound to play
  33960. * @param condition defines the trigger related conditions
  33961. */
  33962. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33963. /** @hidden */
  33964. _prepare(): void;
  33965. /**
  33966. * Execute the action and play the sound.
  33967. */
  33968. execute(): void;
  33969. /**
  33970. * Serializes the actions and its related information.
  33971. * @param parent defines the object to serialize in
  33972. * @returns the serialized object
  33973. */
  33974. serialize(parent: any): any;
  33975. }
  33976. /**
  33977. * This defines an action helpful to stop a defined sound on a triggered action.
  33978. */
  33979. export class StopSoundAction extends Action {
  33980. private _sound;
  33981. /**
  33982. * Instantiate the action
  33983. * @param triggerOptions defines the trigger options
  33984. * @param sound defines the sound to stop
  33985. * @param condition defines the trigger related conditions
  33986. */
  33987. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33988. /** @hidden */
  33989. _prepare(): void;
  33990. /**
  33991. * Execute the action and stop the sound.
  33992. */
  33993. execute(): void;
  33994. /**
  33995. * Serializes the actions and its related information.
  33996. * @param parent defines the object to serialize in
  33997. * @returns the serialized object
  33998. */
  33999. serialize(parent: any): any;
  34000. }
  34001. }
  34002. declare module BABYLON {
  34003. /**
  34004. * This defines an action responsible to change the value of a property
  34005. * by interpolating between its current value and the newly set one once triggered.
  34006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34007. */
  34008. export class InterpolateValueAction extends Action {
  34009. /**
  34010. * Defines the path of the property where the value should be interpolated
  34011. */
  34012. propertyPath: string;
  34013. /**
  34014. * Defines the target value at the end of the interpolation.
  34015. */
  34016. value: any;
  34017. /**
  34018. * Defines the time it will take for the property to interpolate to the value.
  34019. */
  34020. duration: number;
  34021. /**
  34022. * Defines if the other scene animations should be stopped when the action has been triggered
  34023. */
  34024. stopOtherAnimations?: boolean;
  34025. /**
  34026. * Defines a callback raised once the interpolation animation has been done.
  34027. */
  34028. onInterpolationDone?: () => void;
  34029. /**
  34030. * Observable triggered once the interpolation animation has been done.
  34031. */
  34032. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34033. private _target;
  34034. private _effectiveTarget;
  34035. private _property;
  34036. /**
  34037. * Instantiate the action
  34038. * @param triggerOptions defines the trigger options
  34039. * @param target defines the object containing the value to interpolate
  34040. * @param propertyPath defines the path to the property in the target object
  34041. * @param value defines the target value at the end of the interpolation
  34042. * @param duration deines the time it will take for the property to interpolate to the value.
  34043. * @param condition defines the trigger related conditions
  34044. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34045. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34046. */
  34047. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34048. /** @hidden */
  34049. _prepare(): void;
  34050. /**
  34051. * Execute the action starts the value interpolation.
  34052. */
  34053. execute(): void;
  34054. /**
  34055. * Serializes the actions and its related information.
  34056. * @param parent defines the object to serialize in
  34057. * @returns the serialized object
  34058. */
  34059. serialize(parent: any): any;
  34060. }
  34061. }
  34062. declare module BABYLON {
  34063. /**
  34064. * Options allowed during the creation of a sound track.
  34065. */
  34066. export interface ISoundTrackOptions {
  34067. /**
  34068. * The volume the sound track should take during creation
  34069. */
  34070. volume?: number;
  34071. /**
  34072. * Define if the sound track is the main sound track of the scene
  34073. */
  34074. mainTrack?: boolean;
  34075. }
  34076. /**
  34077. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34078. * It will be also used in a future release to apply effects on a specific track.
  34079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34080. */
  34081. export class SoundTrack {
  34082. /**
  34083. * The unique identifier of the sound track in the scene.
  34084. */
  34085. id: number;
  34086. /**
  34087. * The list of sounds included in the sound track.
  34088. */
  34089. soundCollection: Array<Sound>;
  34090. private _outputAudioNode;
  34091. private _scene;
  34092. private _isMainTrack;
  34093. private _connectedAnalyser;
  34094. private _options;
  34095. private _isInitialized;
  34096. /**
  34097. * Creates a new sound track.
  34098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34099. * @param scene Define the scene the sound track belongs to
  34100. * @param options
  34101. */
  34102. constructor(scene: Scene, options?: ISoundTrackOptions);
  34103. private _initializeSoundTrackAudioGraph;
  34104. /**
  34105. * Release the sound track and its associated resources
  34106. */
  34107. dispose(): void;
  34108. /**
  34109. * Adds a sound to this sound track
  34110. * @param sound define the cound to add
  34111. * @ignoreNaming
  34112. */
  34113. AddSound(sound: Sound): void;
  34114. /**
  34115. * Removes a sound to this sound track
  34116. * @param sound define the cound to remove
  34117. * @ignoreNaming
  34118. */
  34119. RemoveSound(sound: Sound): void;
  34120. /**
  34121. * Set a global volume for the full sound track.
  34122. * @param newVolume Define the new volume of the sound track
  34123. */
  34124. setVolume(newVolume: number): void;
  34125. /**
  34126. * Switch the panning model to HRTF:
  34127. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34129. */
  34130. switchPanningModelToHRTF(): void;
  34131. /**
  34132. * Switch the panning model to Equal Power:
  34133. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34135. */
  34136. switchPanningModelToEqualPower(): void;
  34137. /**
  34138. * Connect the sound track to an audio analyser allowing some amazing
  34139. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34141. * @param analyser The analyser to connect to the engine
  34142. */
  34143. connectToAnalyser(analyser: Analyser): void;
  34144. }
  34145. }
  34146. declare module BABYLON {
  34147. interface AbstractScene {
  34148. /**
  34149. * The list of sounds used in the scene.
  34150. */
  34151. sounds: Nullable<Array<Sound>>;
  34152. }
  34153. interface Scene {
  34154. /**
  34155. * @hidden
  34156. * Backing field
  34157. */
  34158. _mainSoundTrack: SoundTrack;
  34159. /**
  34160. * The main sound track played by the scene.
  34161. * It cotains your primary collection of sounds.
  34162. */
  34163. mainSoundTrack: SoundTrack;
  34164. /**
  34165. * The list of sound tracks added to the scene
  34166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34167. */
  34168. soundTracks: Nullable<Array<SoundTrack>>;
  34169. /**
  34170. * Gets a sound using a given name
  34171. * @param name defines the name to search for
  34172. * @return the found sound or null if not found at all.
  34173. */
  34174. getSoundByName(name: string): Nullable<Sound>;
  34175. /**
  34176. * Gets or sets if audio support is enabled
  34177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34178. */
  34179. audioEnabled: boolean;
  34180. /**
  34181. * Gets or sets if audio will be output to headphones
  34182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34183. */
  34184. headphone: boolean;
  34185. }
  34186. /**
  34187. * Defines the sound scene component responsible to manage any sounds
  34188. * in a given scene.
  34189. */
  34190. export class AudioSceneComponent implements ISceneSerializableComponent {
  34191. /**
  34192. * The component name helpfull to identify the component in the list of scene components.
  34193. */
  34194. readonly name: string;
  34195. /**
  34196. * The scene the component belongs to.
  34197. */
  34198. scene: Scene;
  34199. private _audioEnabled;
  34200. /**
  34201. * Gets whether audio is enabled or not.
  34202. * Please use related enable/disable method to switch state.
  34203. */
  34204. readonly audioEnabled: boolean;
  34205. private _headphone;
  34206. /**
  34207. * Gets whether audio is outputing to headphone or not.
  34208. * Please use the according Switch methods to change output.
  34209. */
  34210. readonly headphone: boolean;
  34211. /**
  34212. * Creates a new instance of the component for the given scene
  34213. * @param scene Defines the scene to register the component in
  34214. */
  34215. constructor(scene: Scene);
  34216. /**
  34217. * Registers the component in a given scene
  34218. */
  34219. register(): void;
  34220. /**
  34221. * Rebuilds the elements related to this component in case of
  34222. * context lost for instance.
  34223. */
  34224. rebuild(): void;
  34225. /**
  34226. * Serializes the component data to the specified json object
  34227. * @param serializationObject The object to serialize to
  34228. */
  34229. serialize(serializationObject: any): void;
  34230. /**
  34231. * Adds all the element from the container to the scene
  34232. * @param container the container holding the elements
  34233. */
  34234. addFromContainer(container: AbstractScene): void;
  34235. /**
  34236. * Removes all the elements in the container from the scene
  34237. * @param container contains the elements to remove
  34238. * @param dispose if the removed element should be disposed (default: false)
  34239. */
  34240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34241. /**
  34242. * Disposes the component and the associated ressources.
  34243. */
  34244. dispose(): void;
  34245. /**
  34246. * Disables audio in the associated scene.
  34247. */
  34248. disableAudio(): void;
  34249. /**
  34250. * Enables audio in the associated scene.
  34251. */
  34252. enableAudio(): void;
  34253. /**
  34254. * Switch audio to headphone output.
  34255. */
  34256. switchAudioModeForHeadphones(): void;
  34257. /**
  34258. * Switch audio to normal speakers.
  34259. */
  34260. switchAudioModeForNormalSpeakers(): void;
  34261. private _afterRender;
  34262. }
  34263. }
  34264. declare module BABYLON {
  34265. /**
  34266. * Wraps one or more Sound objects and selects one with random weight for playback.
  34267. */
  34268. export class WeightedSound {
  34269. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34270. loop: boolean;
  34271. private _coneInnerAngle;
  34272. private _coneOuterAngle;
  34273. private _volume;
  34274. /** A Sound is currently playing. */
  34275. isPlaying: boolean;
  34276. /** A Sound is currently paused. */
  34277. isPaused: boolean;
  34278. private _sounds;
  34279. private _weights;
  34280. private _currentIndex?;
  34281. /**
  34282. * Creates a new WeightedSound from the list of sounds given.
  34283. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34284. * @param sounds Array of Sounds that will be selected from.
  34285. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34286. */
  34287. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34288. /**
  34289. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34290. */
  34291. /**
  34292. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34293. */
  34294. directionalConeInnerAngle: number;
  34295. /**
  34296. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34297. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34298. */
  34299. /**
  34300. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34301. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34302. */
  34303. directionalConeOuterAngle: number;
  34304. /**
  34305. * Playback volume.
  34306. */
  34307. /**
  34308. * Playback volume.
  34309. */
  34310. volume: number;
  34311. private _onended;
  34312. /**
  34313. * Suspend playback
  34314. */
  34315. pause(): void;
  34316. /**
  34317. * Stop playback
  34318. */
  34319. stop(): void;
  34320. /**
  34321. * Start playback.
  34322. * @param startOffset Position the clip head at a specific time in seconds.
  34323. */
  34324. play(startOffset?: number): void;
  34325. }
  34326. }
  34327. declare module BABYLON {
  34328. /**
  34329. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34331. */
  34332. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34333. /**
  34334. * Gets the name of the behavior.
  34335. */
  34336. readonly name: string;
  34337. /**
  34338. * The easing function used by animations
  34339. */
  34340. static EasingFunction: BackEase;
  34341. /**
  34342. * The easing mode used by animations
  34343. */
  34344. static EasingMode: number;
  34345. /**
  34346. * The duration of the animation, in milliseconds
  34347. */
  34348. transitionDuration: number;
  34349. /**
  34350. * Length of the distance animated by the transition when lower radius is reached
  34351. */
  34352. lowerRadiusTransitionRange: number;
  34353. /**
  34354. * Length of the distance animated by the transition when upper radius is reached
  34355. */
  34356. upperRadiusTransitionRange: number;
  34357. private _autoTransitionRange;
  34358. /**
  34359. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34360. */
  34361. /**
  34362. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34363. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34364. */
  34365. autoTransitionRange: boolean;
  34366. private _attachedCamera;
  34367. private _onAfterCheckInputsObserver;
  34368. private _onMeshTargetChangedObserver;
  34369. /**
  34370. * Initializes the behavior.
  34371. */
  34372. init(): void;
  34373. /**
  34374. * Attaches the behavior to its arc rotate camera.
  34375. * @param camera Defines the camera to attach the behavior to
  34376. */
  34377. attach(camera: ArcRotateCamera): void;
  34378. /**
  34379. * Detaches the behavior from its current arc rotate camera.
  34380. */
  34381. detach(): void;
  34382. private _radiusIsAnimating;
  34383. private _radiusBounceTransition;
  34384. private _animatables;
  34385. private _cachedWheelPrecision;
  34386. /**
  34387. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34388. * @param radiusLimit The limit to check against.
  34389. * @return Bool to indicate if at limit.
  34390. */
  34391. private _isRadiusAtLimit;
  34392. /**
  34393. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34394. * @param radiusDelta The delta by which to animate to. Can be negative.
  34395. */
  34396. private _applyBoundRadiusAnimation;
  34397. /**
  34398. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34399. */
  34400. protected _clearAnimationLocks(): void;
  34401. /**
  34402. * Stops and removes all animations that have been applied to the camera
  34403. */
  34404. stopAllAnimations(): void;
  34405. }
  34406. }
  34407. declare module BABYLON {
  34408. /**
  34409. * 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.
  34410. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34411. */
  34412. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34413. /**
  34414. * Gets the name of the behavior.
  34415. */
  34416. readonly name: string;
  34417. private _mode;
  34418. private _radiusScale;
  34419. private _positionScale;
  34420. private _defaultElevation;
  34421. private _elevationReturnTime;
  34422. private _elevationReturnWaitTime;
  34423. private _zoomStopsAnimation;
  34424. private _framingTime;
  34425. /**
  34426. * The easing function used by animations
  34427. */
  34428. static EasingFunction: ExponentialEase;
  34429. /**
  34430. * The easing mode used by animations
  34431. */
  34432. static EasingMode: number;
  34433. /**
  34434. * Sets the current mode used by the behavior
  34435. */
  34436. /**
  34437. * Gets current mode used by the behavior.
  34438. */
  34439. mode: number;
  34440. /**
  34441. * Sets the scale applied to the radius (1 by default)
  34442. */
  34443. /**
  34444. * Gets the scale applied to the radius
  34445. */
  34446. radiusScale: number;
  34447. /**
  34448. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34449. */
  34450. /**
  34451. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34452. */
  34453. positionScale: number;
  34454. /**
  34455. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34456. * behaviour is triggered, in radians.
  34457. */
  34458. /**
  34459. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34460. * behaviour is triggered, in radians.
  34461. */
  34462. defaultElevation: number;
  34463. /**
  34464. * Sets the time (in milliseconds) taken to return to the default beta position.
  34465. * Negative value indicates camera should not return to default.
  34466. */
  34467. /**
  34468. * Gets the time (in milliseconds) taken to return to the default beta position.
  34469. * Negative value indicates camera should not return to default.
  34470. */
  34471. elevationReturnTime: number;
  34472. /**
  34473. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34474. */
  34475. /**
  34476. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34477. */
  34478. elevationReturnWaitTime: number;
  34479. /**
  34480. * Sets the flag that indicates if user zooming should stop animation.
  34481. */
  34482. /**
  34483. * Gets the flag that indicates if user zooming should stop animation.
  34484. */
  34485. zoomStopsAnimation: boolean;
  34486. /**
  34487. * Sets the transition time when framing the mesh, in milliseconds
  34488. */
  34489. /**
  34490. * Gets the transition time when framing the mesh, in milliseconds
  34491. */
  34492. framingTime: number;
  34493. /**
  34494. * Define if the behavior should automatically change the configured
  34495. * camera limits and sensibilities.
  34496. */
  34497. autoCorrectCameraLimitsAndSensibility: boolean;
  34498. private _onPrePointerObservableObserver;
  34499. private _onAfterCheckInputsObserver;
  34500. private _onMeshTargetChangedObserver;
  34501. private _attachedCamera;
  34502. private _isPointerDown;
  34503. private _lastInteractionTime;
  34504. /**
  34505. * Initializes the behavior.
  34506. */
  34507. init(): void;
  34508. /**
  34509. * Attaches the behavior to its arc rotate camera.
  34510. * @param camera Defines the camera to attach the behavior to
  34511. */
  34512. attach(camera: ArcRotateCamera): void;
  34513. /**
  34514. * Detaches the behavior from its current arc rotate camera.
  34515. */
  34516. detach(): void;
  34517. private _animatables;
  34518. private _betaIsAnimating;
  34519. private _betaTransition;
  34520. private _radiusTransition;
  34521. private _vectorTransition;
  34522. /**
  34523. * Targets the given mesh and updates zoom level accordingly.
  34524. * @param mesh The mesh to target.
  34525. * @param radius Optional. If a cached radius position already exists, overrides default.
  34526. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34529. */
  34530. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34531. /**
  34532. * Targets the given mesh with its children and updates zoom level accordingly.
  34533. * @param mesh The mesh to target.
  34534. * @param radius Optional. If a cached radius position already exists, overrides default.
  34535. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34538. */
  34539. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34540. /**
  34541. * Targets the given meshes with their children and updates zoom level accordingly.
  34542. * @param meshes The mesh to target.
  34543. * @param radius Optional. If a cached radius position already exists, overrides default.
  34544. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34547. */
  34548. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34549. /**
  34550. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34551. * @param minimumWorld Determines the smaller position of the bounding box extend
  34552. * @param maximumWorld Determines the bigger position of the bounding box extend
  34553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34555. */
  34556. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34557. /**
  34558. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34559. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34560. * frustum width.
  34561. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34562. * to fully enclose the mesh in the viewing frustum.
  34563. */
  34564. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34565. /**
  34566. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34567. * is automatically returned to its default position (expected to be above ground plane).
  34568. */
  34569. private _maintainCameraAboveGround;
  34570. /**
  34571. * Returns the frustum slope based on the canvas ratio and camera FOV
  34572. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34573. */
  34574. private _getFrustumSlope;
  34575. /**
  34576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34577. */
  34578. private _clearAnimationLocks;
  34579. /**
  34580. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34581. */
  34582. private _applyUserInteraction;
  34583. /**
  34584. * Stops and removes all animations that have been applied to the camera
  34585. */
  34586. stopAllAnimations(): void;
  34587. /**
  34588. * Gets a value indicating if the user is moving the camera
  34589. */
  34590. readonly isUserIsMoving: boolean;
  34591. /**
  34592. * The camera can move all the way towards the mesh.
  34593. */
  34594. static IgnoreBoundsSizeMode: number;
  34595. /**
  34596. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34597. */
  34598. static FitFrustumSidesMode: number;
  34599. }
  34600. }
  34601. declare module BABYLON {
  34602. /**
  34603. * Base class for Camera Pointer Inputs.
  34604. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34605. * for example usage.
  34606. */
  34607. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34608. /**
  34609. * Defines the camera the input is attached to.
  34610. */
  34611. abstract camera: Camera;
  34612. /**
  34613. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34614. */
  34615. protected _altKey: boolean;
  34616. protected _ctrlKey: boolean;
  34617. protected _metaKey: boolean;
  34618. protected _shiftKey: boolean;
  34619. /**
  34620. * Which mouse buttons were pressed at time of last mouse event.
  34621. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34622. */
  34623. protected _buttonsPressed: number;
  34624. /**
  34625. * Defines the buttons associated with the input to handle camera move.
  34626. */
  34627. buttons: number[];
  34628. /**
  34629. * Attach the input controls to a specific dom element to get the input from.
  34630. * @param element Defines the element the controls should be listened from
  34631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34632. */
  34633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34634. /**
  34635. * Detach the current controls from the specified dom element.
  34636. * @param element Defines the element to stop listening the inputs from
  34637. */
  34638. detachControl(element: Nullable<HTMLElement>): void;
  34639. /**
  34640. * Gets the class name of the current input.
  34641. * @returns the class name
  34642. */
  34643. getClassName(): string;
  34644. /**
  34645. * Get the friendly name associated with the input class.
  34646. * @returns the input friendly name
  34647. */
  34648. getSimpleName(): string;
  34649. /**
  34650. * Called on pointer POINTERDOUBLETAP event.
  34651. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34652. */
  34653. protected onDoubleTap(type: string): void;
  34654. /**
  34655. * Called on pointer POINTERMOVE event if only a single touch is active.
  34656. * Override this method to provide functionality.
  34657. */
  34658. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34659. /**
  34660. * Called on pointer POINTERMOVE event if multiple touches are active.
  34661. * Override this method to provide functionality.
  34662. */
  34663. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34664. /**
  34665. * Called on JS contextmenu event.
  34666. * Override this method to provide functionality.
  34667. */
  34668. protected onContextMenu(evt: PointerEvent): void;
  34669. /**
  34670. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34671. * press.
  34672. * Override this method to provide functionality.
  34673. */
  34674. protected onButtonDown(evt: PointerEvent): void;
  34675. /**
  34676. * Called each time a new POINTERUP event occurs. Ie, for each button
  34677. * release.
  34678. * Override this method to provide functionality.
  34679. */
  34680. protected onButtonUp(evt: PointerEvent): void;
  34681. /**
  34682. * Called when window becomes inactive.
  34683. * Override this method to provide functionality.
  34684. */
  34685. protected onLostFocus(): void;
  34686. private _pointerInput;
  34687. private _observer;
  34688. private _onLostFocus;
  34689. private pointA;
  34690. private pointB;
  34691. }
  34692. }
  34693. declare module BABYLON {
  34694. /**
  34695. * Manage the pointers inputs to control an arc rotate camera.
  34696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34697. */
  34698. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34699. /**
  34700. * Defines the camera the input is attached to.
  34701. */
  34702. camera: ArcRotateCamera;
  34703. /**
  34704. * Gets the class name of the current input.
  34705. * @returns the class name
  34706. */
  34707. getClassName(): string;
  34708. /**
  34709. * Defines the buttons associated with the input to handle camera move.
  34710. */
  34711. buttons: number[];
  34712. /**
  34713. * Defines the pointer angular sensibility along the X axis or how fast is
  34714. * the camera rotating.
  34715. */
  34716. angularSensibilityX: number;
  34717. /**
  34718. * Defines the pointer angular sensibility along the Y axis or how fast is
  34719. * the camera rotating.
  34720. */
  34721. angularSensibilityY: number;
  34722. /**
  34723. * Defines the pointer pinch precision or how fast is the camera zooming.
  34724. */
  34725. pinchPrecision: number;
  34726. /**
  34727. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34728. * from 0.
  34729. * It defines the percentage of current camera.radius to use as delta when
  34730. * pinch zoom is used.
  34731. */
  34732. pinchDeltaPercentage: number;
  34733. /**
  34734. * Defines the pointer panning sensibility or how fast is the camera moving.
  34735. */
  34736. panningSensibility: number;
  34737. /**
  34738. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34739. */
  34740. multiTouchPanning: boolean;
  34741. /**
  34742. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34743. * zoom (pinch) through multitouch.
  34744. */
  34745. multiTouchPanAndZoom: boolean;
  34746. /**
  34747. * Revers pinch action direction.
  34748. */
  34749. pinchInwards: boolean;
  34750. private _isPanClick;
  34751. private _twoFingerActivityCount;
  34752. private _isPinching;
  34753. /**
  34754. * Called on pointer POINTERMOVE event if only a single touch is active.
  34755. */
  34756. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34757. /**
  34758. * Called on pointer POINTERDOUBLETAP event.
  34759. */
  34760. protected onDoubleTap(type: string): void;
  34761. /**
  34762. * Called on pointer POINTERMOVE event if multiple touches are active.
  34763. */
  34764. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34765. /**
  34766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34767. * press.
  34768. */
  34769. protected onButtonDown(evt: PointerEvent): void;
  34770. /**
  34771. * Called each time a new POINTERUP event occurs. Ie, for each button
  34772. * release.
  34773. */
  34774. protected onButtonUp(evt: PointerEvent): void;
  34775. /**
  34776. * Called when window becomes inactive.
  34777. */
  34778. protected onLostFocus(): void;
  34779. }
  34780. }
  34781. declare module BABYLON {
  34782. /**
  34783. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34785. */
  34786. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34787. /**
  34788. * Defines the camera the input is attached to.
  34789. */
  34790. camera: ArcRotateCamera;
  34791. /**
  34792. * Defines the list of key codes associated with the up action (increase alpha)
  34793. */
  34794. keysUp: number[];
  34795. /**
  34796. * Defines the list of key codes associated with the down action (decrease alpha)
  34797. */
  34798. keysDown: number[];
  34799. /**
  34800. * Defines the list of key codes associated with the left action (increase beta)
  34801. */
  34802. keysLeft: number[];
  34803. /**
  34804. * Defines the list of key codes associated with the right action (decrease beta)
  34805. */
  34806. keysRight: number[];
  34807. /**
  34808. * Defines the list of key codes associated with the reset action.
  34809. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34810. */
  34811. keysReset: number[];
  34812. /**
  34813. * Defines the panning sensibility of the inputs.
  34814. * (How fast is the camera paning)
  34815. */
  34816. panningSensibility: number;
  34817. /**
  34818. * Defines the zooming sensibility of the inputs.
  34819. * (How fast is the camera zooming)
  34820. */
  34821. zoomingSensibility: number;
  34822. /**
  34823. * Defines wether maintaining the alt key down switch the movement mode from
  34824. * orientation to zoom.
  34825. */
  34826. useAltToZoom: boolean;
  34827. /**
  34828. * Rotation speed of the camera
  34829. */
  34830. angularSpeed: number;
  34831. private _keys;
  34832. private _ctrlPressed;
  34833. private _altPressed;
  34834. private _onCanvasBlurObserver;
  34835. private _onKeyboardObserver;
  34836. private _engine;
  34837. private _scene;
  34838. /**
  34839. * Attach the input controls to a specific dom element to get the input from.
  34840. * @param element Defines the element the controls should be listened from
  34841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34842. */
  34843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34844. /**
  34845. * Detach the current controls from the specified dom element.
  34846. * @param element Defines the element to stop listening the inputs from
  34847. */
  34848. detachControl(element: Nullable<HTMLElement>): void;
  34849. /**
  34850. * Update the current camera state depending on the inputs that have been used this frame.
  34851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34852. */
  34853. checkInputs(): void;
  34854. /**
  34855. * Gets the class name of the current intput.
  34856. * @returns the class name
  34857. */
  34858. getClassName(): string;
  34859. /**
  34860. * Get the friendly name associated with the input class.
  34861. * @returns the input friendly name
  34862. */
  34863. getSimpleName(): string;
  34864. }
  34865. }
  34866. declare module BABYLON {
  34867. /**
  34868. * Manage the mouse wheel inputs to control an arc rotate camera.
  34869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34870. */
  34871. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34872. /**
  34873. * Defines the camera the input is attached to.
  34874. */
  34875. camera: ArcRotateCamera;
  34876. /**
  34877. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34878. */
  34879. wheelPrecision: number;
  34880. /**
  34881. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34882. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34883. */
  34884. wheelDeltaPercentage: number;
  34885. private _wheel;
  34886. private _observer;
  34887. /**
  34888. * Attach the input controls to a specific dom element to get the input from.
  34889. * @param element Defines the element the controls should be listened from
  34890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34891. */
  34892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34893. /**
  34894. * Detach the current controls from the specified dom element.
  34895. * @param element Defines the element to stop listening the inputs from
  34896. */
  34897. detachControl(element: Nullable<HTMLElement>): void;
  34898. /**
  34899. * Gets the class name of the current intput.
  34900. * @returns the class name
  34901. */
  34902. getClassName(): string;
  34903. /**
  34904. * Get the friendly name associated with the input class.
  34905. * @returns the input friendly name
  34906. */
  34907. getSimpleName(): string;
  34908. }
  34909. }
  34910. declare module BABYLON {
  34911. /**
  34912. * Default Inputs manager for the ArcRotateCamera.
  34913. * It groups all the default supported inputs for ease of use.
  34914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34915. */
  34916. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34917. /**
  34918. * Instantiates a new ArcRotateCameraInputsManager.
  34919. * @param camera Defines the camera the inputs belong to
  34920. */
  34921. constructor(camera: ArcRotateCamera);
  34922. /**
  34923. * Add mouse wheel input support to the input manager.
  34924. * @returns the current input manager
  34925. */
  34926. addMouseWheel(): ArcRotateCameraInputsManager;
  34927. /**
  34928. * Add pointers input support to the input manager.
  34929. * @returns the current input manager
  34930. */
  34931. addPointers(): ArcRotateCameraInputsManager;
  34932. /**
  34933. * Add keyboard input support to the input manager.
  34934. * @returns the current input manager
  34935. */
  34936. addKeyboard(): ArcRotateCameraInputsManager;
  34937. }
  34938. }
  34939. declare module BABYLON {
  34940. /**
  34941. * This represents an orbital type of camera.
  34942. *
  34943. * 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.
  34944. * 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.
  34945. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34946. */
  34947. export class ArcRotateCamera extends TargetCamera {
  34948. /**
  34949. * Defines the rotation angle of the camera along the longitudinal axis.
  34950. */
  34951. alpha: number;
  34952. /**
  34953. * Defines the rotation angle of the camera along the latitudinal axis.
  34954. */
  34955. beta: number;
  34956. /**
  34957. * Defines the radius of the camera from it s target point.
  34958. */
  34959. radius: number;
  34960. protected _target: Vector3;
  34961. protected _targetHost: Nullable<AbstractMesh>;
  34962. /**
  34963. * Defines the target point of the camera.
  34964. * The camera looks towards it form the radius distance.
  34965. */
  34966. target: Vector3;
  34967. /**
  34968. * Define the current local position of the camera in the scene
  34969. */
  34970. position: Vector3;
  34971. /**
  34972. * Current inertia value on the longitudinal axis.
  34973. * The bigger this number the longer it will take for the camera to stop.
  34974. */
  34975. inertialAlphaOffset: number;
  34976. /**
  34977. * Current inertia value on the latitudinal axis.
  34978. * The bigger this number the longer it will take for the camera to stop.
  34979. */
  34980. inertialBetaOffset: number;
  34981. /**
  34982. * Current inertia value on the radius axis.
  34983. * The bigger this number the longer it will take for the camera to stop.
  34984. */
  34985. inertialRadiusOffset: number;
  34986. /**
  34987. * Minimum allowed angle on the longitudinal axis.
  34988. * This can help limiting how the Camera is able to move in the scene.
  34989. */
  34990. lowerAlphaLimit: Nullable<number>;
  34991. /**
  34992. * Maximum allowed angle on the longitudinal axis.
  34993. * This can help limiting how the Camera is able to move in the scene.
  34994. */
  34995. upperAlphaLimit: Nullable<number>;
  34996. /**
  34997. * Minimum allowed angle on the latitudinal axis.
  34998. * This can help limiting how the Camera is able to move in the scene.
  34999. */
  35000. lowerBetaLimit: number;
  35001. /**
  35002. * Maximum allowed angle on the latitudinal axis.
  35003. * This can help limiting how the Camera is able to move in the scene.
  35004. */
  35005. upperBetaLimit: number;
  35006. /**
  35007. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35008. * This can help limiting how the Camera is able to move in the scene.
  35009. */
  35010. lowerRadiusLimit: Nullable<number>;
  35011. /**
  35012. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35013. * This can help limiting how the Camera is able to move in the scene.
  35014. */
  35015. upperRadiusLimit: Nullable<number>;
  35016. /**
  35017. * Defines the current inertia value used during panning of the camera along the X axis.
  35018. */
  35019. inertialPanningX: number;
  35020. /**
  35021. * Defines the current inertia value used during panning of the camera along the Y axis.
  35022. */
  35023. inertialPanningY: number;
  35024. /**
  35025. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35026. * Basically if your fingers moves away from more than this distance you will be considered
  35027. * in pinch mode.
  35028. */
  35029. pinchToPanMaxDistance: number;
  35030. /**
  35031. * Defines the maximum distance the camera can pan.
  35032. * This could help keeping the cammera always in your scene.
  35033. */
  35034. panningDistanceLimit: Nullable<number>;
  35035. /**
  35036. * Defines the target of the camera before paning.
  35037. */
  35038. panningOriginTarget: Vector3;
  35039. /**
  35040. * Defines the value of the inertia used during panning.
  35041. * 0 would mean stop inertia and one would mean no decelleration at all.
  35042. */
  35043. panningInertia: number;
  35044. /**
  35045. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35046. */
  35047. angularSensibilityX: number;
  35048. /**
  35049. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35050. */
  35051. angularSensibilityY: number;
  35052. /**
  35053. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35054. */
  35055. pinchPrecision: number;
  35056. /**
  35057. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35058. * It will be used instead of pinchDeltaPrecision if different from 0.
  35059. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35060. */
  35061. pinchDeltaPercentage: number;
  35062. /**
  35063. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35064. */
  35065. panningSensibility: number;
  35066. /**
  35067. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35068. */
  35069. keysUp: number[];
  35070. /**
  35071. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35072. */
  35073. keysDown: number[];
  35074. /**
  35075. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35076. */
  35077. keysLeft: number[];
  35078. /**
  35079. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35080. */
  35081. keysRight: number[];
  35082. /**
  35083. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35084. */
  35085. wheelPrecision: number;
  35086. /**
  35087. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35088. * It will be used instead of pinchDeltaPrecision if different from 0.
  35089. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35090. */
  35091. wheelDeltaPercentage: number;
  35092. /**
  35093. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35094. */
  35095. zoomOnFactor: number;
  35096. /**
  35097. * Defines a screen offset for the camera position.
  35098. */
  35099. targetScreenOffset: Vector2;
  35100. /**
  35101. * Allows the camera to be completely reversed.
  35102. * If false the camera can not arrive upside down.
  35103. */
  35104. allowUpsideDown: boolean;
  35105. /**
  35106. * Define if double tap/click is used to restore the previously saved state of the camera.
  35107. */
  35108. useInputToRestoreState: boolean;
  35109. /** @hidden */
  35110. _viewMatrix: Matrix;
  35111. /** @hidden */
  35112. _useCtrlForPanning: boolean;
  35113. /** @hidden */
  35114. _panningMouseButton: number;
  35115. /**
  35116. * Defines the input associated to the camera.
  35117. */
  35118. inputs: ArcRotateCameraInputsManager;
  35119. /** @hidden */
  35120. _reset: () => void;
  35121. /**
  35122. * Defines the allowed panning axis.
  35123. */
  35124. panningAxis: Vector3;
  35125. protected _localDirection: Vector3;
  35126. protected _transformedDirection: Vector3;
  35127. private _bouncingBehavior;
  35128. /**
  35129. * Gets the bouncing behavior of the camera if it has been enabled.
  35130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35131. */
  35132. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35133. /**
  35134. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35136. */
  35137. useBouncingBehavior: boolean;
  35138. private _framingBehavior;
  35139. /**
  35140. * Gets the framing behavior of the camera if it has been enabled.
  35141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35142. */
  35143. readonly framingBehavior: Nullable<FramingBehavior>;
  35144. /**
  35145. * Defines if the framing behavior of the camera is enabled on the camera.
  35146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35147. */
  35148. useFramingBehavior: boolean;
  35149. private _autoRotationBehavior;
  35150. /**
  35151. * Gets the auto rotation behavior of the camera if it has been enabled.
  35152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35153. */
  35154. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35155. /**
  35156. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35158. */
  35159. useAutoRotationBehavior: boolean;
  35160. /**
  35161. * Observable triggered when the mesh target has been changed on the camera.
  35162. */
  35163. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35164. /**
  35165. * Event raised when the camera is colliding with a mesh.
  35166. */
  35167. onCollide: (collidedMesh: AbstractMesh) => void;
  35168. /**
  35169. * Defines whether the camera should check collision with the objects oh the scene.
  35170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35171. */
  35172. checkCollisions: boolean;
  35173. /**
  35174. * Defines the collision radius of the camera.
  35175. * This simulates a sphere around the camera.
  35176. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35177. */
  35178. collisionRadius: Vector3;
  35179. protected _collider: Collider;
  35180. protected _previousPosition: Vector3;
  35181. protected _collisionVelocity: Vector3;
  35182. protected _newPosition: Vector3;
  35183. protected _previousAlpha: number;
  35184. protected _previousBeta: number;
  35185. protected _previousRadius: number;
  35186. protected _collisionTriggered: boolean;
  35187. protected _targetBoundingCenter: Nullable<Vector3>;
  35188. private _computationVector;
  35189. private _tempAxisVector;
  35190. private _tempAxisRotationMatrix;
  35191. /**
  35192. * Instantiates a new ArcRotateCamera in a given scene
  35193. * @param name Defines the name of the camera
  35194. * @param alpha Defines the camera rotation along the logitudinal axis
  35195. * @param beta Defines the camera rotation along the latitudinal axis
  35196. * @param radius Defines the camera distance from its target
  35197. * @param target Defines the camera target
  35198. * @param scene Defines the scene the camera belongs to
  35199. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35200. */
  35201. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35202. /** @hidden */
  35203. _initCache(): void;
  35204. /** @hidden */
  35205. _updateCache(ignoreParentClass?: boolean): void;
  35206. protected _getTargetPosition(): Vector3;
  35207. private _storedAlpha;
  35208. private _storedBeta;
  35209. private _storedRadius;
  35210. private _storedTarget;
  35211. /**
  35212. * Stores the current state of the camera (alpha, beta, radius and target)
  35213. * @returns the camera itself
  35214. */
  35215. storeState(): Camera;
  35216. /**
  35217. * @hidden
  35218. * Restored camera state. You must call storeState() first
  35219. */
  35220. _restoreStateValues(): boolean;
  35221. /** @hidden */
  35222. _isSynchronizedViewMatrix(): boolean;
  35223. /**
  35224. * Attached controls to the current camera.
  35225. * @param element Defines the element the controls should be listened from
  35226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35227. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35228. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35229. */
  35230. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35231. /**
  35232. * Detach the current controls from the camera.
  35233. * The camera will stop reacting to inputs.
  35234. * @param element Defines the element to stop listening the inputs from
  35235. */
  35236. detachControl(element: HTMLElement): void;
  35237. /** @hidden */
  35238. _checkInputs(): void;
  35239. protected _checkLimits(): void;
  35240. /**
  35241. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35242. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35243. */
  35244. rebuildAnglesAndRadius(updateView?: boolean): void;
  35245. /**
  35246. * Use a position to define the current camera related information like aplha, beta and radius
  35247. * @param position Defines the position to set the camera at
  35248. */
  35249. setPosition(position: Vector3): void;
  35250. /**
  35251. * Defines the target the camera should look at.
  35252. * This will automatically adapt alpha beta and radius to fit within the new target.
  35253. * @param target Defines the new target as a Vector or a mesh
  35254. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35255. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35256. */
  35257. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35258. /** @hidden */
  35259. _getViewMatrix(): Matrix;
  35260. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35261. /**
  35262. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35263. * @param meshes Defines the mesh to zoom on
  35264. * @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)
  35265. */
  35266. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35267. /**
  35268. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35269. * The target will be changed but the radius
  35270. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35271. * @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)
  35272. */
  35273. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35274. min: Vector3;
  35275. max: Vector3;
  35276. distance: number;
  35277. }, doNotUpdateMaxZ?: boolean): void;
  35278. /**
  35279. * @override
  35280. * Override Camera.createRigCamera
  35281. */
  35282. createRigCamera(name: string, cameraIndex: number): Camera;
  35283. /**
  35284. * @hidden
  35285. * @override
  35286. * Override Camera._updateRigCameras
  35287. */
  35288. _updateRigCameras(): void;
  35289. /**
  35290. * Destroy the camera and release the current resources hold by it.
  35291. */
  35292. dispose(): void;
  35293. /**
  35294. * Gets the current object class name.
  35295. * @return the class name
  35296. */
  35297. getClassName(): string;
  35298. }
  35299. }
  35300. declare module BABYLON {
  35301. /**
  35302. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35304. */
  35305. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35306. /**
  35307. * Gets the name of the behavior.
  35308. */
  35309. readonly name: string;
  35310. private _zoomStopsAnimation;
  35311. private _idleRotationSpeed;
  35312. private _idleRotationWaitTime;
  35313. private _idleRotationSpinupTime;
  35314. /**
  35315. * Sets the flag that indicates if user zooming should stop animation.
  35316. */
  35317. /**
  35318. * Gets the flag that indicates if user zooming should stop animation.
  35319. */
  35320. zoomStopsAnimation: boolean;
  35321. /**
  35322. * Sets the default speed at which the camera rotates around the model.
  35323. */
  35324. /**
  35325. * Gets the default speed at which the camera rotates around the model.
  35326. */
  35327. idleRotationSpeed: number;
  35328. /**
  35329. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35330. */
  35331. /**
  35332. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35333. */
  35334. idleRotationWaitTime: number;
  35335. /**
  35336. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35337. */
  35338. /**
  35339. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35340. */
  35341. idleRotationSpinupTime: number;
  35342. /**
  35343. * Gets a value indicating if the camera is currently rotating because of this behavior
  35344. */
  35345. readonly rotationInProgress: boolean;
  35346. private _onPrePointerObservableObserver;
  35347. private _onAfterCheckInputsObserver;
  35348. private _attachedCamera;
  35349. private _isPointerDown;
  35350. private _lastFrameTime;
  35351. private _lastInteractionTime;
  35352. private _cameraRotationSpeed;
  35353. /**
  35354. * Initializes the behavior.
  35355. */
  35356. init(): void;
  35357. /**
  35358. * Attaches the behavior to its arc rotate camera.
  35359. * @param camera Defines the camera to attach the behavior to
  35360. */
  35361. attach(camera: ArcRotateCamera): void;
  35362. /**
  35363. * Detaches the behavior from its current arc rotate camera.
  35364. */
  35365. detach(): void;
  35366. /**
  35367. * Returns true if user is scrolling.
  35368. * @return true if user is scrolling.
  35369. */
  35370. private _userIsZooming;
  35371. private _lastFrameRadius;
  35372. private _shouldAnimationStopForInteraction;
  35373. /**
  35374. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35375. */
  35376. private _applyUserInteraction;
  35377. private _userIsMoving;
  35378. }
  35379. }
  35380. declare module BABYLON {
  35381. /**
  35382. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35383. */
  35384. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35385. private ui;
  35386. /**
  35387. * The name of the behavior
  35388. */
  35389. name: string;
  35390. /**
  35391. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35392. */
  35393. distanceAwayFromFace: number;
  35394. /**
  35395. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35396. */
  35397. distanceAwayFromBottomOfFace: number;
  35398. private _faceVectors;
  35399. private _target;
  35400. private _scene;
  35401. private _onRenderObserver;
  35402. private _tmpMatrix;
  35403. private _tmpVector;
  35404. /**
  35405. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35406. * @param ui The transform node that should be attched to the mesh
  35407. */
  35408. constructor(ui: TransformNode);
  35409. /**
  35410. * Initializes the behavior
  35411. */
  35412. init(): void;
  35413. private _closestFace;
  35414. private _zeroVector;
  35415. private _lookAtTmpMatrix;
  35416. private _lookAtToRef;
  35417. /**
  35418. * Attaches the AttachToBoxBehavior to the passed in mesh
  35419. * @param target The mesh that the specified node will be attached to
  35420. */
  35421. attach(target: Mesh): void;
  35422. /**
  35423. * Detaches the behavior from the mesh
  35424. */
  35425. detach(): void;
  35426. }
  35427. }
  35428. declare module BABYLON {
  35429. /**
  35430. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35431. */
  35432. export class FadeInOutBehavior implements Behavior<Mesh> {
  35433. /**
  35434. * Time in milliseconds to delay before fading in (Default: 0)
  35435. */
  35436. delay: number;
  35437. /**
  35438. * Time in milliseconds for the mesh to fade in (Default: 300)
  35439. */
  35440. fadeInTime: number;
  35441. private _millisecondsPerFrame;
  35442. private _hovered;
  35443. private _hoverValue;
  35444. private _ownerNode;
  35445. /**
  35446. * Instatiates the FadeInOutBehavior
  35447. */
  35448. constructor();
  35449. /**
  35450. * The name of the behavior
  35451. */
  35452. readonly name: string;
  35453. /**
  35454. * Initializes the behavior
  35455. */
  35456. init(): void;
  35457. /**
  35458. * Attaches the fade behavior on the passed in mesh
  35459. * @param ownerNode The mesh that will be faded in/out once attached
  35460. */
  35461. attach(ownerNode: Mesh): void;
  35462. /**
  35463. * Detaches the behavior from the mesh
  35464. */
  35465. detach(): void;
  35466. /**
  35467. * Triggers the mesh to begin fading in or out
  35468. * @param value if the object should fade in or out (true to fade in)
  35469. */
  35470. fadeIn(value: boolean): void;
  35471. private _update;
  35472. private _setAllVisibility;
  35473. }
  35474. }
  35475. declare module BABYLON {
  35476. /**
  35477. * Class containing a set of static utilities functions for managing Pivots
  35478. * @hidden
  35479. */
  35480. export class PivotTools {
  35481. private static _PivotCached;
  35482. private static _OldPivotPoint;
  35483. private static _PivotTranslation;
  35484. private static _PivotTmpVector;
  35485. /** @hidden */
  35486. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35487. /** @hidden */
  35488. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35489. }
  35490. }
  35491. declare module BABYLON {
  35492. /**
  35493. * Class containing static functions to help procedurally build meshes
  35494. */
  35495. export class PlaneBuilder {
  35496. /**
  35497. * Creates a plane mesh
  35498. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35499. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35500. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35502. * * 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
  35503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35504. * @param name defines the name of the mesh
  35505. * @param options defines the options used to create the mesh
  35506. * @param scene defines the hosting scene
  35507. * @returns the plane mesh
  35508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35509. */
  35510. static CreatePlane(name: string, options: {
  35511. size?: number;
  35512. width?: number;
  35513. height?: number;
  35514. sideOrientation?: number;
  35515. frontUVs?: Vector4;
  35516. backUVs?: Vector4;
  35517. updatable?: boolean;
  35518. sourcePlane?: Plane;
  35519. }, scene: Scene): Mesh;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35525. */
  35526. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35527. private static _AnyMouseID;
  35528. private _attachedNode;
  35529. private _dragPlane;
  35530. private _scene;
  35531. private _pointerObserver;
  35532. private _beforeRenderObserver;
  35533. private static _planeScene;
  35534. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35535. /**
  35536. * 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)
  35537. */
  35538. maxDragAngle: number;
  35539. /**
  35540. * @hidden
  35541. */
  35542. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35543. /**
  35544. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35545. */
  35546. currentDraggingPointerID: number;
  35547. /**
  35548. * The last position where the pointer hit the drag plane in world space
  35549. */
  35550. lastDragPosition: Vector3;
  35551. /**
  35552. * If the behavior is currently in a dragging state
  35553. */
  35554. dragging: boolean;
  35555. /**
  35556. * 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)
  35557. */
  35558. dragDeltaRatio: number;
  35559. /**
  35560. * If the drag plane orientation should be updated during the dragging (Default: true)
  35561. */
  35562. updateDragPlane: boolean;
  35563. private _debugMode;
  35564. private _moving;
  35565. /**
  35566. * Fires each time the attached mesh is dragged with the pointer
  35567. * * delta between last drag position and current drag position in world space
  35568. * * dragDistance along the drag axis
  35569. * * dragPlaneNormal normal of the current drag plane used during the drag
  35570. * * dragPlanePoint in world space where the drag intersects the drag plane
  35571. */
  35572. onDragObservable: Observable<{
  35573. delta: Vector3;
  35574. dragPlanePoint: Vector3;
  35575. dragPlaneNormal: Vector3;
  35576. dragDistance: number;
  35577. pointerId: number;
  35578. }>;
  35579. /**
  35580. * Fires each time a drag begins (eg. mouse down on mesh)
  35581. */
  35582. onDragStartObservable: Observable<{
  35583. dragPlanePoint: Vector3;
  35584. pointerId: number;
  35585. }>;
  35586. /**
  35587. * Fires each time a drag ends (eg. mouse release after drag)
  35588. */
  35589. onDragEndObservable: Observable<{
  35590. dragPlanePoint: Vector3;
  35591. pointerId: number;
  35592. }>;
  35593. /**
  35594. * If the attached mesh should be moved when dragged
  35595. */
  35596. moveAttached: boolean;
  35597. /**
  35598. * If the drag behavior will react to drag events (Default: true)
  35599. */
  35600. enabled: boolean;
  35601. /**
  35602. * If camera controls should be detached during the drag
  35603. */
  35604. detachCameraControls: boolean;
  35605. /**
  35606. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35607. */
  35608. useObjectOrienationForDragging: boolean;
  35609. private _options;
  35610. /**
  35611. * Creates a pointer drag behavior that can be attached to a mesh
  35612. * @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)
  35613. */
  35614. constructor(options?: {
  35615. dragAxis?: Vector3;
  35616. dragPlaneNormal?: Vector3;
  35617. });
  35618. /**
  35619. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35620. */
  35621. validateDrag: (targetPosition: Vector3) => boolean;
  35622. /**
  35623. * The name of the behavior
  35624. */
  35625. readonly name: string;
  35626. /**
  35627. * Initializes the behavior
  35628. */
  35629. init(): void;
  35630. private _tmpVector;
  35631. private _alternatePickedPoint;
  35632. private _worldDragAxis;
  35633. private _targetPosition;
  35634. private _attachedElement;
  35635. /**
  35636. * Attaches the drag behavior the passed in mesh
  35637. * @param ownerNode The mesh that will be dragged around once attached
  35638. */
  35639. attach(ownerNode: AbstractMesh): void;
  35640. /**
  35641. * Force relase the drag action by code.
  35642. */
  35643. releaseDrag(): void;
  35644. private _startDragRay;
  35645. private _lastPointerRay;
  35646. /**
  35647. * Simulates the start of a pointer drag event on the behavior
  35648. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35649. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35650. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35651. */
  35652. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35653. private _startDrag;
  35654. private _dragDelta;
  35655. private _moveDrag;
  35656. private _pickWithRayOnDragPlane;
  35657. private _pointA;
  35658. private _pointB;
  35659. private _pointC;
  35660. private _lineA;
  35661. private _lineB;
  35662. private _localAxis;
  35663. private _lookAt;
  35664. private _updateDragPlanePosition;
  35665. /**
  35666. * Detaches the behavior from the mesh
  35667. */
  35668. detach(): void;
  35669. }
  35670. }
  35671. declare module BABYLON {
  35672. /**
  35673. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35674. */
  35675. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35676. private _dragBehaviorA;
  35677. private _dragBehaviorB;
  35678. private _startDistance;
  35679. private _initialScale;
  35680. private _targetScale;
  35681. private _ownerNode;
  35682. private _sceneRenderObserver;
  35683. /**
  35684. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35685. */
  35686. constructor();
  35687. /**
  35688. * The name of the behavior
  35689. */
  35690. readonly name: string;
  35691. /**
  35692. * Initializes the behavior
  35693. */
  35694. init(): void;
  35695. private _getCurrentDistance;
  35696. /**
  35697. * Attaches the scale behavior the passed in mesh
  35698. * @param ownerNode The mesh that will be scaled around once attached
  35699. */
  35700. attach(ownerNode: Mesh): void;
  35701. /**
  35702. * Detaches the behavior from the mesh
  35703. */
  35704. detach(): void;
  35705. }
  35706. }
  35707. declare module BABYLON {
  35708. /**
  35709. * 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
  35710. */
  35711. export class SixDofDragBehavior implements Behavior<Mesh> {
  35712. private static _virtualScene;
  35713. private _ownerNode;
  35714. private _sceneRenderObserver;
  35715. private _scene;
  35716. private _targetPosition;
  35717. private _virtualOriginMesh;
  35718. private _virtualDragMesh;
  35719. private _pointerObserver;
  35720. private _moving;
  35721. private _startingOrientation;
  35722. /**
  35723. * 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)
  35724. */
  35725. private zDragFactor;
  35726. /**
  35727. * If the object should rotate to face the drag origin
  35728. */
  35729. rotateDraggedObject: boolean;
  35730. /**
  35731. * If the behavior is currently in a dragging state
  35732. */
  35733. dragging: boolean;
  35734. /**
  35735. * 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)
  35736. */
  35737. dragDeltaRatio: number;
  35738. /**
  35739. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35740. */
  35741. currentDraggingPointerID: number;
  35742. /**
  35743. * If camera controls should be detached during the drag
  35744. */
  35745. detachCameraControls: boolean;
  35746. /**
  35747. * Fires each time a drag starts
  35748. */
  35749. onDragStartObservable: Observable<{}>;
  35750. /**
  35751. * Fires each time a drag ends (eg. mouse release after drag)
  35752. */
  35753. onDragEndObservable: Observable<{}>;
  35754. /**
  35755. * 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
  35756. */
  35757. constructor();
  35758. /**
  35759. * The name of the behavior
  35760. */
  35761. readonly name: string;
  35762. /**
  35763. * Initializes the behavior
  35764. */
  35765. init(): void;
  35766. /**
  35767. * Attaches the scale behavior the passed in mesh
  35768. * @param ownerNode The mesh that will be scaled around once attached
  35769. */
  35770. attach(ownerNode: Mesh): void;
  35771. /**
  35772. * Detaches the behavior from the mesh
  35773. */
  35774. detach(): void;
  35775. }
  35776. }
  35777. declare module BABYLON {
  35778. /**
  35779. * Class used to apply inverse kinematics to bones
  35780. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35781. */
  35782. export class BoneIKController {
  35783. private static _tmpVecs;
  35784. private static _tmpQuat;
  35785. private static _tmpMats;
  35786. /**
  35787. * Gets or sets the target mesh
  35788. */
  35789. targetMesh: AbstractMesh;
  35790. /** Gets or sets the mesh used as pole */
  35791. poleTargetMesh: AbstractMesh;
  35792. /**
  35793. * Gets or sets the bone used as pole
  35794. */
  35795. poleTargetBone: Nullable<Bone>;
  35796. /**
  35797. * Gets or sets the target position
  35798. */
  35799. targetPosition: Vector3;
  35800. /**
  35801. * Gets or sets the pole target position
  35802. */
  35803. poleTargetPosition: Vector3;
  35804. /**
  35805. * Gets or sets the pole target local offset
  35806. */
  35807. poleTargetLocalOffset: Vector3;
  35808. /**
  35809. * Gets or sets the pole angle
  35810. */
  35811. poleAngle: number;
  35812. /**
  35813. * Gets or sets the mesh associated with the controller
  35814. */
  35815. mesh: AbstractMesh;
  35816. /**
  35817. * 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)
  35818. */
  35819. slerpAmount: number;
  35820. private _bone1Quat;
  35821. private _bone1Mat;
  35822. private _bone2Ang;
  35823. private _bone1;
  35824. private _bone2;
  35825. private _bone1Length;
  35826. private _bone2Length;
  35827. private _maxAngle;
  35828. private _maxReach;
  35829. private _rightHandedSystem;
  35830. private _bendAxis;
  35831. private _slerping;
  35832. private _adjustRoll;
  35833. /**
  35834. * Gets or sets maximum allowed angle
  35835. */
  35836. maxAngle: number;
  35837. /**
  35838. * Creates a new BoneIKController
  35839. * @param mesh defines the mesh to control
  35840. * @param bone defines the bone to control
  35841. * @param options defines options to set up the controller
  35842. */
  35843. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35844. targetMesh?: AbstractMesh;
  35845. poleTargetMesh?: AbstractMesh;
  35846. poleTargetBone?: Bone;
  35847. poleTargetLocalOffset?: Vector3;
  35848. poleAngle?: number;
  35849. bendAxis?: Vector3;
  35850. maxAngle?: number;
  35851. slerpAmount?: number;
  35852. });
  35853. private _setMaxAngle;
  35854. /**
  35855. * Force the controller to update the bones
  35856. */
  35857. update(): void;
  35858. }
  35859. }
  35860. declare module BABYLON {
  35861. /**
  35862. * Class used to make a bone look toward a point in space
  35863. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35864. */
  35865. export class BoneLookController {
  35866. private static _tmpVecs;
  35867. private static _tmpQuat;
  35868. private static _tmpMats;
  35869. /**
  35870. * The target Vector3 that the bone will look at
  35871. */
  35872. target: Vector3;
  35873. /**
  35874. * The mesh that the bone is attached to
  35875. */
  35876. mesh: AbstractMesh;
  35877. /**
  35878. * The bone that will be looking to the target
  35879. */
  35880. bone: Bone;
  35881. /**
  35882. * The up axis of the coordinate system that is used when the bone is rotated
  35883. */
  35884. upAxis: Vector3;
  35885. /**
  35886. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35887. */
  35888. upAxisSpace: Space;
  35889. /**
  35890. * Used to make an adjustment to the yaw of the bone
  35891. */
  35892. adjustYaw: number;
  35893. /**
  35894. * Used to make an adjustment to the pitch of the bone
  35895. */
  35896. adjustPitch: number;
  35897. /**
  35898. * Used to make an adjustment to the roll of the bone
  35899. */
  35900. adjustRoll: number;
  35901. /**
  35902. * 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)
  35903. */
  35904. slerpAmount: number;
  35905. private _minYaw;
  35906. private _maxYaw;
  35907. private _minPitch;
  35908. private _maxPitch;
  35909. private _minYawSin;
  35910. private _minYawCos;
  35911. private _maxYawSin;
  35912. private _maxYawCos;
  35913. private _midYawConstraint;
  35914. private _minPitchTan;
  35915. private _maxPitchTan;
  35916. private _boneQuat;
  35917. private _slerping;
  35918. private _transformYawPitch;
  35919. private _transformYawPitchInv;
  35920. private _firstFrameSkipped;
  35921. private _yawRange;
  35922. private _fowardAxis;
  35923. /**
  35924. * Gets or sets the minimum yaw angle that the bone can look to
  35925. */
  35926. minYaw: number;
  35927. /**
  35928. * Gets or sets the maximum yaw angle that the bone can look to
  35929. */
  35930. maxYaw: number;
  35931. /**
  35932. * Gets or sets the minimum pitch angle that the bone can look to
  35933. */
  35934. minPitch: number;
  35935. /**
  35936. * Gets or sets the maximum pitch angle that the bone can look to
  35937. */
  35938. maxPitch: number;
  35939. /**
  35940. * Create a BoneLookController
  35941. * @param mesh the mesh that the bone belongs to
  35942. * @param bone the bone that will be looking to the target
  35943. * @param target the target Vector3 to look at
  35944. * @param options optional settings:
  35945. * * maxYaw: the maximum angle the bone will yaw to
  35946. * * minYaw: the minimum angle the bone will yaw to
  35947. * * maxPitch: the maximum angle the bone will pitch to
  35948. * * minPitch: the minimum angle the bone will yaw to
  35949. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35950. * * upAxis: the up axis of the coordinate system
  35951. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35952. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35953. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35954. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35955. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35956. * * adjustRoll: used to make an adjustment to the roll of the bone
  35957. **/
  35958. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35959. maxYaw?: number;
  35960. minYaw?: number;
  35961. maxPitch?: number;
  35962. minPitch?: number;
  35963. slerpAmount?: number;
  35964. upAxis?: Vector3;
  35965. upAxisSpace?: Space;
  35966. yawAxis?: Vector3;
  35967. pitchAxis?: Vector3;
  35968. adjustYaw?: number;
  35969. adjustPitch?: number;
  35970. adjustRoll?: number;
  35971. });
  35972. /**
  35973. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35974. */
  35975. update(): void;
  35976. private _getAngleDiff;
  35977. private _getAngleBetween;
  35978. private _isAngleBetween;
  35979. }
  35980. }
  35981. declare module BABYLON {
  35982. /**
  35983. * Manage the gamepad inputs to control an arc rotate camera.
  35984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35985. */
  35986. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35987. /**
  35988. * Defines the camera the input is attached to.
  35989. */
  35990. camera: ArcRotateCamera;
  35991. /**
  35992. * Defines the gamepad the input is gathering event from.
  35993. */
  35994. gamepad: Nullable<Gamepad>;
  35995. /**
  35996. * Defines the gamepad rotation sensiblity.
  35997. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35998. */
  35999. gamepadRotationSensibility: number;
  36000. /**
  36001. * Defines the gamepad move sensiblity.
  36002. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36003. */
  36004. gamepadMoveSensibility: number;
  36005. private _onGamepadConnectedObserver;
  36006. private _onGamepadDisconnectedObserver;
  36007. /**
  36008. * Attach the input controls to a specific dom element to get the input from.
  36009. * @param element Defines the element the controls should be listened from
  36010. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36011. */
  36012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36013. /**
  36014. * Detach the current controls from the specified dom element.
  36015. * @param element Defines the element to stop listening the inputs from
  36016. */
  36017. detachControl(element: Nullable<HTMLElement>): void;
  36018. /**
  36019. * Update the current camera state depending on the inputs that have been used this frame.
  36020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36021. */
  36022. checkInputs(): void;
  36023. /**
  36024. * Gets the class name of the current intput.
  36025. * @returns the class name
  36026. */
  36027. getClassName(): string;
  36028. /**
  36029. * Get the friendly name associated with the input class.
  36030. * @returns the input friendly name
  36031. */
  36032. getSimpleName(): string;
  36033. }
  36034. }
  36035. declare module BABYLON {
  36036. interface ArcRotateCameraInputsManager {
  36037. /**
  36038. * Add orientation input support to the input manager.
  36039. * @returns the current input manager
  36040. */
  36041. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36042. }
  36043. /**
  36044. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36046. */
  36047. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36048. /**
  36049. * Defines the camera the input is attached to.
  36050. */
  36051. camera: ArcRotateCamera;
  36052. /**
  36053. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36054. */
  36055. alphaCorrection: number;
  36056. /**
  36057. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36058. */
  36059. gammaCorrection: number;
  36060. private _alpha;
  36061. private _gamma;
  36062. private _dirty;
  36063. private _deviceOrientationHandler;
  36064. /**
  36065. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36066. */
  36067. constructor();
  36068. /**
  36069. * Attach the input controls to a specific dom element to get the input from.
  36070. * @param element Defines the element the controls should be listened from
  36071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36072. */
  36073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36074. /** @hidden */
  36075. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36076. /**
  36077. * Update the current camera state depending on the inputs that have been used this frame.
  36078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36079. */
  36080. checkInputs(): void;
  36081. /**
  36082. * Detach the current controls from the specified dom element.
  36083. * @param element Defines the element to stop listening the inputs from
  36084. */
  36085. detachControl(element: Nullable<HTMLElement>): void;
  36086. /**
  36087. * Gets the class name of the current intput.
  36088. * @returns the class name
  36089. */
  36090. getClassName(): string;
  36091. /**
  36092. * Get the friendly name associated with the input class.
  36093. * @returns the input friendly name
  36094. */
  36095. getSimpleName(): string;
  36096. }
  36097. }
  36098. declare module BABYLON {
  36099. /**
  36100. * Listen to mouse events to control the camera.
  36101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36102. */
  36103. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36104. /**
  36105. * Defines the camera the input is attached to.
  36106. */
  36107. camera: FlyCamera;
  36108. /**
  36109. * Defines if touch is enabled. (Default is true.)
  36110. */
  36111. touchEnabled: boolean;
  36112. /**
  36113. * Defines the buttons associated with the input to handle camera rotation.
  36114. */
  36115. buttons: number[];
  36116. /**
  36117. * Assign buttons for Yaw control.
  36118. */
  36119. buttonsYaw: number[];
  36120. /**
  36121. * Assign buttons for Pitch control.
  36122. */
  36123. buttonsPitch: number[];
  36124. /**
  36125. * Assign buttons for Roll control.
  36126. */
  36127. buttonsRoll: number[];
  36128. /**
  36129. * Detect if any button is being pressed while mouse is moved.
  36130. * -1 = Mouse locked.
  36131. * 0 = Left button.
  36132. * 1 = Middle Button.
  36133. * 2 = Right Button.
  36134. */
  36135. activeButton: number;
  36136. /**
  36137. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36138. * Higher values reduce its sensitivity.
  36139. */
  36140. angularSensibility: number;
  36141. private _mousemoveCallback;
  36142. private _observer;
  36143. private _rollObserver;
  36144. private previousPosition;
  36145. private noPreventDefault;
  36146. private element;
  36147. /**
  36148. * Listen to mouse events to control the camera.
  36149. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36151. */
  36152. constructor(touchEnabled?: boolean);
  36153. /**
  36154. * Attach the mouse control to the HTML DOM element.
  36155. * @param element Defines the element that listens to the input events.
  36156. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36157. */
  36158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36159. /**
  36160. * Detach the current controls from the specified dom element.
  36161. * @param element Defines the element to stop listening the inputs from
  36162. */
  36163. detachControl(element: Nullable<HTMLElement>): void;
  36164. /**
  36165. * Gets the class name of the current input.
  36166. * @returns the class name.
  36167. */
  36168. getClassName(): string;
  36169. /**
  36170. * Get the friendly name associated with the input class.
  36171. * @returns the input's friendly name.
  36172. */
  36173. getSimpleName(): string;
  36174. private _pointerInput;
  36175. private _onMouseMove;
  36176. /**
  36177. * Rotate camera by mouse offset.
  36178. */
  36179. private rotateCamera;
  36180. }
  36181. }
  36182. declare module BABYLON {
  36183. /**
  36184. * Default Inputs manager for the FlyCamera.
  36185. * It groups all the default supported inputs for ease of use.
  36186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36187. */
  36188. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36189. /**
  36190. * Instantiates a new FlyCameraInputsManager.
  36191. * @param camera Defines the camera the inputs belong to.
  36192. */
  36193. constructor(camera: FlyCamera);
  36194. /**
  36195. * Add keyboard input support to the input manager.
  36196. * @returns the new FlyCameraKeyboardMoveInput().
  36197. */
  36198. addKeyboard(): FlyCameraInputsManager;
  36199. /**
  36200. * Add mouse input support to the input manager.
  36201. * @param touchEnabled Enable touch screen support.
  36202. * @returns the new FlyCameraMouseInput().
  36203. */
  36204. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36205. }
  36206. }
  36207. declare module BABYLON {
  36208. /**
  36209. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36210. * such as in a 3D Space Shooter or a Flight Simulator.
  36211. */
  36212. export class FlyCamera extends TargetCamera {
  36213. /**
  36214. * Define the collision ellipsoid of the camera.
  36215. * This is helpful for simulating a camera body, like a player's body.
  36216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36217. */
  36218. ellipsoid: Vector3;
  36219. /**
  36220. * Define an offset for the position of the ellipsoid around the camera.
  36221. * This can be helpful if the camera is attached away from the player's body center,
  36222. * such as at its head.
  36223. */
  36224. ellipsoidOffset: Vector3;
  36225. /**
  36226. * Enable or disable collisions of the camera with the rest of the scene objects.
  36227. */
  36228. checkCollisions: boolean;
  36229. /**
  36230. * Enable or disable gravity on the camera.
  36231. */
  36232. applyGravity: boolean;
  36233. /**
  36234. * Define the current direction the camera is moving to.
  36235. */
  36236. cameraDirection: Vector3;
  36237. /**
  36238. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36239. * This overrides and empties cameraRotation.
  36240. */
  36241. rotationQuaternion: Quaternion;
  36242. /**
  36243. * Track Roll to maintain the wanted Rolling when looking around.
  36244. */
  36245. _trackRoll: number;
  36246. /**
  36247. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36248. */
  36249. rollCorrect: number;
  36250. /**
  36251. * Mimic a banked turn, Rolling the camera when Yawing.
  36252. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36253. */
  36254. bankedTurn: boolean;
  36255. /**
  36256. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36257. */
  36258. bankedTurnLimit: number;
  36259. /**
  36260. * Value of 0 disables the banked Roll.
  36261. * Value of 1 is equal to the Yaw angle in radians.
  36262. */
  36263. bankedTurnMultiplier: number;
  36264. /**
  36265. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36266. */
  36267. inputs: FlyCameraInputsManager;
  36268. /**
  36269. * Gets the input sensibility for mouse input.
  36270. * Higher values reduce sensitivity.
  36271. */
  36272. /**
  36273. * Sets the input sensibility for a mouse input.
  36274. * Higher values reduce sensitivity.
  36275. */
  36276. angularSensibility: number;
  36277. /**
  36278. * Get the keys for camera movement forward.
  36279. */
  36280. /**
  36281. * Set the keys for camera movement forward.
  36282. */
  36283. keysForward: number[];
  36284. /**
  36285. * Get the keys for camera movement backward.
  36286. */
  36287. keysBackward: number[];
  36288. /**
  36289. * Get the keys for camera movement up.
  36290. */
  36291. /**
  36292. * Set the keys for camera movement up.
  36293. */
  36294. keysUp: number[];
  36295. /**
  36296. * Get the keys for camera movement down.
  36297. */
  36298. /**
  36299. * Set the keys for camera movement down.
  36300. */
  36301. keysDown: number[];
  36302. /**
  36303. * Get the keys for camera movement left.
  36304. */
  36305. /**
  36306. * Set the keys for camera movement left.
  36307. */
  36308. keysLeft: number[];
  36309. /**
  36310. * Set the keys for camera movement right.
  36311. */
  36312. /**
  36313. * Set the keys for camera movement right.
  36314. */
  36315. keysRight: number[];
  36316. /**
  36317. * Event raised when the camera collides with a mesh in the scene.
  36318. */
  36319. onCollide: (collidedMesh: AbstractMesh) => void;
  36320. private _collider;
  36321. private _needMoveForGravity;
  36322. private _oldPosition;
  36323. private _diffPosition;
  36324. private _newPosition;
  36325. /** @hidden */
  36326. _localDirection: Vector3;
  36327. /** @hidden */
  36328. _transformedDirection: Vector3;
  36329. /**
  36330. * Instantiates a FlyCamera.
  36331. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36332. * such as in a 3D Space Shooter or a Flight Simulator.
  36333. * @param name Define the name of the camera in the scene.
  36334. * @param position Define the starting position of the camera in the scene.
  36335. * @param scene Define the scene the camera belongs to.
  36336. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36337. */
  36338. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36339. /**
  36340. * Attach a control to the HTML DOM element.
  36341. * @param element Defines the element that listens to the input events.
  36342. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36343. */
  36344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36345. /**
  36346. * Detach a control from the HTML DOM element.
  36347. * The camera will stop reacting to that input.
  36348. * @param element Defines the element that listens to the input events.
  36349. */
  36350. detachControl(element: HTMLElement): void;
  36351. private _collisionMask;
  36352. /**
  36353. * Get the mask that the camera ignores in collision events.
  36354. */
  36355. /**
  36356. * Set the mask that the camera ignores in collision events.
  36357. */
  36358. collisionMask: number;
  36359. /** @hidden */
  36360. _collideWithWorld(displacement: Vector3): void;
  36361. /** @hidden */
  36362. private _onCollisionPositionChange;
  36363. /** @hidden */
  36364. _checkInputs(): void;
  36365. /** @hidden */
  36366. _decideIfNeedsToMove(): boolean;
  36367. /** @hidden */
  36368. _updatePosition(): void;
  36369. /**
  36370. * Restore the Roll to its target value at the rate specified.
  36371. * @param rate - Higher means slower restoring.
  36372. * @hidden
  36373. */
  36374. restoreRoll(rate: number): void;
  36375. /**
  36376. * Destroy the camera and release the current resources held by it.
  36377. */
  36378. dispose(): void;
  36379. /**
  36380. * Get the current object class name.
  36381. * @returns the class name.
  36382. */
  36383. getClassName(): string;
  36384. }
  36385. }
  36386. declare module BABYLON {
  36387. /**
  36388. * Listen to keyboard events to control the camera.
  36389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36390. */
  36391. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36392. /**
  36393. * Defines the camera the input is attached to.
  36394. */
  36395. camera: FlyCamera;
  36396. /**
  36397. * The list of keyboard keys used to control the forward move of the camera.
  36398. */
  36399. keysForward: number[];
  36400. /**
  36401. * The list of keyboard keys used to control the backward move of the camera.
  36402. */
  36403. keysBackward: number[];
  36404. /**
  36405. * The list of keyboard keys used to control the forward move of the camera.
  36406. */
  36407. keysUp: number[];
  36408. /**
  36409. * The list of keyboard keys used to control the backward move of the camera.
  36410. */
  36411. keysDown: number[];
  36412. /**
  36413. * The list of keyboard keys used to control the right strafe move of the camera.
  36414. */
  36415. keysRight: number[];
  36416. /**
  36417. * The list of keyboard keys used to control the left strafe move of the camera.
  36418. */
  36419. keysLeft: number[];
  36420. private _keys;
  36421. private _onCanvasBlurObserver;
  36422. private _onKeyboardObserver;
  36423. private _engine;
  36424. private _scene;
  36425. /**
  36426. * Attach the input controls to a specific dom element to get the input from.
  36427. * @param element Defines the element the controls should be listened from
  36428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36429. */
  36430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36431. /**
  36432. * Detach the current controls from the specified dom element.
  36433. * @param element Defines the element to stop listening the inputs from
  36434. */
  36435. detachControl(element: Nullable<HTMLElement>): void;
  36436. /**
  36437. * Gets the class name of the current intput.
  36438. * @returns the class name
  36439. */
  36440. getClassName(): string;
  36441. /** @hidden */
  36442. _onLostFocus(e: FocusEvent): void;
  36443. /**
  36444. * Get the friendly name associated with the input class.
  36445. * @returns the input friendly name
  36446. */
  36447. getSimpleName(): string;
  36448. /**
  36449. * Update the current camera state depending on the inputs that have been used this frame.
  36450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36451. */
  36452. checkInputs(): void;
  36453. }
  36454. }
  36455. declare module BABYLON {
  36456. /**
  36457. * Manage the mouse wheel inputs to control a follow camera.
  36458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36459. */
  36460. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36461. /**
  36462. * Defines the camera the input is attached to.
  36463. */
  36464. camera: FollowCamera;
  36465. /**
  36466. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36467. */
  36468. axisControlRadius: boolean;
  36469. /**
  36470. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36471. */
  36472. axisControlHeight: boolean;
  36473. /**
  36474. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36475. */
  36476. axisControlRotation: boolean;
  36477. /**
  36478. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36479. * relation to mouseWheel events.
  36480. */
  36481. wheelPrecision: number;
  36482. /**
  36483. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36484. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36485. */
  36486. wheelDeltaPercentage: number;
  36487. private _wheel;
  36488. private _observer;
  36489. /**
  36490. * Attach the input controls to a specific dom element to get the input from.
  36491. * @param element Defines the element the controls should be listened from
  36492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36493. */
  36494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36495. /**
  36496. * Detach the current controls from the specified dom element.
  36497. * @param element Defines the element to stop listening the inputs from
  36498. */
  36499. detachControl(element: Nullable<HTMLElement>): void;
  36500. /**
  36501. * Gets the class name of the current intput.
  36502. * @returns the class name
  36503. */
  36504. getClassName(): string;
  36505. /**
  36506. * Get the friendly name associated with the input class.
  36507. * @returns the input friendly name
  36508. */
  36509. getSimpleName(): string;
  36510. }
  36511. }
  36512. declare module BABYLON {
  36513. /**
  36514. * Manage the pointers inputs to control an follow camera.
  36515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36516. */
  36517. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36518. /**
  36519. * Defines the camera the input is attached to.
  36520. */
  36521. camera: FollowCamera;
  36522. /**
  36523. * Gets the class name of the current input.
  36524. * @returns the class name
  36525. */
  36526. getClassName(): string;
  36527. /**
  36528. * Defines the pointer angular sensibility along the X axis or how fast is
  36529. * the camera rotating.
  36530. * A negative number will reverse the axis direction.
  36531. */
  36532. angularSensibilityX: number;
  36533. /**
  36534. * Defines the pointer angular sensibility along the Y axis or how fast is
  36535. * the camera rotating.
  36536. * A negative number will reverse the axis direction.
  36537. */
  36538. angularSensibilityY: number;
  36539. /**
  36540. * Defines the pointer pinch precision or how fast is the camera zooming.
  36541. * A negative number will reverse the axis direction.
  36542. */
  36543. pinchPrecision: number;
  36544. /**
  36545. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36546. * from 0.
  36547. * It defines the percentage of current camera.radius to use as delta when
  36548. * pinch zoom is used.
  36549. */
  36550. pinchDeltaPercentage: number;
  36551. /**
  36552. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36553. */
  36554. axisXControlRadius: boolean;
  36555. /**
  36556. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36557. */
  36558. axisXControlHeight: boolean;
  36559. /**
  36560. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36561. */
  36562. axisXControlRotation: boolean;
  36563. /**
  36564. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36565. */
  36566. axisYControlRadius: boolean;
  36567. /**
  36568. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36569. */
  36570. axisYControlHeight: boolean;
  36571. /**
  36572. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36573. */
  36574. axisYControlRotation: boolean;
  36575. /**
  36576. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36577. */
  36578. axisPinchControlRadius: boolean;
  36579. /**
  36580. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36581. */
  36582. axisPinchControlHeight: boolean;
  36583. /**
  36584. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36585. */
  36586. axisPinchControlRotation: boolean;
  36587. /**
  36588. * Log error messages if basic misconfiguration has occurred.
  36589. */
  36590. warningEnable: boolean;
  36591. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36592. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36593. private _warningCounter;
  36594. private _warning;
  36595. }
  36596. }
  36597. declare module BABYLON {
  36598. /**
  36599. * Default Inputs manager for the FollowCamera.
  36600. * It groups all the default supported inputs for ease of use.
  36601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36602. */
  36603. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36604. /**
  36605. * Instantiates a new FollowCameraInputsManager.
  36606. * @param camera Defines the camera the inputs belong to
  36607. */
  36608. constructor(camera: FollowCamera);
  36609. /**
  36610. * Add keyboard input support to the input manager.
  36611. * @returns the current input manager
  36612. */
  36613. addKeyboard(): FollowCameraInputsManager;
  36614. /**
  36615. * Add mouse wheel input support to the input manager.
  36616. * @returns the current input manager
  36617. */
  36618. addMouseWheel(): FollowCameraInputsManager;
  36619. /**
  36620. * Add pointers input support to the input manager.
  36621. * @returns the current input manager
  36622. */
  36623. addPointers(): FollowCameraInputsManager;
  36624. /**
  36625. * Add orientation input support to the input manager.
  36626. * @returns the current input manager
  36627. */
  36628. addVRDeviceOrientation(): FollowCameraInputsManager;
  36629. }
  36630. }
  36631. declare module BABYLON {
  36632. /**
  36633. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36634. * an arc rotate version arcFollowCamera are available.
  36635. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36636. */
  36637. export class FollowCamera extends TargetCamera {
  36638. /**
  36639. * Distance the follow camera should follow an object at
  36640. */
  36641. radius: number;
  36642. /**
  36643. * Minimum allowed distance of the camera to the axis of rotation
  36644. * (The camera can not get closer).
  36645. * This can help limiting how the Camera is able to move in the scene.
  36646. */
  36647. lowerRadiusLimit: Nullable<number>;
  36648. /**
  36649. * Maximum allowed distance of the camera to the axis of rotation
  36650. * (The camera can not get further).
  36651. * This can help limiting how the Camera is able to move in the scene.
  36652. */
  36653. upperRadiusLimit: Nullable<number>;
  36654. /**
  36655. * Define a rotation offset between the camera and the object it follows
  36656. */
  36657. rotationOffset: number;
  36658. /**
  36659. * Minimum allowed angle to camera position relative to target object.
  36660. * This can help limiting how the Camera is able to move in the scene.
  36661. */
  36662. lowerRotationOffsetLimit: Nullable<number>;
  36663. /**
  36664. * Maximum allowed angle to camera position relative to target object.
  36665. * This can help limiting how the Camera is able to move in the scene.
  36666. */
  36667. upperRotationOffsetLimit: Nullable<number>;
  36668. /**
  36669. * Define a height offset between the camera and the object it follows.
  36670. * It can help following an object from the top (like a car chaing a plane)
  36671. */
  36672. heightOffset: number;
  36673. /**
  36674. * Minimum allowed height of camera position relative to target object.
  36675. * This can help limiting how the Camera is able to move in the scene.
  36676. */
  36677. lowerHeightOffsetLimit: Nullable<number>;
  36678. /**
  36679. * Maximum allowed height of camera position relative to target object.
  36680. * This can help limiting how the Camera is able to move in the scene.
  36681. */
  36682. upperHeightOffsetLimit: Nullable<number>;
  36683. /**
  36684. * Define how fast the camera can accelerate to follow it s target.
  36685. */
  36686. cameraAcceleration: number;
  36687. /**
  36688. * Define the speed limit of the camera following an object.
  36689. */
  36690. maxCameraSpeed: number;
  36691. /**
  36692. * Define the target of the camera.
  36693. */
  36694. lockedTarget: Nullable<AbstractMesh>;
  36695. /**
  36696. * Defines the input associated with the camera.
  36697. */
  36698. inputs: FollowCameraInputsManager;
  36699. /**
  36700. * Instantiates the follow camera.
  36701. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36702. * @param name Define the name of the camera in the scene
  36703. * @param position Define the position of the camera
  36704. * @param scene Define the scene the camera belong to
  36705. * @param lockedTarget Define the target of the camera
  36706. */
  36707. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36708. private _follow;
  36709. /**
  36710. * Attached controls to the current camera.
  36711. * @param element Defines the element the controls should be listened from
  36712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36713. */
  36714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36715. /**
  36716. * Detach the current controls from the camera.
  36717. * The camera will stop reacting to inputs.
  36718. * @param element Defines the element to stop listening the inputs from
  36719. */
  36720. detachControl(element: HTMLElement): void;
  36721. /** @hidden */
  36722. _checkInputs(): void;
  36723. private _checkLimits;
  36724. /**
  36725. * Gets the camera class name.
  36726. * @returns the class name
  36727. */
  36728. getClassName(): string;
  36729. }
  36730. /**
  36731. * Arc Rotate version of the follow camera.
  36732. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36733. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36734. */
  36735. export class ArcFollowCamera extends TargetCamera {
  36736. /** The longitudinal angle of the camera */
  36737. alpha: number;
  36738. /** The latitudinal angle of the camera */
  36739. beta: number;
  36740. /** The radius of the camera from its target */
  36741. radius: number;
  36742. /** Define the camera target (the messh it should follow) */
  36743. target: Nullable<AbstractMesh>;
  36744. private _cartesianCoordinates;
  36745. /**
  36746. * Instantiates a new ArcFollowCamera
  36747. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36748. * @param name Define the name of the camera
  36749. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36750. * @param beta Define the rotation angle of the camera around the elevation axis
  36751. * @param radius Define the radius of the camera from its target point
  36752. * @param target Define the target of the camera
  36753. * @param scene Define the scene the camera belongs to
  36754. */
  36755. constructor(name: string,
  36756. /** The longitudinal angle of the camera */
  36757. alpha: number,
  36758. /** The latitudinal angle of the camera */
  36759. beta: number,
  36760. /** The radius of the camera from its target */
  36761. radius: number,
  36762. /** Define the camera target (the messh it should follow) */
  36763. target: Nullable<AbstractMesh>, scene: Scene);
  36764. private _follow;
  36765. /** @hidden */
  36766. _checkInputs(): void;
  36767. /**
  36768. * Returns the class name of the object.
  36769. * It is mostly used internally for serialization purposes.
  36770. */
  36771. getClassName(): string;
  36772. }
  36773. }
  36774. declare module BABYLON {
  36775. /**
  36776. * Manage the keyboard inputs to control the movement of a follow camera.
  36777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36778. */
  36779. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36780. /**
  36781. * Defines the camera the input is attached to.
  36782. */
  36783. camera: FollowCamera;
  36784. /**
  36785. * Defines the list of key codes associated with the up action (increase heightOffset)
  36786. */
  36787. keysHeightOffsetIncr: number[];
  36788. /**
  36789. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36790. */
  36791. keysHeightOffsetDecr: number[];
  36792. /**
  36793. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36794. */
  36795. keysHeightOffsetModifierAlt: boolean;
  36796. /**
  36797. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36798. */
  36799. keysHeightOffsetModifierCtrl: boolean;
  36800. /**
  36801. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36802. */
  36803. keysHeightOffsetModifierShift: boolean;
  36804. /**
  36805. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36806. */
  36807. keysRotationOffsetIncr: number[];
  36808. /**
  36809. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36810. */
  36811. keysRotationOffsetDecr: number[];
  36812. /**
  36813. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36814. */
  36815. keysRotationOffsetModifierAlt: boolean;
  36816. /**
  36817. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36818. */
  36819. keysRotationOffsetModifierCtrl: boolean;
  36820. /**
  36821. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36822. */
  36823. keysRotationOffsetModifierShift: boolean;
  36824. /**
  36825. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36826. */
  36827. keysRadiusIncr: number[];
  36828. /**
  36829. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36830. */
  36831. keysRadiusDecr: number[];
  36832. /**
  36833. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36834. */
  36835. keysRadiusModifierAlt: boolean;
  36836. /**
  36837. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36838. */
  36839. keysRadiusModifierCtrl: boolean;
  36840. /**
  36841. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36842. */
  36843. keysRadiusModifierShift: boolean;
  36844. /**
  36845. * Defines the rate of change of heightOffset.
  36846. */
  36847. heightSensibility: number;
  36848. /**
  36849. * Defines the rate of change of rotationOffset.
  36850. */
  36851. rotationSensibility: number;
  36852. /**
  36853. * Defines the rate of change of radius.
  36854. */
  36855. radiusSensibility: number;
  36856. private _keys;
  36857. private _ctrlPressed;
  36858. private _altPressed;
  36859. private _shiftPressed;
  36860. private _onCanvasBlurObserver;
  36861. private _onKeyboardObserver;
  36862. private _engine;
  36863. private _scene;
  36864. /**
  36865. * Attach the input controls to a specific dom element to get the input from.
  36866. * @param element Defines the element the controls should be listened from
  36867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36868. */
  36869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36870. /**
  36871. * Detach the current controls from the specified dom element.
  36872. * @param element Defines the element to stop listening the inputs from
  36873. */
  36874. detachControl(element: Nullable<HTMLElement>): void;
  36875. /**
  36876. * Update the current camera state depending on the inputs that have been used this frame.
  36877. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36878. */
  36879. checkInputs(): void;
  36880. /**
  36881. * Gets the class name of the current input.
  36882. * @returns the class name
  36883. */
  36884. getClassName(): string;
  36885. /**
  36886. * Get the friendly name associated with the input class.
  36887. * @returns the input friendly name
  36888. */
  36889. getSimpleName(): string;
  36890. /**
  36891. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36892. * allow modification of the heightOffset value.
  36893. */
  36894. private _modifierHeightOffset;
  36895. /**
  36896. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36897. * allow modification of the rotationOffset value.
  36898. */
  36899. private _modifierRotationOffset;
  36900. /**
  36901. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36902. * allow modification of the radius value.
  36903. */
  36904. private _modifierRadius;
  36905. }
  36906. }
  36907. declare module BABYLON {
  36908. interface FreeCameraInputsManager {
  36909. /**
  36910. * @hidden
  36911. */
  36912. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36913. /**
  36914. * Add orientation input support to the input manager.
  36915. * @returns the current input manager
  36916. */
  36917. addDeviceOrientation(): FreeCameraInputsManager;
  36918. }
  36919. /**
  36920. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36921. * Screen rotation is taken into account.
  36922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36923. */
  36924. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36925. private _camera;
  36926. private _screenOrientationAngle;
  36927. private _constantTranform;
  36928. private _screenQuaternion;
  36929. private _alpha;
  36930. private _beta;
  36931. private _gamma;
  36932. /**
  36933. * @hidden
  36934. */
  36935. _onDeviceOrientationChangedObservable: Observable<void>;
  36936. /**
  36937. * Instantiates a new input
  36938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36939. */
  36940. constructor();
  36941. /**
  36942. * Define the camera controlled by the input.
  36943. */
  36944. camera: FreeCamera;
  36945. /**
  36946. * Attach the input controls to a specific dom element to get the input from.
  36947. * @param element Defines the element the controls should be listened from
  36948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36949. */
  36950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36951. private _orientationChanged;
  36952. private _deviceOrientation;
  36953. /**
  36954. * Detach the current controls from the specified dom element.
  36955. * @param element Defines the element to stop listening the inputs from
  36956. */
  36957. detachControl(element: Nullable<HTMLElement>): void;
  36958. /**
  36959. * Update the current camera state depending on the inputs that have been used this frame.
  36960. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36961. */
  36962. checkInputs(): void;
  36963. /**
  36964. * Gets the class name of the current intput.
  36965. * @returns the class name
  36966. */
  36967. getClassName(): string;
  36968. /**
  36969. * Get the friendly name associated with the input class.
  36970. * @returns the input friendly name
  36971. */
  36972. getSimpleName(): string;
  36973. }
  36974. }
  36975. declare module BABYLON {
  36976. /**
  36977. * Manage the gamepad inputs to control a free camera.
  36978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36979. */
  36980. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36981. /**
  36982. * Define the camera the input is attached to.
  36983. */
  36984. camera: FreeCamera;
  36985. /**
  36986. * Define the Gamepad controlling the input
  36987. */
  36988. gamepad: Nullable<Gamepad>;
  36989. /**
  36990. * Defines the gamepad rotation sensiblity.
  36991. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36992. */
  36993. gamepadAngularSensibility: number;
  36994. /**
  36995. * Defines the gamepad move sensiblity.
  36996. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36997. */
  36998. gamepadMoveSensibility: number;
  36999. private _onGamepadConnectedObserver;
  37000. private _onGamepadDisconnectedObserver;
  37001. private _cameraTransform;
  37002. private _deltaTransform;
  37003. private _vector3;
  37004. private _vector2;
  37005. /**
  37006. * Attach the input controls to a specific dom element to get the input from.
  37007. * @param element Defines the element the controls should be listened from
  37008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37009. */
  37010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37011. /**
  37012. * Detach the current controls from the specified dom element.
  37013. * @param element Defines the element to stop listening the inputs from
  37014. */
  37015. detachControl(element: Nullable<HTMLElement>): void;
  37016. /**
  37017. * Update the current camera state depending on the inputs that have been used this frame.
  37018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37019. */
  37020. checkInputs(): void;
  37021. /**
  37022. * Gets the class name of the current intput.
  37023. * @returns the class name
  37024. */
  37025. getClassName(): string;
  37026. /**
  37027. * Get the friendly name associated with the input class.
  37028. * @returns the input friendly name
  37029. */
  37030. getSimpleName(): string;
  37031. }
  37032. }
  37033. declare module BABYLON {
  37034. /**
  37035. * Defines the potential axis of a Joystick
  37036. */
  37037. export enum JoystickAxis {
  37038. /** X axis */
  37039. X = 0,
  37040. /** Y axis */
  37041. Y = 1,
  37042. /** Z axis */
  37043. Z = 2
  37044. }
  37045. /**
  37046. * Class used to define virtual joystick (used in touch mode)
  37047. */
  37048. export class VirtualJoystick {
  37049. /**
  37050. * Gets or sets a boolean indicating that left and right values must be inverted
  37051. */
  37052. reverseLeftRight: boolean;
  37053. /**
  37054. * Gets or sets a boolean indicating that up and down values must be inverted
  37055. */
  37056. reverseUpDown: boolean;
  37057. /**
  37058. * Gets the offset value for the position (ie. the change of the position value)
  37059. */
  37060. deltaPosition: Vector3;
  37061. /**
  37062. * Gets a boolean indicating if the virtual joystick was pressed
  37063. */
  37064. pressed: boolean;
  37065. /**
  37066. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37067. */
  37068. static Canvas: Nullable<HTMLCanvasElement>;
  37069. private static _globalJoystickIndex;
  37070. private static vjCanvasContext;
  37071. private static vjCanvasWidth;
  37072. private static vjCanvasHeight;
  37073. private static halfWidth;
  37074. private _action;
  37075. private _axisTargetedByLeftAndRight;
  37076. private _axisTargetedByUpAndDown;
  37077. private _joystickSensibility;
  37078. private _inversedSensibility;
  37079. private _joystickPointerID;
  37080. private _joystickColor;
  37081. private _joystickPointerPos;
  37082. private _joystickPreviousPointerPos;
  37083. private _joystickPointerStartPos;
  37084. private _deltaJoystickVector;
  37085. private _leftJoystick;
  37086. private _touches;
  37087. private _onPointerDownHandlerRef;
  37088. private _onPointerMoveHandlerRef;
  37089. private _onPointerUpHandlerRef;
  37090. private _onResize;
  37091. /**
  37092. * Creates a new virtual joystick
  37093. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37094. */
  37095. constructor(leftJoystick?: boolean);
  37096. /**
  37097. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37098. * @param newJoystickSensibility defines the new sensibility
  37099. */
  37100. setJoystickSensibility(newJoystickSensibility: number): void;
  37101. private _onPointerDown;
  37102. private _onPointerMove;
  37103. private _onPointerUp;
  37104. /**
  37105. * Change the color of the virtual joystick
  37106. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37107. */
  37108. setJoystickColor(newColor: string): void;
  37109. /**
  37110. * Defines a callback to call when the joystick is touched
  37111. * @param action defines the callback
  37112. */
  37113. setActionOnTouch(action: () => any): void;
  37114. /**
  37115. * Defines which axis you'd like to control for left & right
  37116. * @param axis defines the axis to use
  37117. */
  37118. setAxisForLeftRight(axis: JoystickAxis): void;
  37119. /**
  37120. * Defines which axis you'd like to control for up & down
  37121. * @param axis defines the axis to use
  37122. */
  37123. setAxisForUpDown(axis: JoystickAxis): void;
  37124. private _drawVirtualJoystick;
  37125. /**
  37126. * Release internal HTML canvas
  37127. */
  37128. releaseCanvas(): void;
  37129. }
  37130. }
  37131. declare module BABYLON {
  37132. interface FreeCameraInputsManager {
  37133. /**
  37134. * Add virtual joystick input support to the input manager.
  37135. * @returns the current input manager
  37136. */
  37137. addVirtualJoystick(): FreeCameraInputsManager;
  37138. }
  37139. /**
  37140. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37142. */
  37143. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37144. /**
  37145. * Defines the camera the input is attached to.
  37146. */
  37147. camera: FreeCamera;
  37148. private _leftjoystick;
  37149. private _rightjoystick;
  37150. /**
  37151. * Gets the left stick of the virtual joystick.
  37152. * @returns The virtual Joystick
  37153. */
  37154. getLeftJoystick(): VirtualJoystick;
  37155. /**
  37156. * Gets the right stick of the virtual joystick.
  37157. * @returns The virtual Joystick
  37158. */
  37159. getRightJoystick(): VirtualJoystick;
  37160. /**
  37161. * Update the current camera state depending on the inputs that have been used this frame.
  37162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37163. */
  37164. checkInputs(): void;
  37165. /**
  37166. * Attach the input controls to a specific dom element to get the input from.
  37167. * @param element Defines the element the controls should be listened from
  37168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37169. */
  37170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37171. /**
  37172. * Detach the current controls from the specified dom element.
  37173. * @param element Defines the element to stop listening the inputs from
  37174. */
  37175. detachControl(element: Nullable<HTMLElement>): void;
  37176. /**
  37177. * Gets the class name of the current intput.
  37178. * @returns the class name
  37179. */
  37180. getClassName(): string;
  37181. /**
  37182. * Get the friendly name associated with the input class.
  37183. * @returns the input friendly name
  37184. */
  37185. getSimpleName(): string;
  37186. }
  37187. }
  37188. declare module BABYLON {
  37189. /**
  37190. * This represents a FPS type of camera controlled by touch.
  37191. * This is like a universal camera minus the Gamepad controls.
  37192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37193. */
  37194. export class TouchCamera extends FreeCamera {
  37195. /**
  37196. * Defines the touch sensibility for rotation.
  37197. * The higher the faster.
  37198. */
  37199. touchAngularSensibility: number;
  37200. /**
  37201. * Defines the touch sensibility for move.
  37202. * The higher the faster.
  37203. */
  37204. touchMoveSensibility: number;
  37205. /**
  37206. * Instantiates a new touch camera.
  37207. * This represents a FPS type of camera controlled by touch.
  37208. * This is like a universal camera minus the Gamepad controls.
  37209. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37210. * @param name Define the name of the camera in the scene
  37211. * @param position Define the start position of the camera in the scene
  37212. * @param scene Define the scene the camera belongs to
  37213. */
  37214. constructor(name: string, position: Vector3, scene: Scene);
  37215. /**
  37216. * Gets the current object class name.
  37217. * @return the class name
  37218. */
  37219. getClassName(): string;
  37220. /** @hidden */
  37221. _setupInputs(): void;
  37222. }
  37223. }
  37224. declare module BABYLON {
  37225. /**
  37226. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37227. * being tilted forward or back and left or right.
  37228. */
  37229. export class DeviceOrientationCamera extends FreeCamera {
  37230. private _initialQuaternion;
  37231. private _quaternionCache;
  37232. private _tmpDragQuaternion;
  37233. /**
  37234. * Creates a new device orientation camera
  37235. * @param name The name of the camera
  37236. * @param position The start position camera
  37237. * @param scene The scene the camera belongs to
  37238. */
  37239. constructor(name: string, position: Vector3, scene: Scene);
  37240. /**
  37241. * Disabled pointer input on first orientation sensor update (Default: true)
  37242. */
  37243. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37244. private _dragFactor;
  37245. /**
  37246. * Enabled turning on the y axis when the orientation sensor is active
  37247. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37248. */
  37249. enableHorizontalDragging(dragFactor?: number): void;
  37250. /**
  37251. * Gets the current instance class name ("DeviceOrientationCamera").
  37252. * This helps avoiding instanceof at run time.
  37253. * @returns the class name
  37254. */
  37255. getClassName(): string;
  37256. /**
  37257. * @hidden
  37258. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37259. */
  37260. _checkInputs(): void;
  37261. /**
  37262. * Reset the camera to its default orientation on the specified axis only.
  37263. * @param axis The axis to reset
  37264. */
  37265. resetToCurrentRotation(axis?: Axis): void;
  37266. }
  37267. }
  37268. declare module BABYLON {
  37269. /**
  37270. * 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,
  37271. * which still works and will still be found in many Playgrounds.
  37272. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37273. */
  37274. export class UniversalCamera extends TouchCamera {
  37275. /**
  37276. * Defines the gamepad rotation sensiblity.
  37277. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37278. */
  37279. gamepadAngularSensibility: number;
  37280. /**
  37281. * Defines the gamepad move sensiblity.
  37282. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37283. */
  37284. gamepadMoveSensibility: number;
  37285. /**
  37286. * 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,
  37287. * which still works and will still be found in many Playgrounds.
  37288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37289. * @param name Define the name of the camera in the scene
  37290. * @param position Define the start position of the camera in the scene
  37291. * @param scene Define the scene the camera belongs to
  37292. */
  37293. constructor(name: string, position: Vector3, scene: Scene);
  37294. /**
  37295. * Gets the current object class name.
  37296. * @return the class name
  37297. */
  37298. getClassName(): string;
  37299. }
  37300. }
  37301. declare module BABYLON {
  37302. /**
  37303. * This represents a FPS type of camera. This is only here for back compat purpose.
  37304. * Please use the UniversalCamera instead as both are identical.
  37305. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37306. */
  37307. export class GamepadCamera extends UniversalCamera {
  37308. /**
  37309. * Instantiates a new Gamepad Camera
  37310. * This represents a FPS type of camera. This is only here for back compat purpose.
  37311. * Please use the UniversalCamera instead as both are identical.
  37312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37313. * @param name Define the name of the camera in the scene
  37314. * @param position Define the start position of the camera in the scene
  37315. * @param scene Define the scene the camera belongs to
  37316. */
  37317. constructor(name: string, position: Vector3, scene: Scene);
  37318. /**
  37319. * Gets the current object class name.
  37320. * @return the class name
  37321. */
  37322. getClassName(): string;
  37323. }
  37324. }
  37325. declare module BABYLON {
  37326. /** @hidden */
  37327. export var passPixelShader: {
  37328. name: string;
  37329. shader: string;
  37330. };
  37331. }
  37332. declare module BABYLON {
  37333. /** @hidden */
  37334. export var passCubePixelShader: {
  37335. name: string;
  37336. shader: string;
  37337. };
  37338. }
  37339. declare module BABYLON {
  37340. /**
  37341. * PassPostProcess which produces an output the same as it's input
  37342. */
  37343. export class PassPostProcess extends PostProcess {
  37344. /**
  37345. * Creates the PassPostProcess
  37346. * @param name The name of the effect.
  37347. * @param options The required width/height ratio to downsize to before computing the render pass.
  37348. * @param camera The camera to apply the render pass to.
  37349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37350. * @param engine The engine which the post process will be applied. (default: current engine)
  37351. * @param reusable If the post process can be reused on the same frame. (default: false)
  37352. * @param textureType The type of texture to be used when performing the post processing.
  37353. * @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)
  37354. */
  37355. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37356. }
  37357. /**
  37358. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37359. */
  37360. export class PassCubePostProcess extends PostProcess {
  37361. private _face;
  37362. /**
  37363. * Gets or sets the cube face to display.
  37364. * * 0 is +X
  37365. * * 1 is -X
  37366. * * 2 is +Y
  37367. * * 3 is -Y
  37368. * * 4 is +Z
  37369. * * 5 is -Z
  37370. */
  37371. face: number;
  37372. /**
  37373. * Creates the PassCubePostProcess
  37374. * @param name The name of the effect.
  37375. * @param options The required width/height ratio to downsize to before computing the render pass.
  37376. * @param camera The camera to apply the render pass to.
  37377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37378. * @param engine The engine which the post process will be applied. (default: current engine)
  37379. * @param reusable If the post process can be reused on the same frame. (default: false)
  37380. * @param textureType The type of texture to be used when performing the post processing.
  37381. * @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)
  37382. */
  37383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37384. }
  37385. }
  37386. declare module BABYLON {
  37387. /** @hidden */
  37388. export var anaglyphPixelShader: {
  37389. name: string;
  37390. shader: string;
  37391. };
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * Postprocess used to generate anaglyphic rendering
  37396. */
  37397. export class AnaglyphPostProcess extends PostProcess {
  37398. private _passedProcess;
  37399. /**
  37400. * Creates a new AnaglyphPostProcess
  37401. * @param name defines postprocess name
  37402. * @param options defines creation options or target ratio scale
  37403. * @param rigCameras defines cameras using this postprocess
  37404. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37405. * @param engine defines hosting engine
  37406. * @param reusable defines if the postprocess will be reused multiple times per frame
  37407. */
  37408. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37409. }
  37410. }
  37411. declare module BABYLON {
  37412. /**
  37413. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37415. */
  37416. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37417. /**
  37418. * Creates a new AnaglyphArcRotateCamera
  37419. * @param name defines camera name
  37420. * @param alpha defines alpha angle (in radians)
  37421. * @param beta defines beta angle (in radians)
  37422. * @param radius defines radius
  37423. * @param target defines camera target
  37424. * @param interaxialDistance defines distance between each color axis
  37425. * @param scene defines the hosting scene
  37426. */
  37427. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37428. /**
  37429. * Gets camera class name
  37430. * @returns AnaglyphArcRotateCamera
  37431. */
  37432. getClassName(): string;
  37433. }
  37434. }
  37435. declare module BABYLON {
  37436. /**
  37437. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37438. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37439. */
  37440. export class AnaglyphFreeCamera extends FreeCamera {
  37441. /**
  37442. * Creates a new AnaglyphFreeCamera
  37443. * @param name defines camera name
  37444. * @param position defines initial position
  37445. * @param interaxialDistance defines distance between each color axis
  37446. * @param scene defines the hosting scene
  37447. */
  37448. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37449. /**
  37450. * Gets camera class name
  37451. * @returns AnaglyphFreeCamera
  37452. */
  37453. getClassName(): string;
  37454. }
  37455. }
  37456. declare module BABYLON {
  37457. /**
  37458. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37459. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37460. */
  37461. export class AnaglyphGamepadCamera extends GamepadCamera {
  37462. /**
  37463. * Creates a new AnaglyphGamepadCamera
  37464. * @param name defines camera name
  37465. * @param position defines initial position
  37466. * @param interaxialDistance defines distance between each color axis
  37467. * @param scene defines the hosting scene
  37468. */
  37469. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37470. /**
  37471. * Gets camera class name
  37472. * @returns AnaglyphGamepadCamera
  37473. */
  37474. getClassName(): string;
  37475. }
  37476. }
  37477. declare module BABYLON {
  37478. /**
  37479. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37480. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37481. */
  37482. export class AnaglyphUniversalCamera extends UniversalCamera {
  37483. /**
  37484. * Creates a new AnaglyphUniversalCamera
  37485. * @param name defines camera name
  37486. * @param position defines initial position
  37487. * @param interaxialDistance defines distance between each color axis
  37488. * @param scene defines the hosting scene
  37489. */
  37490. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37491. /**
  37492. * Gets camera class name
  37493. * @returns AnaglyphUniversalCamera
  37494. */
  37495. getClassName(): string;
  37496. }
  37497. }
  37498. declare module BABYLON {
  37499. /** @hidden */
  37500. export var stereoscopicInterlacePixelShader: {
  37501. name: string;
  37502. shader: string;
  37503. };
  37504. }
  37505. declare module BABYLON {
  37506. /**
  37507. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37508. */
  37509. export class StereoscopicInterlacePostProcess extends PostProcess {
  37510. private _stepSize;
  37511. private _passedProcess;
  37512. /**
  37513. * Initializes a StereoscopicInterlacePostProcess
  37514. * @param name The name of the effect.
  37515. * @param rigCameras The rig cameras to be appled to the post process
  37516. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37518. * @param engine The engine which the post process will be applied. (default: current engine)
  37519. * @param reusable If the post process can be reused on the same frame. (default: false)
  37520. */
  37521. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37522. }
  37523. }
  37524. declare module BABYLON {
  37525. /**
  37526. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37527. * @see http://doc.babylonjs.com/features/cameras
  37528. */
  37529. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37530. /**
  37531. * Creates a new StereoscopicArcRotateCamera
  37532. * @param name defines camera name
  37533. * @param alpha defines alpha angle (in radians)
  37534. * @param beta defines beta angle (in radians)
  37535. * @param radius defines radius
  37536. * @param target defines camera target
  37537. * @param interaxialDistance defines distance between each color axis
  37538. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37539. * @param scene defines the hosting scene
  37540. */
  37541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37542. /**
  37543. * Gets camera class name
  37544. * @returns StereoscopicArcRotateCamera
  37545. */
  37546. getClassName(): string;
  37547. }
  37548. }
  37549. declare module BABYLON {
  37550. /**
  37551. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37552. * @see http://doc.babylonjs.com/features/cameras
  37553. */
  37554. export class StereoscopicFreeCamera extends FreeCamera {
  37555. /**
  37556. * Creates a new StereoscopicFreeCamera
  37557. * @param name defines camera name
  37558. * @param position defines initial position
  37559. * @param interaxialDistance defines distance between each color axis
  37560. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37561. * @param scene defines the hosting scene
  37562. */
  37563. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37564. /**
  37565. * Gets camera class name
  37566. * @returns StereoscopicFreeCamera
  37567. */
  37568. getClassName(): string;
  37569. }
  37570. }
  37571. declare module BABYLON {
  37572. /**
  37573. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37574. * @see http://doc.babylonjs.com/features/cameras
  37575. */
  37576. export class StereoscopicGamepadCamera extends GamepadCamera {
  37577. /**
  37578. * Creates a new StereoscopicGamepadCamera
  37579. * @param name defines camera name
  37580. * @param position defines initial position
  37581. * @param interaxialDistance defines distance between each color axis
  37582. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37583. * @param scene defines the hosting scene
  37584. */
  37585. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37586. /**
  37587. * Gets camera class name
  37588. * @returns StereoscopicGamepadCamera
  37589. */
  37590. getClassName(): string;
  37591. }
  37592. }
  37593. declare module BABYLON {
  37594. /**
  37595. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37596. * @see http://doc.babylonjs.com/features/cameras
  37597. */
  37598. export class StereoscopicUniversalCamera extends UniversalCamera {
  37599. /**
  37600. * Creates a new StereoscopicUniversalCamera
  37601. * @param name defines camera name
  37602. * @param position defines initial position
  37603. * @param interaxialDistance defines distance between each color axis
  37604. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37605. * @param scene defines the hosting scene
  37606. */
  37607. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37608. /**
  37609. * Gets camera class name
  37610. * @returns StereoscopicUniversalCamera
  37611. */
  37612. getClassName(): string;
  37613. }
  37614. }
  37615. declare module BABYLON {
  37616. /**
  37617. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37618. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37619. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37620. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37621. */
  37622. export class VirtualJoysticksCamera extends FreeCamera {
  37623. /**
  37624. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37625. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37626. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37627. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37628. * @param name Define the name of the camera in the scene
  37629. * @param position Define the start position of the camera in the scene
  37630. * @param scene Define the scene the camera belongs to
  37631. */
  37632. constructor(name: string, position: Vector3, scene: Scene);
  37633. /**
  37634. * Gets the current object class name.
  37635. * @return the class name
  37636. */
  37637. getClassName(): string;
  37638. }
  37639. }
  37640. declare module BABYLON {
  37641. /**
  37642. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37643. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37644. */
  37645. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37646. /**
  37647. * Creates a new VRDeviceOrientationArcRotateCamera
  37648. * @param name defines camera name
  37649. * @param alpha defines the camera rotation along the logitudinal axis
  37650. * @param beta defines the camera rotation along the latitudinal axis
  37651. * @param radius defines the camera distance from its target
  37652. * @param target defines the camera target
  37653. * @param scene defines the scene the camera belongs to
  37654. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37655. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37656. */
  37657. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37658. /**
  37659. * Gets camera class name
  37660. * @returns VRDeviceOrientationArcRotateCamera
  37661. */
  37662. getClassName(): string;
  37663. }
  37664. }
  37665. declare module BABYLON {
  37666. /**
  37667. * Camera used to simulate VR rendering (based on FreeCamera)
  37668. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37669. */
  37670. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37671. /**
  37672. * Creates a new VRDeviceOrientationFreeCamera
  37673. * @param name defines camera name
  37674. * @param position defines the start position of the camera
  37675. * @param scene defines the scene the camera belongs to
  37676. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37677. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37678. */
  37679. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37680. /**
  37681. * Gets camera class name
  37682. * @returns VRDeviceOrientationFreeCamera
  37683. */
  37684. getClassName(): string;
  37685. }
  37686. }
  37687. declare module BABYLON {
  37688. /**
  37689. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37690. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37691. */
  37692. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37693. /**
  37694. * Creates a new VRDeviceOrientationGamepadCamera
  37695. * @param name defines camera name
  37696. * @param position defines the start position of the camera
  37697. * @param scene defines the scene the camera belongs to
  37698. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37699. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37700. */
  37701. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37702. /**
  37703. * Gets camera class name
  37704. * @returns VRDeviceOrientationGamepadCamera
  37705. */
  37706. getClassName(): string;
  37707. }
  37708. }
  37709. declare module BABYLON {
  37710. /**
  37711. * Defines supported buttons for XBox360 compatible gamepads
  37712. */
  37713. export enum Xbox360Button {
  37714. /** A */
  37715. A = 0,
  37716. /** B */
  37717. B = 1,
  37718. /** X */
  37719. X = 2,
  37720. /** Y */
  37721. Y = 3,
  37722. /** Start */
  37723. Start = 4,
  37724. /** Back */
  37725. Back = 5,
  37726. /** Left button */
  37727. LB = 6,
  37728. /** Right button */
  37729. RB = 7,
  37730. /** Left stick */
  37731. LeftStick = 8,
  37732. /** Right stick */
  37733. RightStick = 9
  37734. }
  37735. /** Defines values for XBox360 DPad */
  37736. export enum Xbox360Dpad {
  37737. /** Up */
  37738. Up = 0,
  37739. /** Down */
  37740. Down = 1,
  37741. /** Left */
  37742. Left = 2,
  37743. /** Right */
  37744. Right = 3
  37745. }
  37746. /**
  37747. * Defines a XBox360 gamepad
  37748. */
  37749. export class Xbox360Pad extends Gamepad {
  37750. private _leftTrigger;
  37751. private _rightTrigger;
  37752. private _onlefttriggerchanged;
  37753. private _onrighttriggerchanged;
  37754. private _onbuttondown;
  37755. private _onbuttonup;
  37756. private _ondpaddown;
  37757. private _ondpadup;
  37758. /** Observable raised when a button is pressed */
  37759. onButtonDownObservable: Observable<Xbox360Button>;
  37760. /** Observable raised when a button is released */
  37761. onButtonUpObservable: Observable<Xbox360Button>;
  37762. /** Observable raised when a pad is pressed */
  37763. onPadDownObservable: Observable<Xbox360Dpad>;
  37764. /** Observable raised when a pad is released */
  37765. onPadUpObservable: Observable<Xbox360Dpad>;
  37766. private _buttonA;
  37767. private _buttonB;
  37768. private _buttonX;
  37769. private _buttonY;
  37770. private _buttonBack;
  37771. private _buttonStart;
  37772. private _buttonLB;
  37773. private _buttonRB;
  37774. private _buttonLeftStick;
  37775. private _buttonRightStick;
  37776. private _dPadUp;
  37777. private _dPadDown;
  37778. private _dPadLeft;
  37779. private _dPadRight;
  37780. private _isXboxOnePad;
  37781. /**
  37782. * Creates a new XBox360 gamepad object
  37783. * @param id defines the id of this gamepad
  37784. * @param index defines its index
  37785. * @param gamepad defines the internal HTML gamepad object
  37786. * @param xboxOne defines if it is a XBox One gamepad
  37787. */
  37788. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37789. /**
  37790. * Defines the callback to call when left trigger is pressed
  37791. * @param callback defines the callback to use
  37792. */
  37793. onlefttriggerchanged(callback: (value: number) => void): void;
  37794. /**
  37795. * Defines the callback to call when right trigger is pressed
  37796. * @param callback defines the callback to use
  37797. */
  37798. onrighttriggerchanged(callback: (value: number) => void): void;
  37799. /**
  37800. * Gets the left trigger value
  37801. */
  37802. /**
  37803. * Sets the left trigger value
  37804. */
  37805. leftTrigger: number;
  37806. /**
  37807. * Gets the right trigger value
  37808. */
  37809. /**
  37810. * Sets the right trigger value
  37811. */
  37812. rightTrigger: number;
  37813. /**
  37814. * Defines the callback to call when a button is pressed
  37815. * @param callback defines the callback to use
  37816. */
  37817. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37818. /**
  37819. * Defines the callback to call when a button is released
  37820. * @param callback defines the callback to use
  37821. */
  37822. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37823. /**
  37824. * Defines the callback to call when a pad is pressed
  37825. * @param callback defines the callback to use
  37826. */
  37827. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37828. /**
  37829. * Defines the callback to call when a pad is released
  37830. * @param callback defines the callback to use
  37831. */
  37832. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37833. private _setButtonValue;
  37834. private _setDPadValue;
  37835. /**
  37836. * Gets the value of the `A` button
  37837. */
  37838. /**
  37839. * Sets the value of the `A` button
  37840. */
  37841. buttonA: number;
  37842. /**
  37843. * Gets the value of the `B` button
  37844. */
  37845. /**
  37846. * Sets the value of the `B` button
  37847. */
  37848. buttonB: number;
  37849. /**
  37850. * Gets the value of the `X` button
  37851. */
  37852. /**
  37853. * Sets the value of the `X` button
  37854. */
  37855. buttonX: number;
  37856. /**
  37857. * Gets the value of the `Y` button
  37858. */
  37859. /**
  37860. * Sets the value of the `Y` button
  37861. */
  37862. buttonY: number;
  37863. /**
  37864. * Gets the value of the `Start` button
  37865. */
  37866. /**
  37867. * Sets the value of the `Start` button
  37868. */
  37869. buttonStart: number;
  37870. /**
  37871. * Gets the value of the `Back` button
  37872. */
  37873. /**
  37874. * Sets the value of the `Back` button
  37875. */
  37876. buttonBack: number;
  37877. /**
  37878. * Gets the value of the `Left` button
  37879. */
  37880. /**
  37881. * Sets the value of the `Left` button
  37882. */
  37883. buttonLB: number;
  37884. /**
  37885. * Gets the value of the `Right` button
  37886. */
  37887. /**
  37888. * Sets the value of the `Right` button
  37889. */
  37890. buttonRB: number;
  37891. /**
  37892. * Gets the value of the Left joystick
  37893. */
  37894. /**
  37895. * Sets the value of the Left joystick
  37896. */
  37897. buttonLeftStick: number;
  37898. /**
  37899. * Gets the value of the Right joystick
  37900. */
  37901. /**
  37902. * Sets the value of the Right joystick
  37903. */
  37904. buttonRightStick: number;
  37905. /**
  37906. * Gets the value of D-pad up
  37907. */
  37908. /**
  37909. * Sets the value of D-pad up
  37910. */
  37911. dPadUp: number;
  37912. /**
  37913. * Gets the value of D-pad down
  37914. */
  37915. /**
  37916. * Sets the value of D-pad down
  37917. */
  37918. dPadDown: number;
  37919. /**
  37920. * Gets the value of D-pad left
  37921. */
  37922. /**
  37923. * Sets the value of D-pad left
  37924. */
  37925. dPadLeft: number;
  37926. /**
  37927. * Gets the value of D-pad right
  37928. */
  37929. /**
  37930. * Sets the value of D-pad right
  37931. */
  37932. dPadRight: number;
  37933. /**
  37934. * Force the gamepad to synchronize with device values
  37935. */
  37936. update(): void;
  37937. /**
  37938. * Disposes the gamepad
  37939. */
  37940. dispose(): void;
  37941. }
  37942. }
  37943. declare module BABYLON {
  37944. /**
  37945. * Base class of materials working in push mode in babylon JS
  37946. * @hidden
  37947. */
  37948. export class PushMaterial extends Material {
  37949. protected _activeEffect: Effect;
  37950. protected _normalMatrix: Matrix;
  37951. /**
  37952. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37953. * This means that the material can keep using a previous shader while a new one is being compiled.
  37954. * This is mostly used when shader parallel compilation is supported (true by default)
  37955. */
  37956. allowShaderHotSwapping: boolean;
  37957. constructor(name: string, scene: Scene);
  37958. getEffect(): Effect;
  37959. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37960. /**
  37961. * Binds the given world matrix to the active effect
  37962. *
  37963. * @param world the matrix to bind
  37964. */
  37965. bindOnlyWorldMatrix(world: Matrix): void;
  37966. /**
  37967. * Binds the given normal matrix to the active effect
  37968. *
  37969. * @param normalMatrix the matrix to bind
  37970. */
  37971. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37972. bind(world: Matrix, mesh?: Mesh): void;
  37973. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37974. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37975. }
  37976. }
  37977. declare module BABYLON {
  37978. /**
  37979. * This groups all the flags used to control the materials channel.
  37980. */
  37981. export class MaterialFlags {
  37982. private static _DiffuseTextureEnabled;
  37983. /**
  37984. * Are diffuse textures enabled in the application.
  37985. */
  37986. static DiffuseTextureEnabled: boolean;
  37987. private static _AmbientTextureEnabled;
  37988. /**
  37989. * Are ambient textures enabled in the application.
  37990. */
  37991. static AmbientTextureEnabled: boolean;
  37992. private static _OpacityTextureEnabled;
  37993. /**
  37994. * Are opacity textures enabled in the application.
  37995. */
  37996. static OpacityTextureEnabled: boolean;
  37997. private static _ReflectionTextureEnabled;
  37998. /**
  37999. * Are reflection textures enabled in the application.
  38000. */
  38001. static ReflectionTextureEnabled: boolean;
  38002. private static _EmissiveTextureEnabled;
  38003. /**
  38004. * Are emissive textures enabled in the application.
  38005. */
  38006. static EmissiveTextureEnabled: boolean;
  38007. private static _SpecularTextureEnabled;
  38008. /**
  38009. * Are specular textures enabled in the application.
  38010. */
  38011. static SpecularTextureEnabled: boolean;
  38012. private static _BumpTextureEnabled;
  38013. /**
  38014. * Are bump textures enabled in the application.
  38015. */
  38016. static BumpTextureEnabled: boolean;
  38017. private static _LightmapTextureEnabled;
  38018. /**
  38019. * Are lightmap textures enabled in the application.
  38020. */
  38021. static LightmapTextureEnabled: boolean;
  38022. private static _RefractionTextureEnabled;
  38023. /**
  38024. * Are refraction textures enabled in the application.
  38025. */
  38026. static RefractionTextureEnabled: boolean;
  38027. private static _ColorGradingTextureEnabled;
  38028. /**
  38029. * Are color grading textures enabled in the application.
  38030. */
  38031. static ColorGradingTextureEnabled: boolean;
  38032. private static _FresnelEnabled;
  38033. /**
  38034. * Are fresnels enabled in the application.
  38035. */
  38036. static FresnelEnabled: boolean;
  38037. private static _ClearCoatTextureEnabled;
  38038. /**
  38039. * Are clear coat textures enabled in the application.
  38040. */
  38041. static ClearCoatTextureEnabled: boolean;
  38042. private static _ClearCoatBumpTextureEnabled;
  38043. /**
  38044. * Are clear coat bump textures enabled in the application.
  38045. */
  38046. static ClearCoatBumpTextureEnabled: boolean;
  38047. private static _ClearCoatTintTextureEnabled;
  38048. /**
  38049. * Are clear coat tint textures enabled in the application.
  38050. */
  38051. static ClearCoatTintTextureEnabled: boolean;
  38052. private static _SheenTextureEnabled;
  38053. /**
  38054. * Are sheen textures enabled in the application.
  38055. */
  38056. static SheenTextureEnabled: boolean;
  38057. private static _AnisotropicTextureEnabled;
  38058. /**
  38059. * Are anisotropic textures enabled in the application.
  38060. */
  38061. static AnisotropicTextureEnabled: boolean;
  38062. }
  38063. }
  38064. declare module BABYLON {
  38065. /** @hidden */
  38066. export var defaultFragmentDeclaration: {
  38067. name: string;
  38068. shader: string;
  38069. };
  38070. }
  38071. declare module BABYLON {
  38072. /** @hidden */
  38073. export var defaultUboDeclaration: {
  38074. name: string;
  38075. shader: string;
  38076. };
  38077. }
  38078. declare module BABYLON {
  38079. /** @hidden */
  38080. export var lightFragmentDeclaration: {
  38081. name: string;
  38082. shader: string;
  38083. };
  38084. }
  38085. declare module BABYLON {
  38086. /** @hidden */
  38087. export var lightUboDeclaration: {
  38088. name: string;
  38089. shader: string;
  38090. };
  38091. }
  38092. declare module BABYLON {
  38093. /** @hidden */
  38094. export var lightsFragmentFunctions: {
  38095. name: string;
  38096. shader: string;
  38097. };
  38098. }
  38099. declare module BABYLON {
  38100. /** @hidden */
  38101. export var shadowsFragmentFunctions: {
  38102. name: string;
  38103. shader: string;
  38104. };
  38105. }
  38106. declare module BABYLON {
  38107. /** @hidden */
  38108. export var fresnelFunction: {
  38109. name: string;
  38110. shader: string;
  38111. };
  38112. }
  38113. declare module BABYLON {
  38114. /** @hidden */
  38115. export var reflectionFunction: {
  38116. name: string;
  38117. shader: string;
  38118. };
  38119. }
  38120. declare module BABYLON {
  38121. /** @hidden */
  38122. export var bumpFragmentFunctions: {
  38123. name: string;
  38124. shader: string;
  38125. };
  38126. }
  38127. declare module BABYLON {
  38128. /** @hidden */
  38129. export var logDepthDeclaration: {
  38130. name: string;
  38131. shader: string;
  38132. };
  38133. }
  38134. declare module BABYLON {
  38135. /** @hidden */
  38136. export var bumpFragment: {
  38137. name: string;
  38138. shader: string;
  38139. };
  38140. }
  38141. declare module BABYLON {
  38142. /** @hidden */
  38143. export var depthPrePass: {
  38144. name: string;
  38145. shader: string;
  38146. };
  38147. }
  38148. declare module BABYLON {
  38149. /** @hidden */
  38150. export var lightFragment: {
  38151. name: string;
  38152. shader: string;
  38153. };
  38154. }
  38155. declare module BABYLON {
  38156. /** @hidden */
  38157. export var logDepthFragment: {
  38158. name: string;
  38159. shader: string;
  38160. };
  38161. }
  38162. declare module BABYLON {
  38163. /** @hidden */
  38164. export var defaultPixelShader: {
  38165. name: string;
  38166. shader: string;
  38167. };
  38168. }
  38169. declare module BABYLON {
  38170. /** @hidden */
  38171. export var defaultVertexDeclaration: {
  38172. name: string;
  38173. shader: string;
  38174. };
  38175. }
  38176. declare module BABYLON {
  38177. /** @hidden */
  38178. export var bumpVertexDeclaration: {
  38179. name: string;
  38180. shader: string;
  38181. };
  38182. }
  38183. declare module BABYLON {
  38184. /** @hidden */
  38185. export var bumpVertex: {
  38186. name: string;
  38187. shader: string;
  38188. };
  38189. }
  38190. declare module BABYLON {
  38191. /** @hidden */
  38192. export var fogVertex: {
  38193. name: string;
  38194. shader: string;
  38195. };
  38196. }
  38197. declare module BABYLON {
  38198. /** @hidden */
  38199. export var shadowsVertex: {
  38200. name: string;
  38201. shader: string;
  38202. };
  38203. }
  38204. declare module BABYLON {
  38205. /** @hidden */
  38206. export var pointCloudVertex: {
  38207. name: string;
  38208. shader: string;
  38209. };
  38210. }
  38211. declare module BABYLON {
  38212. /** @hidden */
  38213. export var logDepthVertex: {
  38214. name: string;
  38215. shader: string;
  38216. };
  38217. }
  38218. declare module BABYLON {
  38219. /** @hidden */
  38220. export var defaultVertexShader: {
  38221. name: string;
  38222. shader: string;
  38223. };
  38224. }
  38225. declare module BABYLON {
  38226. /** @hidden */
  38227. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38228. MAINUV1: boolean;
  38229. MAINUV2: boolean;
  38230. DIFFUSE: boolean;
  38231. DIFFUSEDIRECTUV: number;
  38232. AMBIENT: boolean;
  38233. AMBIENTDIRECTUV: number;
  38234. OPACITY: boolean;
  38235. OPACITYDIRECTUV: number;
  38236. OPACITYRGB: boolean;
  38237. REFLECTION: boolean;
  38238. EMISSIVE: boolean;
  38239. EMISSIVEDIRECTUV: number;
  38240. SPECULAR: boolean;
  38241. SPECULARDIRECTUV: number;
  38242. BUMP: boolean;
  38243. BUMPDIRECTUV: number;
  38244. PARALLAX: boolean;
  38245. PARALLAXOCCLUSION: boolean;
  38246. SPECULAROVERALPHA: boolean;
  38247. CLIPPLANE: boolean;
  38248. CLIPPLANE2: boolean;
  38249. CLIPPLANE3: boolean;
  38250. CLIPPLANE4: boolean;
  38251. ALPHATEST: boolean;
  38252. DEPTHPREPASS: boolean;
  38253. ALPHAFROMDIFFUSE: boolean;
  38254. POINTSIZE: boolean;
  38255. FOG: boolean;
  38256. SPECULARTERM: boolean;
  38257. DIFFUSEFRESNEL: boolean;
  38258. OPACITYFRESNEL: boolean;
  38259. REFLECTIONFRESNEL: boolean;
  38260. REFRACTIONFRESNEL: boolean;
  38261. EMISSIVEFRESNEL: boolean;
  38262. FRESNEL: boolean;
  38263. NORMAL: boolean;
  38264. UV1: boolean;
  38265. UV2: boolean;
  38266. VERTEXCOLOR: boolean;
  38267. VERTEXALPHA: boolean;
  38268. NUM_BONE_INFLUENCERS: number;
  38269. BonesPerMesh: number;
  38270. BONETEXTURE: boolean;
  38271. INSTANCES: boolean;
  38272. GLOSSINESS: boolean;
  38273. ROUGHNESS: boolean;
  38274. EMISSIVEASILLUMINATION: boolean;
  38275. LINKEMISSIVEWITHDIFFUSE: boolean;
  38276. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38277. LIGHTMAP: boolean;
  38278. LIGHTMAPDIRECTUV: number;
  38279. OBJECTSPACE_NORMALMAP: boolean;
  38280. USELIGHTMAPASSHADOWMAP: boolean;
  38281. REFLECTIONMAP_3D: boolean;
  38282. REFLECTIONMAP_SPHERICAL: boolean;
  38283. REFLECTIONMAP_PLANAR: boolean;
  38284. REFLECTIONMAP_CUBIC: boolean;
  38285. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38286. REFLECTIONMAP_PROJECTION: boolean;
  38287. REFLECTIONMAP_SKYBOX: boolean;
  38288. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38289. REFLECTIONMAP_EXPLICIT: boolean;
  38290. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38291. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38292. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38293. INVERTCUBICMAP: boolean;
  38294. LOGARITHMICDEPTH: boolean;
  38295. REFRACTION: boolean;
  38296. REFRACTIONMAP_3D: boolean;
  38297. REFLECTIONOVERALPHA: boolean;
  38298. TWOSIDEDLIGHTING: boolean;
  38299. SHADOWFLOAT: boolean;
  38300. MORPHTARGETS: boolean;
  38301. MORPHTARGETS_NORMAL: boolean;
  38302. MORPHTARGETS_TANGENT: boolean;
  38303. NUM_MORPH_INFLUENCERS: number;
  38304. NONUNIFORMSCALING: boolean;
  38305. PREMULTIPLYALPHA: boolean;
  38306. IMAGEPROCESSING: boolean;
  38307. VIGNETTE: boolean;
  38308. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38309. VIGNETTEBLENDMODEOPAQUE: boolean;
  38310. TONEMAPPING: boolean;
  38311. TONEMAPPING_ACES: boolean;
  38312. CONTRAST: boolean;
  38313. COLORCURVES: boolean;
  38314. COLORGRADING: boolean;
  38315. COLORGRADING3D: boolean;
  38316. SAMPLER3DGREENDEPTH: boolean;
  38317. SAMPLER3DBGRMAP: boolean;
  38318. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38319. MULTIVIEW: boolean;
  38320. /**
  38321. * If the reflection texture on this material is in linear color space
  38322. * @hidden
  38323. */
  38324. IS_REFLECTION_LINEAR: boolean;
  38325. /**
  38326. * If the refraction texture on this material is in linear color space
  38327. * @hidden
  38328. */
  38329. IS_REFRACTION_LINEAR: boolean;
  38330. EXPOSURE: boolean;
  38331. constructor();
  38332. setReflectionMode(modeToEnable: string): void;
  38333. }
  38334. /**
  38335. * This is the default material used in Babylon. It is the best trade off between quality
  38336. * and performances.
  38337. * @see http://doc.babylonjs.com/babylon101/materials
  38338. */
  38339. export class StandardMaterial extends PushMaterial {
  38340. private _diffuseTexture;
  38341. /**
  38342. * The basic texture of the material as viewed under a light.
  38343. */
  38344. diffuseTexture: Nullable<BaseTexture>;
  38345. private _ambientTexture;
  38346. /**
  38347. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38348. */
  38349. ambientTexture: Nullable<BaseTexture>;
  38350. private _opacityTexture;
  38351. /**
  38352. * Define the transparency of the material from a texture.
  38353. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38354. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38355. */
  38356. opacityTexture: Nullable<BaseTexture>;
  38357. private _reflectionTexture;
  38358. /**
  38359. * Define the texture used to display the reflection.
  38360. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38361. */
  38362. reflectionTexture: Nullable<BaseTexture>;
  38363. private _emissiveTexture;
  38364. /**
  38365. * Define texture of the material as if self lit.
  38366. * This will be mixed in the final result even in the absence of light.
  38367. */
  38368. emissiveTexture: Nullable<BaseTexture>;
  38369. private _specularTexture;
  38370. /**
  38371. * Define how the color and intensity of the highlight given by the light in the material.
  38372. */
  38373. specularTexture: Nullable<BaseTexture>;
  38374. private _bumpTexture;
  38375. /**
  38376. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38377. * 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.
  38378. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38379. */
  38380. bumpTexture: Nullable<BaseTexture>;
  38381. private _lightmapTexture;
  38382. /**
  38383. * Complex lighting can be computationally expensive to compute at runtime.
  38384. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38385. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38386. */
  38387. lightmapTexture: Nullable<BaseTexture>;
  38388. private _refractionTexture;
  38389. /**
  38390. * Define the texture used to display the refraction.
  38391. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38392. */
  38393. refractionTexture: Nullable<BaseTexture>;
  38394. /**
  38395. * The color of the material lit by the environmental background lighting.
  38396. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38397. */
  38398. ambientColor: Color3;
  38399. /**
  38400. * The basic color of the material as viewed under a light.
  38401. */
  38402. diffuseColor: Color3;
  38403. /**
  38404. * Define how the color and intensity of the highlight given by the light in the material.
  38405. */
  38406. specularColor: Color3;
  38407. /**
  38408. * Define the color of the material as if self lit.
  38409. * This will be mixed in the final result even in the absence of light.
  38410. */
  38411. emissiveColor: Color3;
  38412. /**
  38413. * Defines how sharp are the highlights in the material.
  38414. * The bigger the value the sharper giving a more glossy feeling to the result.
  38415. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38416. */
  38417. specularPower: number;
  38418. private _useAlphaFromDiffuseTexture;
  38419. /**
  38420. * Does the transparency come from the diffuse texture alpha channel.
  38421. */
  38422. useAlphaFromDiffuseTexture: boolean;
  38423. private _useEmissiveAsIllumination;
  38424. /**
  38425. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38426. */
  38427. useEmissiveAsIllumination: boolean;
  38428. private _linkEmissiveWithDiffuse;
  38429. /**
  38430. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38431. * the emissive level when the final color is close to one.
  38432. */
  38433. linkEmissiveWithDiffuse: boolean;
  38434. private _useSpecularOverAlpha;
  38435. /**
  38436. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38437. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38438. */
  38439. useSpecularOverAlpha: boolean;
  38440. private _useReflectionOverAlpha;
  38441. /**
  38442. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38443. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38444. */
  38445. useReflectionOverAlpha: boolean;
  38446. private _disableLighting;
  38447. /**
  38448. * Does lights from the scene impacts this material.
  38449. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38450. */
  38451. disableLighting: boolean;
  38452. private _useObjectSpaceNormalMap;
  38453. /**
  38454. * Allows using an object space normal map (instead of tangent space).
  38455. */
  38456. useObjectSpaceNormalMap: boolean;
  38457. private _useParallax;
  38458. /**
  38459. * Is parallax enabled or not.
  38460. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38461. */
  38462. useParallax: boolean;
  38463. private _useParallaxOcclusion;
  38464. /**
  38465. * Is parallax occlusion enabled or not.
  38466. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38467. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38468. */
  38469. useParallaxOcclusion: boolean;
  38470. /**
  38471. * 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.
  38472. */
  38473. parallaxScaleBias: number;
  38474. private _roughness;
  38475. /**
  38476. * Helps to define how blurry the reflections should appears in the material.
  38477. */
  38478. roughness: number;
  38479. /**
  38480. * In case of refraction, define the value of the indice of refraction.
  38481. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38482. */
  38483. indexOfRefraction: number;
  38484. /**
  38485. * Invert the refraction texture alongside the y axis.
  38486. * It can be useful with procedural textures or probe for instance.
  38487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38488. */
  38489. invertRefractionY: boolean;
  38490. /**
  38491. * Defines the alpha limits in alpha test mode.
  38492. */
  38493. alphaCutOff: number;
  38494. private _useLightmapAsShadowmap;
  38495. /**
  38496. * In case of light mapping, define whether the map contains light or shadow informations.
  38497. */
  38498. useLightmapAsShadowmap: boolean;
  38499. private _diffuseFresnelParameters;
  38500. /**
  38501. * Define the diffuse fresnel parameters of the material.
  38502. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38503. */
  38504. diffuseFresnelParameters: FresnelParameters;
  38505. private _opacityFresnelParameters;
  38506. /**
  38507. * Define the opacity fresnel parameters of the material.
  38508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38509. */
  38510. opacityFresnelParameters: FresnelParameters;
  38511. private _reflectionFresnelParameters;
  38512. /**
  38513. * Define the reflection fresnel parameters of the material.
  38514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38515. */
  38516. reflectionFresnelParameters: FresnelParameters;
  38517. private _refractionFresnelParameters;
  38518. /**
  38519. * Define the refraction fresnel parameters of the material.
  38520. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38521. */
  38522. refractionFresnelParameters: FresnelParameters;
  38523. private _emissiveFresnelParameters;
  38524. /**
  38525. * Define the emissive fresnel parameters of the material.
  38526. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38527. */
  38528. emissiveFresnelParameters: FresnelParameters;
  38529. private _useReflectionFresnelFromSpecular;
  38530. /**
  38531. * If true automatically deducts the fresnels values from the material specularity.
  38532. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38533. */
  38534. useReflectionFresnelFromSpecular: boolean;
  38535. private _useGlossinessFromSpecularMapAlpha;
  38536. /**
  38537. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38538. */
  38539. useGlossinessFromSpecularMapAlpha: boolean;
  38540. private _maxSimultaneousLights;
  38541. /**
  38542. * Defines the maximum number of lights that can be used in the material
  38543. */
  38544. maxSimultaneousLights: number;
  38545. private _invertNormalMapX;
  38546. /**
  38547. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38548. */
  38549. invertNormalMapX: boolean;
  38550. private _invertNormalMapY;
  38551. /**
  38552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38553. */
  38554. invertNormalMapY: boolean;
  38555. private _twoSidedLighting;
  38556. /**
  38557. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38558. */
  38559. twoSidedLighting: boolean;
  38560. /**
  38561. * Default configuration related to image processing available in the standard Material.
  38562. */
  38563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38564. /**
  38565. * Gets the image processing configuration used either in this material.
  38566. */
  38567. /**
  38568. * Sets the Default image processing configuration used either in the this material.
  38569. *
  38570. * If sets to null, the scene one is in use.
  38571. */
  38572. imageProcessingConfiguration: ImageProcessingConfiguration;
  38573. /**
  38574. * Keep track of the image processing observer to allow dispose and replace.
  38575. */
  38576. private _imageProcessingObserver;
  38577. /**
  38578. * Attaches a new image processing configuration to the Standard Material.
  38579. * @param configuration
  38580. */
  38581. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38582. /**
  38583. * Gets wether the color curves effect is enabled.
  38584. */
  38585. /**
  38586. * Sets wether the color curves effect is enabled.
  38587. */
  38588. cameraColorCurvesEnabled: boolean;
  38589. /**
  38590. * Gets wether the color grading effect is enabled.
  38591. */
  38592. /**
  38593. * Gets wether the color grading effect is enabled.
  38594. */
  38595. cameraColorGradingEnabled: boolean;
  38596. /**
  38597. * Gets wether tonemapping is enabled or not.
  38598. */
  38599. /**
  38600. * Sets wether tonemapping is enabled or not
  38601. */
  38602. cameraToneMappingEnabled: boolean;
  38603. /**
  38604. * The camera exposure used on this material.
  38605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38606. * This corresponds to a photographic exposure.
  38607. */
  38608. /**
  38609. * The camera exposure used on this material.
  38610. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38611. * This corresponds to a photographic exposure.
  38612. */
  38613. cameraExposure: number;
  38614. /**
  38615. * Gets The camera contrast used on this material.
  38616. */
  38617. /**
  38618. * Sets The camera contrast used on this material.
  38619. */
  38620. cameraContrast: number;
  38621. /**
  38622. * Gets the Color Grading 2D Lookup Texture.
  38623. */
  38624. /**
  38625. * Sets the Color Grading 2D Lookup Texture.
  38626. */
  38627. cameraColorGradingTexture: Nullable<BaseTexture>;
  38628. /**
  38629. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38630. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38631. * 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;
  38632. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38633. */
  38634. /**
  38635. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38636. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38637. * 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;
  38638. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38639. */
  38640. cameraColorCurves: Nullable<ColorCurves>;
  38641. /**
  38642. * Custom callback helping to override the default shader used in the material.
  38643. */
  38644. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38645. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38646. protected _worldViewProjectionMatrix: Matrix;
  38647. protected _globalAmbientColor: Color3;
  38648. protected _useLogarithmicDepth: boolean;
  38649. /**
  38650. * Instantiates a new standard material.
  38651. * This is the default material used in Babylon. It is the best trade off between quality
  38652. * and performances.
  38653. * @see http://doc.babylonjs.com/babylon101/materials
  38654. * @param name Define the name of the material in the scene
  38655. * @param scene Define the scene the material belong to
  38656. */
  38657. constructor(name: string, scene: Scene);
  38658. /**
  38659. * Gets a boolean indicating that current material needs to register RTT
  38660. */
  38661. readonly hasRenderTargetTextures: boolean;
  38662. /**
  38663. * Gets the current class name of the material e.g. "StandardMaterial"
  38664. * Mainly use in serialization.
  38665. * @returns the class name
  38666. */
  38667. getClassName(): string;
  38668. /**
  38669. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38670. * You can try switching to logarithmic depth.
  38671. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38672. */
  38673. useLogarithmicDepth: boolean;
  38674. /**
  38675. * Specifies if the material will require alpha blending
  38676. * @returns a boolean specifying if alpha blending is needed
  38677. */
  38678. needAlphaBlending(): boolean;
  38679. /**
  38680. * Specifies if this material should be rendered in alpha test mode
  38681. * @returns a boolean specifying if an alpha test is needed.
  38682. */
  38683. needAlphaTesting(): boolean;
  38684. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38685. /**
  38686. * Get the texture used for alpha test purpose.
  38687. * @returns the diffuse texture in case of the standard material.
  38688. */
  38689. getAlphaTestTexture(): Nullable<BaseTexture>;
  38690. /**
  38691. * Get if the submesh is ready to be used and all its information available.
  38692. * Child classes can use it to update shaders
  38693. * @param mesh defines the mesh to check
  38694. * @param subMesh defines which submesh to check
  38695. * @param useInstances specifies that instances should be used
  38696. * @returns a boolean indicating that the submesh is ready or not
  38697. */
  38698. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38699. /**
  38700. * Builds the material UBO layouts.
  38701. * Used internally during the effect preparation.
  38702. */
  38703. buildUniformLayout(): void;
  38704. /**
  38705. * Unbinds the material from the mesh
  38706. */
  38707. unbind(): void;
  38708. /**
  38709. * Binds the submesh to this material by preparing the effect and shader to draw
  38710. * @param world defines the world transformation matrix
  38711. * @param mesh defines the mesh containing the submesh
  38712. * @param subMesh defines the submesh to bind the material to
  38713. */
  38714. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38715. /**
  38716. * Get the list of animatables in the material.
  38717. * @returns the list of animatables object used in the material
  38718. */
  38719. getAnimatables(): IAnimatable[];
  38720. /**
  38721. * Gets the active textures from the material
  38722. * @returns an array of textures
  38723. */
  38724. getActiveTextures(): BaseTexture[];
  38725. /**
  38726. * Specifies if the material uses a texture
  38727. * @param texture defines the texture to check against the material
  38728. * @returns a boolean specifying if the material uses the texture
  38729. */
  38730. hasTexture(texture: BaseTexture): boolean;
  38731. /**
  38732. * Disposes the material
  38733. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38734. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38735. */
  38736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38737. /**
  38738. * Makes a duplicate of the material, and gives it a new name
  38739. * @param name defines the new name for the duplicated material
  38740. * @returns the cloned material
  38741. */
  38742. clone(name: string): StandardMaterial;
  38743. /**
  38744. * Serializes this material in a JSON representation
  38745. * @returns the serialized material object
  38746. */
  38747. serialize(): any;
  38748. /**
  38749. * Creates a standard material from parsed material data
  38750. * @param source defines the JSON representation of the material
  38751. * @param scene defines the hosting scene
  38752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38753. * @returns a new standard material
  38754. */
  38755. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38756. /**
  38757. * Are diffuse textures enabled in the application.
  38758. */
  38759. static DiffuseTextureEnabled: boolean;
  38760. /**
  38761. * Are ambient textures enabled in the application.
  38762. */
  38763. static AmbientTextureEnabled: boolean;
  38764. /**
  38765. * Are opacity textures enabled in the application.
  38766. */
  38767. static OpacityTextureEnabled: boolean;
  38768. /**
  38769. * Are reflection textures enabled in the application.
  38770. */
  38771. static ReflectionTextureEnabled: boolean;
  38772. /**
  38773. * Are emissive textures enabled in the application.
  38774. */
  38775. static EmissiveTextureEnabled: boolean;
  38776. /**
  38777. * Are specular textures enabled in the application.
  38778. */
  38779. static SpecularTextureEnabled: boolean;
  38780. /**
  38781. * Are bump textures enabled in the application.
  38782. */
  38783. static BumpTextureEnabled: boolean;
  38784. /**
  38785. * Are lightmap textures enabled in the application.
  38786. */
  38787. static LightmapTextureEnabled: boolean;
  38788. /**
  38789. * Are refraction textures enabled in the application.
  38790. */
  38791. static RefractionTextureEnabled: boolean;
  38792. /**
  38793. * Are color grading textures enabled in the application.
  38794. */
  38795. static ColorGradingTextureEnabled: boolean;
  38796. /**
  38797. * Are fresnels enabled in the application.
  38798. */
  38799. static FresnelEnabled: boolean;
  38800. }
  38801. }
  38802. declare module BABYLON {
  38803. /**
  38804. * A class extending Texture allowing drawing on a texture
  38805. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38806. */
  38807. export class DynamicTexture extends Texture {
  38808. private _generateMipMaps;
  38809. private _canvas;
  38810. private _context;
  38811. private _engine;
  38812. /**
  38813. * Creates a DynamicTexture
  38814. * @param name defines the name of the texture
  38815. * @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
  38816. * @param scene defines the scene where you want the texture
  38817. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38818. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38819. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38820. */
  38821. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38822. /**
  38823. * Get the current class name of the texture useful for serialization or dynamic coding.
  38824. * @returns "DynamicTexture"
  38825. */
  38826. getClassName(): string;
  38827. /**
  38828. * Gets the current state of canRescale
  38829. */
  38830. readonly canRescale: boolean;
  38831. private _recreate;
  38832. /**
  38833. * Scales the texture
  38834. * @param ratio the scale factor to apply to both width and height
  38835. */
  38836. scale(ratio: number): void;
  38837. /**
  38838. * Resizes the texture
  38839. * @param width the new width
  38840. * @param height the new height
  38841. */
  38842. scaleTo(width: number, height: number): void;
  38843. /**
  38844. * Gets the context of the canvas used by the texture
  38845. * @returns the canvas context of the dynamic texture
  38846. */
  38847. getContext(): CanvasRenderingContext2D;
  38848. /**
  38849. * Clears the texture
  38850. */
  38851. clear(): void;
  38852. /**
  38853. * Updates the texture
  38854. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38855. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38856. */
  38857. update(invertY?: boolean, premulAlpha?: boolean): void;
  38858. /**
  38859. * Draws text onto the texture
  38860. * @param text defines the text to be drawn
  38861. * @param x defines the placement of the text from the left
  38862. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38863. * @param font defines the font to be used with font-style, font-size, font-name
  38864. * @param color defines the color used for the text
  38865. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38866. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38867. * @param update defines whether texture is immediately update (default is true)
  38868. */
  38869. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38870. /**
  38871. * Clones the texture
  38872. * @returns the clone of the texture.
  38873. */
  38874. clone(): DynamicTexture;
  38875. /**
  38876. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38877. * @returns a serialized dynamic texture object
  38878. */
  38879. serialize(): any;
  38880. /** @hidden */
  38881. _rebuild(): void;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /** @hidden */
  38886. export var imageProcessingPixelShader: {
  38887. name: string;
  38888. shader: string;
  38889. };
  38890. }
  38891. declare module BABYLON {
  38892. /**
  38893. * ImageProcessingPostProcess
  38894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38895. */
  38896. export class ImageProcessingPostProcess extends PostProcess {
  38897. /**
  38898. * Default configuration related to image processing available in the PBR Material.
  38899. */
  38900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38901. /**
  38902. * Gets the image processing configuration used either in this material.
  38903. */
  38904. /**
  38905. * Sets the Default image processing configuration used either in the this material.
  38906. *
  38907. * If sets to null, the scene one is in use.
  38908. */
  38909. imageProcessingConfiguration: ImageProcessingConfiguration;
  38910. /**
  38911. * Keep track of the image processing observer to allow dispose and replace.
  38912. */
  38913. private _imageProcessingObserver;
  38914. /**
  38915. * Attaches a new image processing configuration to the PBR Material.
  38916. * @param configuration
  38917. */
  38918. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38919. /**
  38920. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38921. */
  38922. /**
  38923. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38924. */
  38925. colorCurves: Nullable<ColorCurves>;
  38926. /**
  38927. * Gets wether the color curves effect is enabled.
  38928. */
  38929. /**
  38930. * Sets wether the color curves effect is enabled.
  38931. */
  38932. colorCurvesEnabled: boolean;
  38933. /**
  38934. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38935. */
  38936. /**
  38937. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38938. */
  38939. colorGradingTexture: Nullable<BaseTexture>;
  38940. /**
  38941. * Gets wether the color grading effect is enabled.
  38942. */
  38943. /**
  38944. * Gets wether the color grading effect is enabled.
  38945. */
  38946. colorGradingEnabled: boolean;
  38947. /**
  38948. * Gets exposure used in the effect.
  38949. */
  38950. /**
  38951. * Sets exposure used in the effect.
  38952. */
  38953. exposure: number;
  38954. /**
  38955. * Gets wether tonemapping is enabled or not.
  38956. */
  38957. /**
  38958. * Sets wether tonemapping is enabled or not
  38959. */
  38960. toneMappingEnabled: boolean;
  38961. /**
  38962. * Gets the type of tone mapping effect.
  38963. */
  38964. /**
  38965. * Sets the type of tone mapping effect.
  38966. */
  38967. toneMappingType: number;
  38968. /**
  38969. * Gets contrast used in the effect.
  38970. */
  38971. /**
  38972. * Sets contrast used in the effect.
  38973. */
  38974. contrast: number;
  38975. /**
  38976. * Gets Vignette stretch size.
  38977. */
  38978. /**
  38979. * Sets Vignette stretch size.
  38980. */
  38981. vignetteStretch: number;
  38982. /**
  38983. * Gets Vignette centre X Offset.
  38984. */
  38985. /**
  38986. * Sets Vignette centre X Offset.
  38987. */
  38988. vignetteCentreX: number;
  38989. /**
  38990. * Gets Vignette centre Y Offset.
  38991. */
  38992. /**
  38993. * Sets Vignette centre Y Offset.
  38994. */
  38995. vignetteCentreY: number;
  38996. /**
  38997. * Gets Vignette weight or intensity of the vignette effect.
  38998. */
  38999. /**
  39000. * Sets Vignette weight or intensity of the vignette effect.
  39001. */
  39002. vignetteWeight: number;
  39003. /**
  39004. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39005. * if vignetteEnabled is set to true.
  39006. */
  39007. /**
  39008. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39009. * if vignetteEnabled is set to true.
  39010. */
  39011. vignetteColor: Color4;
  39012. /**
  39013. * Gets Camera field of view used by the Vignette effect.
  39014. */
  39015. /**
  39016. * Sets Camera field of view used by the Vignette effect.
  39017. */
  39018. vignetteCameraFov: number;
  39019. /**
  39020. * Gets the vignette blend mode allowing different kind of effect.
  39021. */
  39022. /**
  39023. * Sets the vignette blend mode allowing different kind of effect.
  39024. */
  39025. vignetteBlendMode: number;
  39026. /**
  39027. * Gets wether the vignette effect is enabled.
  39028. */
  39029. /**
  39030. * Sets wether the vignette effect is enabled.
  39031. */
  39032. vignetteEnabled: boolean;
  39033. private _fromLinearSpace;
  39034. /**
  39035. * Gets wether the input of the processing is in Gamma or Linear Space.
  39036. */
  39037. /**
  39038. * Sets wether the input of the processing is in Gamma or Linear Space.
  39039. */
  39040. fromLinearSpace: boolean;
  39041. /**
  39042. * Defines cache preventing GC.
  39043. */
  39044. private _defines;
  39045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39046. /**
  39047. * "ImageProcessingPostProcess"
  39048. * @returns "ImageProcessingPostProcess"
  39049. */
  39050. getClassName(): string;
  39051. protected _updateParameters(): void;
  39052. dispose(camera?: Camera): void;
  39053. }
  39054. }
  39055. declare module BABYLON {
  39056. /**
  39057. * Class containing static functions to help procedurally build meshes
  39058. */
  39059. export class GroundBuilder {
  39060. /**
  39061. * Creates a ground mesh
  39062. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39063. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39065. * @param name defines the name of the mesh
  39066. * @param options defines the options used to create the mesh
  39067. * @param scene defines the hosting scene
  39068. * @returns the ground mesh
  39069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39070. */
  39071. static CreateGround(name: string, options: {
  39072. width?: number;
  39073. height?: number;
  39074. subdivisions?: number;
  39075. subdivisionsX?: number;
  39076. subdivisionsY?: number;
  39077. updatable?: boolean;
  39078. }, scene: any): Mesh;
  39079. /**
  39080. * Creates a tiled ground mesh
  39081. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39082. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39083. * * 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
  39084. * * 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
  39085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39086. * @param name defines the name of the mesh
  39087. * @param options defines the options used to create the mesh
  39088. * @param scene defines the hosting scene
  39089. * @returns the tiled ground mesh
  39090. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39091. */
  39092. static CreateTiledGround(name: string, options: {
  39093. xmin: number;
  39094. zmin: number;
  39095. xmax: number;
  39096. zmax: number;
  39097. subdivisions?: {
  39098. w: number;
  39099. h: number;
  39100. };
  39101. precision?: {
  39102. w: number;
  39103. h: number;
  39104. };
  39105. updatable?: boolean;
  39106. }, scene: Scene): Mesh;
  39107. /**
  39108. * Creates a ground mesh from a height map
  39109. * * The parameter `url` sets the URL of the height map image resource.
  39110. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39111. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39112. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39113. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39114. * * 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.
  39115. * * 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).
  39116. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39118. * @param name defines the name of the mesh
  39119. * @param url defines the url to the height map
  39120. * @param options defines the options used to create the mesh
  39121. * @param scene defines the hosting scene
  39122. * @returns the ground mesh
  39123. * @see https://doc.babylonjs.com/babylon101/height_map
  39124. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39125. */
  39126. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39127. width?: number;
  39128. height?: number;
  39129. subdivisions?: number;
  39130. minHeight?: number;
  39131. maxHeight?: number;
  39132. colorFilter?: Color3;
  39133. alphaFilter?: number;
  39134. updatable?: boolean;
  39135. onReady?: (mesh: GroundMesh) => void;
  39136. }, scene: Scene): GroundMesh;
  39137. }
  39138. }
  39139. declare module BABYLON {
  39140. /**
  39141. * Class containing static functions to help procedurally build meshes
  39142. */
  39143. export class TorusBuilder {
  39144. /**
  39145. * Creates a torus mesh
  39146. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39147. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39148. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39150. * * 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
  39151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39152. * @param name defines the name of the mesh
  39153. * @param options defines the options used to create the mesh
  39154. * @param scene defines the hosting scene
  39155. * @returns the torus mesh
  39156. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39157. */
  39158. static CreateTorus(name: string, options: {
  39159. diameter?: number;
  39160. thickness?: number;
  39161. tessellation?: number;
  39162. updatable?: boolean;
  39163. sideOrientation?: number;
  39164. frontUVs?: Vector4;
  39165. backUVs?: Vector4;
  39166. }, scene: any): Mesh;
  39167. }
  39168. }
  39169. declare module BABYLON {
  39170. /**
  39171. * Class containing static functions to help procedurally build meshes
  39172. */
  39173. export class CylinderBuilder {
  39174. /**
  39175. * Creates a cylinder or a cone mesh
  39176. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39177. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39178. * * 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.
  39179. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39180. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39181. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39182. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39183. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39184. * * 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).
  39185. * * 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
  39186. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39187. * * 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
  39188. * * 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.
  39189. * * If `enclose` is false, a ring surface is one element.
  39190. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39191. * * 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
  39192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39193. * * 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
  39194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39195. * @param name defines the name of the mesh
  39196. * @param options defines the options used to create the mesh
  39197. * @param scene defines the hosting scene
  39198. * @returns the cylinder mesh
  39199. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39200. */
  39201. static CreateCylinder(name: string, options: {
  39202. height?: number;
  39203. diameterTop?: number;
  39204. diameterBottom?: number;
  39205. diameter?: number;
  39206. tessellation?: number;
  39207. subdivisions?: number;
  39208. arc?: number;
  39209. faceColors?: Color4[];
  39210. faceUV?: Vector4[];
  39211. updatable?: boolean;
  39212. hasRings?: boolean;
  39213. enclose?: boolean;
  39214. sideOrientation?: number;
  39215. frontUVs?: Vector4;
  39216. backUVs?: Vector4;
  39217. }, scene: any): Mesh;
  39218. }
  39219. }
  39220. declare module BABYLON {
  39221. /**
  39222. * Manager for handling gamepads
  39223. */
  39224. export class GamepadManager {
  39225. private _scene?;
  39226. private _babylonGamepads;
  39227. private _oneGamepadConnected;
  39228. /** @hidden */
  39229. _isMonitoring: boolean;
  39230. private _gamepadEventSupported;
  39231. private _gamepadSupport;
  39232. /**
  39233. * observable to be triggered when the gamepad controller has been connected
  39234. */
  39235. onGamepadConnectedObservable: Observable<Gamepad>;
  39236. /**
  39237. * observable to be triggered when the gamepad controller has been disconnected
  39238. */
  39239. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39240. private _onGamepadConnectedEvent;
  39241. private _onGamepadDisconnectedEvent;
  39242. /**
  39243. * Initializes the gamepad manager
  39244. * @param _scene BabylonJS scene
  39245. */
  39246. constructor(_scene?: Scene | undefined);
  39247. /**
  39248. * The gamepads in the game pad manager
  39249. */
  39250. readonly gamepads: Gamepad[];
  39251. /**
  39252. * Get the gamepad controllers based on type
  39253. * @param type The type of gamepad controller
  39254. * @returns Nullable gamepad
  39255. */
  39256. getGamepadByType(type?: number): Nullable<Gamepad>;
  39257. /**
  39258. * Disposes the gamepad manager
  39259. */
  39260. dispose(): void;
  39261. private _addNewGamepad;
  39262. private _startMonitoringGamepads;
  39263. private _stopMonitoringGamepads;
  39264. /** @hidden */
  39265. _checkGamepadsStatus(): void;
  39266. private _updateGamepadObjects;
  39267. }
  39268. }
  39269. declare module BABYLON {
  39270. interface Scene {
  39271. /** @hidden */
  39272. _gamepadManager: Nullable<GamepadManager>;
  39273. /**
  39274. * Gets the gamepad manager associated with the scene
  39275. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39276. */
  39277. gamepadManager: GamepadManager;
  39278. }
  39279. /**
  39280. * Interface representing a free camera inputs manager
  39281. */
  39282. interface FreeCameraInputsManager {
  39283. /**
  39284. * Adds gamepad input support to the FreeCameraInputsManager.
  39285. * @returns the FreeCameraInputsManager
  39286. */
  39287. addGamepad(): FreeCameraInputsManager;
  39288. }
  39289. /**
  39290. * Interface representing an arc rotate camera inputs manager
  39291. */
  39292. interface ArcRotateCameraInputsManager {
  39293. /**
  39294. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39295. * @returns the camera inputs manager
  39296. */
  39297. addGamepad(): ArcRotateCameraInputsManager;
  39298. }
  39299. /**
  39300. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39301. */
  39302. export class GamepadSystemSceneComponent implements ISceneComponent {
  39303. /**
  39304. * The component name helpfull to identify the component in the list of scene components.
  39305. */
  39306. readonly name: string;
  39307. /**
  39308. * The scene the component belongs to.
  39309. */
  39310. scene: Scene;
  39311. /**
  39312. * Creates a new instance of the component for the given scene
  39313. * @param scene Defines the scene to register the component in
  39314. */
  39315. constructor(scene: Scene);
  39316. /**
  39317. * Registers the component in a given scene
  39318. */
  39319. register(): void;
  39320. /**
  39321. * Rebuilds the elements related to this component in case of
  39322. * context lost for instance.
  39323. */
  39324. rebuild(): void;
  39325. /**
  39326. * Disposes the component and the associated ressources
  39327. */
  39328. dispose(): void;
  39329. private _beforeCameraUpdate;
  39330. }
  39331. }
  39332. declare module BABYLON {
  39333. /**
  39334. * Options to modify the vr teleportation behavior.
  39335. */
  39336. export interface VRTeleportationOptions {
  39337. /**
  39338. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39339. */
  39340. floorMeshName?: string;
  39341. /**
  39342. * A list of meshes to be used as the teleportation floor. (default: empty)
  39343. */
  39344. floorMeshes?: Mesh[];
  39345. }
  39346. /**
  39347. * Options to modify the vr experience helper's behavior.
  39348. */
  39349. export interface VRExperienceHelperOptions extends WebVROptions {
  39350. /**
  39351. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39352. */
  39353. createDeviceOrientationCamera?: boolean;
  39354. /**
  39355. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39356. */
  39357. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39358. /**
  39359. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39360. */
  39361. laserToggle?: boolean;
  39362. /**
  39363. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39364. */
  39365. floorMeshes?: Mesh[];
  39366. /**
  39367. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39368. */
  39369. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39370. }
  39371. /**
  39372. * Event containing information after VR has been entered
  39373. */
  39374. export class OnAfterEnteringVRObservableEvent {
  39375. /**
  39376. * If entering vr was successful
  39377. */
  39378. success: boolean;
  39379. }
  39380. /**
  39381. * Helps to quickly add VR support to an existing scene.
  39382. * See http://doc.babylonjs.com/how_to/webvr_helper
  39383. */
  39384. export class VRExperienceHelper {
  39385. /** Options to modify the vr experience helper's behavior. */
  39386. webVROptions: VRExperienceHelperOptions;
  39387. private _scene;
  39388. private _position;
  39389. private _btnVR;
  39390. private _btnVRDisplayed;
  39391. private _webVRsupported;
  39392. private _webVRready;
  39393. private _webVRrequesting;
  39394. private _webVRpresenting;
  39395. private _hasEnteredVR;
  39396. private _fullscreenVRpresenting;
  39397. private _canvas;
  39398. private _webVRCamera;
  39399. private _vrDeviceOrientationCamera;
  39400. private _deviceOrientationCamera;
  39401. private _existingCamera;
  39402. private _onKeyDown;
  39403. private _onVrDisplayPresentChange;
  39404. private _onVRDisplayChanged;
  39405. private _onVRRequestPresentStart;
  39406. private _onVRRequestPresentComplete;
  39407. /**
  39408. * Observable raised right before entering VR.
  39409. */
  39410. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39411. /**
  39412. * Observable raised when entering VR has completed.
  39413. */
  39414. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39415. /**
  39416. * Observable raised when exiting VR.
  39417. */
  39418. onExitingVRObservable: Observable<VRExperienceHelper>;
  39419. /**
  39420. * Observable raised when controller mesh is loaded.
  39421. */
  39422. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39423. /** Return this.onEnteringVRObservable
  39424. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39425. */
  39426. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39427. /** Return this.onExitingVRObservable
  39428. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39429. */
  39430. readonly onExitingVR: Observable<VRExperienceHelper>;
  39431. /** Return this.onControllerMeshLoadedObservable
  39432. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39433. */
  39434. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39435. private _rayLength;
  39436. private _useCustomVRButton;
  39437. private _teleportationRequested;
  39438. private _teleportActive;
  39439. private _floorMeshName;
  39440. private _floorMeshesCollection;
  39441. private _rotationAllowed;
  39442. private _teleportBackwardsVector;
  39443. private _teleportationTarget;
  39444. private _isDefaultTeleportationTarget;
  39445. private _postProcessMove;
  39446. private _teleportationFillColor;
  39447. private _teleportationBorderColor;
  39448. private _rotationAngle;
  39449. private _haloCenter;
  39450. private _cameraGazer;
  39451. private _padSensibilityUp;
  39452. private _padSensibilityDown;
  39453. private _leftController;
  39454. private _rightController;
  39455. /**
  39456. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39457. */
  39458. onNewMeshSelected: Observable<AbstractMesh>;
  39459. /**
  39460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39461. */
  39462. onNewMeshPicked: Observable<PickingInfo>;
  39463. private _circleEase;
  39464. /**
  39465. * Observable raised before camera teleportation
  39466. */
  39467. onBeforeCameraTeleport: Observable<Vector3>;
  39468. /**
  39469. * Observable raised after camera teleportation
  39470. */
  39471. onAfterCameraTeleport: Observable<Vector3>;
  39472. /**
  39473. * Observable raised when current selected mesh gets unselected
  39474. */
  39475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39476. private _raySelectionPredicate;
  39477. /**
  39478. * To be optionaly changed by user to define custom ray selection
  39479. */
  39480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39481. /**
  39482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39483. */
  39484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39485. /**
  39486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39487. */
  39488. teleportationEnabled: boolean;
  39489. private _defaultHeight;
  39490. private _teleportationInitialized;
  39491. private _interactionsEnabled;
  39492. private _interactionsRequested;
  39493. private _displayGaze;
  39494. private _displayLaserPointer;
  39495. /**
  39496. * The mesh used to display where the user is going to teleport.
  39497. */
  39498. /**
  39499. * Sets the mesh to be used to display where the user is going to teleport.
  39500. */
  39501. teleportationTarget: Mesh;
  39502. /**
  39503. * 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
  39504. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39505. * See http://doc.babylonjs.com/resources/baking_transformations
  39506. */
  39507. gazeTrackerMesh: Mesh;
  39508. /**
  39509. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39510. */
  39511. updateGazeTrackerScale: boolean;
  39512. /**
  39513. * If the gaze trackers color should be updated when selecting meshes
  39514. */
  39515. updateGazeTrackerColor: boolean;
  39516. /**
  39517. * The gaze tracking mesh corresponding to the left controller
  39518. */
  39519. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39520. /**
  39521. * The gaze tracking mesh corresponding to the right controller
  39522. */
  39523. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39524. /**
  39525. * If the ray of the gaze should be displayed.
  39526. */
  39527. /**
  39528. * Sets if the ray of the gaze should be displayed.
  39529. */
  39530. displayGaze: boolean;
  39531. /**
  39532. * If the ray of the LaserPointer should be displayed.
  39533. */
  39534. /**
  39535. * Sets if the ray of the LaserPointer should be displayed.
  39536. */
  39537. displayLaserPointer: boolean;
  39538. /**
  39539. * The deviceOrientationCamera used as the camera when not in VR.
  39540. */
  39541. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39542. /**
  39543. * Based on the current WebVR support, returns the current VR camera used.
  39544. */
  39545. readonly currentVRCamera: Nullable<Camera>;
  39546. /**
  39547. * The webVRCamera which is used when in VR.
  39548. */
  39549. readonly webVRCamera: WebVRFreeCamera;
  39550. /**
  39551. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39552. */
  39553. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39554. private readonly _teleportationRequestInitiated;
  39555. /**
  39556. * Defines wether or not Pointer lock should be requested when switching to
  39557. * full screen.
  39558. */
  39559. requestPointerLockOnFullScreen: boolean;
  39560. /**
  39561. * Instantiates a VRExperienceHelper.
  39562. * Helps to quickly add VR support to an existing scene.
  39563. * @param scene The scene the VRExperienceHelper belongs to.
  39564. * @param webVROptions Options to modify the vr experience helper's behavior.
  39565. */
  39566. constructor(scene: Scene,
  39567. /** Options to modify the vr experience helper's behavior. */
  39568. webVROptions?: VRExperienceHelperOptions);
  39569. private _onDefaultMeshLoaded;
  39570. private _onResize;
  39571. private _onFullscreenChange;
  39572. /**
  39573. * Gets a value indicating if we are currently in VR mode.
  39574. */
  39575. readonly isInVRMode: boolean;
  39576. private onVrDisplayPresentChange;
  39577. private onVRDisplayChanged;
  39578. private moveButtonToBottomRight;
  39579. private displayVRButton;
  39580. private updateButtonVisibility;
  39581. private _cachedAngularSensibility;
  39582. /**
  39583. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39584. * Otherwise, will use the fullscreen API.
  39585. */
  39586. enterVR(): void;
  39587. /**
  39588. * Attempt to exit VR, or fullscreen.
  39589. */
  39590. exitVR(): void;
  39591. /**
  39592. * The position of the vr experience helper.
  39593. */
  39594. /**
  39595. * Sets the position of the vr experience helper.
  39596. */
  39597. position: Vector3;
  39598. /**
  39599. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39600. */
  39601. enableInteractions(): void;
  39602. private readonly _noControllerIsActive;
  39603. private beforeRender;
  39604. private _isTeleportationFloor;
  39605. /**
  39606. * Adds a floor mesh to be used for teleportation.
  39607. * @param floorMesh the mesh to be used for teleportation.
  39608. */
  39609. addFloorMesh(floorMesh: Mesh): void;
  39610. /**
  39611. * Removes a floor mesh from being used for teleportation.
  39612. * @param floorMesh the mesh to be removed.
  39613. */
  39614. removeFloorMesh(floorMesh: Mesh): void;
  39615. /**
  39616. * Enables interactions and teleportation using the VR controllers and gaze.
  39617. * @param vrTeleportationOptions options to modify teleportation behavior.
  39618. */
  39619. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39620. private _onNewGamepadConnected;
  39621. private _tryEnableInteractionOnController;
  39622. private _onNewGamepadDisconnected;
  39623. private _enableInteractionOnController;
  39624. private _checkTeleportWithRay;
  39625. private _checkRotate;
  39626. private _checkTeleportBackwards;
  39627. private _enableTeleportationOnController;
  39628. private _createTeleportationCircles;
  39629. private _displayTeleportationTarget;
  39630. private _hideTeleportationTarget;
  39631. private _rotateCamera;
  39632. private _moveTeleportationSelectorTo;
  39633. private _workingVector;
  39634. private _workingQuaternion;
  39635. private _workingMatrix;
  39636. /**
  39637. * Teleports the users feet to the desired location
  39638. * @param location The location where the user's feet should be placed
  39639. */
  39640. teleportCamera(location: Vector3): void;
  39641. private _convertNormalToDirectionOfRay;
  39642. private _castRayAndSelectObject;
  39643. private _notifySelectedMeshUnselected;
  39644. /**
  39645. * Sets the color of the laser ray from the vr controllers.
  39646. * @param color new color for the ray.
  39647. */
  39648. changeLaserColor(color: Color3): void;
  39649. /**
  39650. * Sets the color of the ray from the vr headsets gaze.
  39651. * @param color new color for the ray.
  39652. */
  39653. changeGazeColor(color: Color3): void;
  39654. /**
  39655. * Exits VR and disposes of the vr experience helper
  39656. */
  39657. dispose(): void;
  39658. /**
  39659. * Gets the name of the VRExperienceHelper class
  39660. * @returns "VRExperienceHelper"
  39661. */
  39662. getClassName(): string;
  39663. }
  39664. }
  39665. declare module BABYLON {
  39666. /**
  39667. * Manages an XRSession
  39668. * @see https://doc.babylonjs.com/how_to/webxr
  39669. */
  39670. export class WebXRSessionManager implements IDisposable {
  39671. private scene;
  39672. /**
  39673. * Fires every time a new xrFrame arrives which can be used to update the camera
  39674. */
  39675. onXRFrameObservable: Observable<any>;
  39676. /**
  39677. * Fires when the xr session is ended either by the device or manually done
  39678. */
  39679. onXRSessionEnded: Observable<any>;
  39680. /** @hidden */
  39681. _xrSession: XRSession;
  39682. /** @hidden */
  39683. _frameOfReference: XRFrameOfReference;
  39684. /** @hidden */
  39685. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39686. /** @hidden */
  39687. _currentXRFrame: Nullable<XRFrame>;
  39688. private _xrNavigator;
  39689. private _xrDevice;
  39690. private _tmpMatrix;
  39691. /**
  39692. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39693. * @param scene The scene which the session should be created for
  39694. */
  39695. constructor(scene: Scene);
  39696. /**
  39697. * Initializes the manager
  39698. * After initialization enterXR can be called to start an XR session
  39699. * @returns Promise which resolves after it is initialized
  39700. */
  39701. initializeAsync(): Promise<void>;
  39702. /**
  39703. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39704. * @param sessionCreationOptions xr options to create the session with
  39705. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39706. * @returns Promise which resolves after it enters XR
  39707. */
  39708. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39709. /**
  39710. * Stops the xrSession and restores the renderloop
  39711. * @returns Promise which resolves after it exits XR
  39712. */
  39713. exitXRAsync(): Promise<void>;
  39714. /**
  39715. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39716. * @param ray ray to cast into the environment
  39717. * @returns Promise which resolves with a collision point in the environment if it exists
  39718. */
  39719. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39720. /**
  39721. * Checks if a session would be supported for the creation options specified
  39722. * @param options creation options to check if they are supported
  39723. * @returns true if supported
  39724. */
  39725. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39726. /**
  39727. * @hidden
  39728. * Converts the render layer of xrSession to a render target
  39729. * @param session session to create render target for
  39730. * @param scene scene the new render target should be created for
  39731. */
  39732. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39733. /**
  39734. * Disposes of the session manager
  39735. */
  39736. dispose(): void;
  39737. }
  39738. }
  39739. declare module BABYLON {
  39740. /**
  39741. * WebXR Camera which holds the views for the xrSession
  39742. * @see https://doc.babylonjs.com/how_to/webxr
  39743. */
  39744. export class WebXRCamera extends FreeCamera {
  39745. private static _TmpMatrix;
  39746. /**
  39747. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39748. * @param name the name of the camera
  39749. * @param scene the scene to add the camera to
  39750. */
  39751. constructor(name: string, scene: Scene);
  39752. private _updateNumberOfRigCameras;
  39753. /** @hidden */
  39754. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39755. /**
  39756. * Updates the cameras position from the current pose information of the XR session
  39757. * @param xrSessionManager the session containing pose information
  39758. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39759. */
  39760. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39761. }
  39762. }
  39763. declare module BABYLON {
  39764. /**
  39765. * States of the webXR experience
  39766. */
  39767. export enum WebXRState {
  39768. /**
  39769. * Transitioning to being in XR mode
  39770. */
  39771. ENTERING_XR = 0,
  39772. /**
  39773. * Transitioning to non XR mode
  39774. */
  39775. EXITING_XR = 1,
  39776. /**
  39777. * In XR mode and presenting
  39778. */
  39779. IN_XR = 2,
  39780. /**
  39781. * Not entered XR mode
  39782. */
  39783. NOT_IN_XR = 3
  39784. }
  39785. /**
  39786. * Helper class used to enable XR
  39787. * @see https://doc.babylonjs.com/how_to/webxr
  39788. */
  39789. export class WebXRExperienceHelper implements IDisposable {
  39790. private scene;
  39791. /**
  39792. * 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
  39793. */
  39794. container: AbstractMesh;
  39795. /**
  39796. * Camera used to render xr content
  39797. */
  39798. camera: WebXRCamera;
  39799. /**
  39800. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39801. */
  39802. state: WebXRState;
  39803. private _setState;
  39804. private static _TmpVector;
  39805. /**
  39806. * Fires when the state of the experience helper has changed
  39807. */
  39808. onStateChangedObservable: Observable<WebXRState>;
  39809. /** @hidden */
  39810. _sessionManager: WebXRSessionManager;
  39811. private _nonVRCamera;
  39812. private _originalSceneAutoClear;
  39813. private _supported;
  39814. /**
  39815. * Creates the experience helper
  39816. * @param scene the scene to attach the experience helper to
  39817. * @returns a promise for the experience helper
  39818. */
  39819. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39820. /**
  39821. * Creates a WebXRExperienceHelper
  39822. * @param scene The scene the helper should be created in
  39823. */
  39824. private constructor();
  39825. /**
  39826. * Exits XR mode and returns the scene to its original state
  39827. * @returns promise that resolves after xr mode has exited
  39828. */
  39829. exitXRAsync(): Promise<void>;
  39830. /**
  39831. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39832. * @param sessionCreationOptions options for the XR session
  39833. * @param frameOfReference frame of reference of the XR session
  39834. * @returns promise that resolves after xr mode has entered
  39835. */
  39836. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39837. /**
  39838. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39839. * @param ray ray to cast into the environment
  39840. * @returns Promise which resolves with a collision point in the environment if it exists
  39841. */
  39842. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39843. /**
  39844. * Updates the global position of the camera by moving the camera's container
  39845. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39846. * @param position The desired global position of the camera
  39847. */
  39848. setPositionOfCameraUsingContainer(position: Vector3): void;
  39849. /**
  39850. * Rotates the xr camera by rotating the camera's container around the camera's position
  39851. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39852. * @param rotation the desired quaternion rotation to apply to the camera
  39853. */
  39854. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39855. /**
  39856. * Checks if the creation options are supported by the xr session
  39857. * @param options creation options
  39858. * @returns true if supported
  39859. */
  39860. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39861. /**
  39862. * Disposes of the experience helper
  39863. */
  39864. dispose(): void;
  39865. }
  39866. }
  39867. declare module BABYLON {
  39868. /**
  39869. * Button which can be used to enter a different mode of XR
  39870. */
  39871. export class WebXREnterExitUIButton {
  39872. /** button element */
  39873. element: HTMLElement;
  39874. /** XR initialization options for the button */
  39875. initializationOptions: XRSessionCreationOptions;
  39876. /**
  39877. * Creates a WebXREnterExitUIButton
  39878. * @param element button element
  39879. * @param initializationOptions XR initialization options for the button
  39880. */
  39881. constructor(
  39882. /** button element */
  39883. element: HTMLElement,
  39884. /** XR initialization options for the button */
  39885. initializationOptions: XRSessionCreationOptions);
  39886. /**
  39887. * Overwritable function which can be used to update the button's visuals when the state changes
  39888. * @param activeButton the current active button in the UI
  39889. */
  39890. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39891. }
  39892. /**
  39893. * Options to create the webXR UI
  39894. */
  39895. export class WebXREnterExitUIOptions {
  39896. /**
  39897. * Context to enter xr with
  39898. */
  39899. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39900. /**
  39901. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39902. */
  39903. customButtons?: Array<WebXREnterExitUIButton>;
  39904. }
  39905. /**
  39906. * UI to allow the user to enter/exit XR mode
  39907. */
  39908. export class WebXREnterExitUI implements IDisposable {
  39909. private scene;
  39910. private _overlay;
  39911. private _buttons;
  39912. private _activeButton;
  39913. /**
  39914. * Fired every time the active button is changed.
  39915. *
  39916. * When xr is entered via a button that launches xr that button will be the callback parameter
  39917. *
  39918. * When exiting xr the callback parameter will be null)
  39919. */
  39920. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39921. /**
  39922. * Creates UI to allow the user to enter/exit XR mode
  39923. * @param scene the scene to add the ui to
  39924. * @param helper the xr experience helper to enter/exit xr with
  39925. * @param options options to configure the UI
  39926. * @returns the created ui
  39927. */
  39928. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39929. private constructor();
  39930. private _updateButtons;
  39931. /**
  39932. * Disposes of the object
  39933. */
  39934. dispose(): void;
  39935. }
  39936. }
  39937. declare module BABYLON {
  39938. /**
  39939. * Represents an XR input
  39940. */
  39941. export class WebXRController {
  39942. /**
  39943. * 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
  39944. */
  39945. grip?: AbstractMesh;
  39946. /**
  39947. * Pointer which can be used to select objects or attach a visible laser to
  39948. */
  39949. pointer: AbstractMesh;
  39950. /**
  39951. * Creates the controller
  39952. * @see https://doc.babylonjs.com/how_to/webxr
  39953. * @param scene the scene which the controller should be associated to
  39954. */
  39955. constructor(scene: Scene);
  39956. /**
  39957. * Disposes of the object
  39958. */
  39959. dispose(): void;
  39960. }
  39961. /**
  39962. * XR input used to track XR inputs such as controllers/rays
  39963. */
  39964. export class WebXRInput implements IDisposable {
  39965. private helper;
  39966. /**
  39967. * XR controllers being tracked
  39968. */
  39969. controllers: Array<WebXRController>;
  39970. private _tmpMatrix;
  39971. private _frameObserver;
  39972. /**
  39973. * Initializes the WebXRInput
  39974. * @param helper experience helper which the input should be created for
  39975. */
  39976. constructor(helper: WebXRExperienceHelper);
  39977. /**
  39978. * Disposes of the object
  39979. */
  39980. dispose(): void;
  39981. }
  39982. }
  39983. declare module BABYLON {
  39984. /**
  39985. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39986. */
  39987. export class WebXRManagedOutputCanvas implements IDisposable {
  39988. private _canvas;
  39989. /**
  39990. * xrpresent context of the canvas which can be used to display/mirror xr content
  39991. */
  39992. canvasContext: Nullable<WebGLRenderingContext>;
  39993. /**
  39994. * Initializes the canvas to be added/removed upon entering/exiting xr
  39995. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39996. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39997. */
  39998. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39999. /**
  40000. * Disposes of the object
  40001. */
  40002. dispose(): void;
  40003. private _setManagedOutputCanvas;
  40004. private _addCanvas;
  40005. private _removeCanvas;
  40006. }
  40007. }
  40008. declare module BABYLON {
  40009. /**
  40010. * Contains an array of blocks representing the octree
  40011. */
  40012. export interface IOctreeContainer<T> {
  40013. /**
  40014. * Blocks within the octree
  40015. */
  40016. blocks: Array<OctreeBlock<T>>;
  40017. }
  40018. /**
  40019. * Class used to store a cell in an octree
  40020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40021. */
  40022. export class OctreeBlock<T> {
  40023. /**
  40024. * Gets the content of the current block
  40025. */
  40026. entries: T[];
  40027. /**
  40028. * Gets the list of block children
  40029. */
  40030. blocks: Array<OctreeBlock<T>>;
  40031. private _depth;
  40032. private _maxDepth;
  40033. private _capacity;
  40034. private _minPoint;
  40035. private _maxPoint;
  40036. private _boundingVectors;
  40037. private _creationFunc;
  40038. /**
  40039. * Creates a new block
  40040. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40041. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40042. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40043. * @param depth defines the current depth of this block in the octree
  40044. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40045. * @param creationFunc defines a callback to call when an element is added to the block
  40046. */
  40047. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40048. /**
  40049. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40050. */
  40051. readonly capacity: number;
  40052. /**
  40053. * Gets the minimum vector (in world space) of the block's bounding box
  40054. */
  40055. readonly minPoint: Vector3;
  40056. /**
  40057. * Gets the maximum vector (in world space) of the block's bounding box
  40058. */
  40059. readonly maxPoint: Vector3;
  40060. /**
  40061. * Add a new element to this block
  40062. * @param entry defines the element to add
  40063. */
  40064. addEntry(entry: T): void;
  40065. /**
  40066. * Remove an element from this block
  40067. * @param entry defines the element to remove
  40068. */
  40069. removeEntry(entry: T): void;
  40070. /**
  40071. * Add an array of elements to this block
  40072. * @param entries defines the array of elements to add
  40073. */
  40074. addEntries(entries: T[]): void;
  40075. /**
  40076. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40077. * @param frustumPlanes defines the frustum planes to test
  40078. * @param selection defines the array to store current content if selection is positive
  40079. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40080. */
  40081. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40082. /**
  40083. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40084. * @param sphereCenter defines the bounding sphere center
  40085. * @param sphereRadius defines the bounding sphere radius
  40086. * @param selection defines the array to store current content if selection is positive
  40087. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40088. */
  40089. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40090. /**
  40091. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40092. * @param ray defines the ray to test with
  40093. * @param selection defines the array to store current content if selection is positive
  40094. */
  40095. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40096. /**
  40097. * Subdivide the content into child blocks (this block will then be empty)
  40098. */
  40099. createInnerBlocks(): void;
  40100. /**
  40101. * @hidden
  40102. */
  40103. 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;
  40104. }
  40105. }
  40106. declare module BABYLON {
  40107. /**
  40108. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40109. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40110. */
  40111. export class Octree<T> {
  40112. /** 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.) */
  40113. maxDepth: number;
  40114. /**
  40115. * Blocks within the octree containing objects
  40116. */
  40117. blocks: Array<OctreeBlock<T>>;
  40118. /**
  40119. * Content stored in the octree
  40120. */
  40121. dynamicContent: T[];
  40122. private _maxBlockCapacity;
  40123. private _selectionContent;
  40124. private _creationFunc;
  40125. /**
  40126. * Creates a octree
  40127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40128. * @param creationFunc function to be used to instatiate the octree
  40129. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40130. * @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.)
  40131. */
  40132. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40133. /** 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.) */
  40134. maxDepth?: number);
  40135. /**
  40136. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40137. * @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);
  40138. * @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);
  40139. * @param entries meshes to be added to the octree blocks
  40140. */
  40141. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40142. /**
  40143. * Adds a mesh to the octree
  40144. * @param entry Mesh to add to the octree
  40145. */
  40146. addMesh(entry: T): void;
  40147. /**
  40148. * Remove an element from the octree
  40149. * @param entry defines the element to remove
  40150. */
  40151. removeMesh(entry: T): void;
  40152. /**
  40153. * Selects an array of meshes within the frustum
  40154. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40155. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40156. * @returns array of meshes within the frustum
  40157. */
  40158. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40159. /**
  40160. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40161. * @param sphereCenter defines the bounding sphere center
  40162. * @param sphereRadius defines the bounding sphere radius
  40163. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40164. * @returns an array of objects that intersect the sphere
  40165. */
  40166. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40167. /**
  40168. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40169. * @param ray defines the ray to test with
  40170. * @returns array of intersected objects
  40171. */
  40172. intersectsRay(ray: Ray): SmartArray<T>;
  40173. /**
  40174. * Adds a mesh into the octree block if it intersects the block
  40175. */
  40176. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40177. /**
  40178. * Adds a submesh into the octree block if it intersects the block
  40179. */
  40180. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. interface Scene {
  40185. /**
  40186. * @hidden
  40187. * Backing Filed
  40188. */
  40189. _selectionOctree: Octree<AbstractMesh>;
  40190. /**
  40191. * Gets the octree used to boost mesh selection (picking)
  40192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40193. */
  40194. selectionOctree: Octree<AbstractMesh>;
  40195. /**
  40196. * Creates or updates the octree used to boost selection (picking)
  40197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40198. * @param maxCapacity defines the maximum capacity per leaf
  40199. * @param maxDepth defines the maximum depth of the octree
  40200. * @returns an octree of AbstractMesh
  40201. */
  40202. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40203. }
  40204. interface AbstractMesh {
  40205. /**
  40206. * @hidden
  40207. * Backing Field
  40208. */
  40209. _submeshesOctree: Octree<SubMesh>;
  40210. /**
  40211. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40212. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40213. * @param maxCapacity defines the maximum size of each block (64 by default)
  40214. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40215. * @returns the new octree
  40216. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40218. */
  40219. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40220. }
  40221. /**
  40222. * Defines the octree scene component responsible to manage any octrees
  40223. * in a given scene.
  40224. */
  40225. export class OctreeSceneComponent {
  40226. /**
  40227. * The component name helpfull to identify the component in the list of scene components.
  40228. */
  40229. readonly name: string;
  40230. /**
  40231. * The scene the component belongs to.
  40232. */
  40233. scene: Scene;
  40234. /**
  40235. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40236. */
  40237. readonly checksIsEnabled: boolean;
  40238. /**
  40239. * Creates a new instance of the component for the given scene
  40240. * @param scene Defines the scene to register the component in
  40241. */
  40242. constructor(scene: Scene);
  40243. /**
  40244. * Registers the component in a given scene
  40245. */
  40246. register(): void;
  40247. /**
  40248. * Return the list of active meshes
  40249. * @returns the list of active meshes
  40250. */
  40251. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40252. /**
  40253. * Return the list of active sub meshes
  40254. * @param mesh The mesh to get the candidates sub meshes from
  40255. * @returns the list of active sub meshes
  40256. */
  40257. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40258. private _tempRay;
  40259. /**
  40260. * Return the list of sub meshes intersecting with a given local ray
  40261. * @param mesh defines the mesh to find the submesh for
  40262. * @param localRay defines the ray in local space
  40263. * @returns the list of intersecting sub meshes
  40264. */
  40265. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40266. /**
  40267. * Return the list of sub meshes colliding with a collider
  40268. * @param mesh defines the mesh to find the submesh for
  40269. * @param collider defines the collider to evaluate the collision against
  40270. * @returns the list of colliding sub meshes
  40271. */
  40272. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40273. /**
  40274. * Rebuilds the elements related to this component in case of
  40275. * context lost for instance.
  40276. */
  40277. rebuild(): void;
  40278. /**
  40279. * Disposes the component and the associated ressources.
  40280. */
  40281. dispose(): void;
  40282. }
  40283. }
  40284. declare module BABYLON {
  40285. /**
  40286. * Renders a layer on top of an existing scene
  40287. */
  40288. export class UtilityLayerRenderer implements IDisposable {
  40289. /** the original scene that will be rendered on top of */
  40290. originalScene: Scene;
  40291. private _pointerCaptures;
  40292. private _lastPointerEvents;
  40293. private static _DefaultUtilityLayer;
  40294. private static _DefaultKeepDepthUtilityLayer;
  40295. private _sharedGizmoLight;
  40296. /**
  40297. * @hidden
  40298. * Light which used by gizmos to get light shading
  40299. */
  40300. _getSharedGizmoLight(): HemisphericLight;
  40301. /**
  40302. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40303. */
  40304. pickUtilitySceneFirst: boolean;
  40305. /**
  40306. * 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)
  40307. */
  40308. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40309. /**
  40310. * 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)
  40311. */
  40312. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40313. /**
  40314. * The scene that is rendered on top of the original scene
  40315. */
  40316. utilityLayerScene: Scene;
  40317. /**
  40318. * If the utility layer should automatically be rendered on top of existing scene
  40319. */
  40320. shouldRender: boolean;
  40321. /**
  40322. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40323. */
  40324. onlyCheckPointerDownEvents: boolean;
  40325. /**
  40326. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40327. */
  40328. processAllEvents: boolean;
  40329. /**
  40330. * Observable raised when the pointer move from the utility layer scene to the main scene
  40331. */
  40332. onPointerOutObservable: Observable<number>;
  40333. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40334. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40335. private _afterRenderObserver;
  40336. private _sceneDisposeObserver;
  40337. private _originalPointerObserver;
  40338. /**
  40339. * Instantiates a UtilityLayerRenderer
  40340. * @param originalScene the original scene that will be rendered on top of
  40341. * @param handleEvents boolean indicating if the utility layer should handle events
  40342. */
  40343. constructor(
  40344. /** the original scene that will be rendered on top of */
  40345. originalScene: Scene, handleEvents?: boolean);
  40346. private _notifyObservers;
  40347. /**
  40348. * Renders the utility layers scene on top of the original scene
  40349. */
  40350. render(): void;
  40351. /**
  40352. * Disposes of the renderer
  40353. */
  40354. dispose(): void;
  40355. private _updateCamera;
  40356. }
  40357. }
  40358. declare module BABYLON {
  40359. /**
  40360. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40361. */
  40362. export class Gizmo implements IDisposable {
  40363. /** The utility layer the gizmo will be added to */
  40364. gizmoLayer: UtilityLayerRenderer;
  40365. /**
  40366. * The root mesh of the gizmo
  40367. */
  40368. _rootMesh: Mesh;
  40369. private _attachedMesh;
  40370. /**
  40371. * Ratio for the scale of the gizmo (Default: 1)
  40372. */
  40373. scaleRatio: number;
  40374. private _tmpMatrix;
  40375. /**
  40376. * If a custom mesh has been set (Default: false)
  40377. */
  40378. protected _customMeshSet: boolean;
  40379. /**
  40380. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40381. * * When set, interactions will be enabled
  40382. */
  40383. attachedMesh: Nullable<AbstractMesh>;
  40384. /**
  40385. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40386. * @param mesh The mesh to replace the default mesh of the gizmo
  40387. */
  40388. setCustomMesh(mesh: Mesh): void;
  40389. /**
  40390. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40391. */
  40392. updateGizmoRotationToMatchAttachedMesh: boolean;
  40393. /**
  40394. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40395. */
  40396. updateGizmoPositionToMatchAttachedMesh: boolean;
  40397. /**
  40398. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40399. */
  40400. protected _updateScale: boolean;
  40401. protected _interactionsEnabled: boolean;
  40402. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40403. private _beforeRenderObserver;
  40404. /**
  40405. * Creates a gizmo
  40406. * @param gizmoLayer The utility layer the gizmo will be added to
  40407. */
  40408. constructor(
  40409. /** The utility layer the gizmo will be added to */
  40410. gizmoLayer?: UtilityLayerRenderer);
  40411. private _tempVector;
  40412. /**
  40413. * @hidden
  40414. * Updates the gizmo to match the attached mesh's position/rotation
  40415. */
  40416. protected _update(): void;
  40417. /**
  40418. * Disposes of the gizmo
  40419. */
  40420. dispose(): void;
  40421. }
  40422. }
  40423. declare module BABYLON {
  40424. /**
  40425. * Single axis drag gizmo
  40426. */
  40427. export class AxisDragGizmo extends Gizmo {
  40428. /**
  40429. * Drag behavior responsible for the gizmos dragging interactions
  40430. */
  40431. dragBehavior: PointerDragBehavior;
  40432. private _pointerObserver;
  40433. /**
  40434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40435. */
  40436. snapDistance: number;
  40437. /**
  40438. * Event that fires each time the gizmo snaps to a new location.
  40439. * * snapDistance is the the change in distance
  40440. */
  40441. onSnapObservable: Observable<{
  40442. snapDistance: number;
  40443. }>;
  40444. /** @hidden */
  40445. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40446. /** @hidden */
  40447. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40448. /**
  40449. * Creates an AxisDragGizmo
  40450. * @param gizmoLayer The utility layer the gizmo will be added to
  40451. * @param dragAxis The axis which the gizmo will be able to drag on
  40452. * @param color The color of the gizmo
  40453. */
  40454. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40455. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40456. /**
  40457. * Disposes of the gizmo
  40458. */
  40459. dispose(): void;
  40460. }
  40461. }
  40462. declare module BABYLON.Debug {
  40463. /**
  40464. * The Axes viewer will show 3 axes in a specific point in space
  40465. */
  40466. export class AxesViewer {
  40467. private _xAxis;
  40468. private _yAxis;
  40469. private _zAxis;
  40470. private _scaleLinesFactor;
  40471. private _instanced;
  40472. /**
  40473. * Gets the hosting scene
  40474. */
  40475. scene: Scene;
  40476. /**
  40477. * Gets or sets a number used to scale line length
  40478. */
  40479. scaleLines: number;
  40480. /** Gets the node hierarchy used to render x-axis */
  40481. readonly xAxis: TransformNode;
  40482. /** Gets the node hierarchy used to render y-axis */
  40483. readonly yAxis: TransformNode;
  40484. /** Gets the node hierarchy used to render z-axis */
  40485. readonly zAxis: TransformNode;
  40486. /**
  40487. * Creates a new AxesViewer
  40488. * @param scene defines the hosting scene
  40489. * @param scaleLines defines a number used to scale line length (1 by default)
  40490. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40491. * @param xAxis defines the node hierarchy used to render the x-axis
  40492. * @param yAxis defines the node hierarchy used to render the y-axis
  40493. * @param zAxis defines the node hierarchy used to render the z-axis
  40494. */
  40495. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40496. /**
  40497. * Force the viewer to update
  40498. * @param position defines the position of the viewer
  40499. * @param xaxis defines the x axis of the viewer
  40500. * @param yaxis defines the y axis of the viewer
  40501. * @param zaxis defines the z axis of the viewer
  40502. */
  40503. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40504. /**
  40505. * Creates an instance of this axes viewer.
  40506. * @returns a new axes viewer with instanced meshes
  40507. */
  40508. createInstance(): AxesViewer;
  40509. /** Releases resources */
  40510. dispose(): void;
  40511. private static _SetRenderingGroupId;
  40512. }
  40513. }
  40514. declare module BABYLON.Debug {
  40515. /**
  40516. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40517. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40518. */
  40519. export class BoneAxesViewer extends AxesViewer {
  40520. /**
  40521. * Gets or sets the target mesh where to display the axes viewer
  40522. */
  40523. mesh: Nullable<Mesh>;
  40524. /**
  40525. * Gets or sets the target bone where to display the axes viewer
  40526. */
  40527. bone: Nullable<Bone>;
  40528. /** Gets current position */
  40529. pos: Vector3;
  40530. /** Gets direction of X axis */
  40531. xaxis: Vector3;
  40532. /** Gets direction of Y axis */
  40533. yaxis: Vector3;
  40534. /** Gets direction of Z axis */
  40535. zaxis: Vector3;
  40536. /**
  40537. * Creates a new BoneAxesViewer
  40538. * @param scene defines the hosting scene
  40539. * @param bone defines the target bone
  40540. * @param mesh defines the target mesh
  40541. * @param scaleLines defines a scaling factor for line length (1 by default)
  40542. */
  40543. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40544. /**
  40545. * Force the viewer to update
  40546. */
  40547. update(): void;
  40548. /** Releases resources */
  40549. dispose(): void;
  40550. }
  40551. }
  40552. declare module BABYLON {
  40553. /**
  40554. * Interface used to define scene explorer extensibility option
  40555. */
  40556. export interface IExplorerExtensibilityOption {
  40557. /**
  40558. * Define the option label
  40559. */
  40560. label: string;
  40561. /**
  40562. * Defines the action to execute on click
  40563. */
  40564. action: (entity: any) => void;
  40565. }
  40566. /**
  40567. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40568. */
  40569. export interface IExplorerExtensibilityGroup {
  40570. /**
  40571. * Defines a predicate to test if a given type mut be extended
  40572. */
  40573. predicate: (entity: any) => boolean;
  40574. /**
  40575. * Gets the list of options added to a type
  40576. */
  40577. entries: IExplorerExtensibilityOption[];
  40578. }
  40579. /**
  40580. * Interface used to define the options to use to create the Inspector
  40581. */
  40582. export interface IInspectorOptions {
  40583. /**
  40584. * Display in overlay mode (default: false)
  40585. */
  40586. overlay?: boolean;
  40587. /**
  40588. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40589. */
  40590. globalRoot?: HTMLElement;
  40591. /**
  40592. * Display the Scene explorer
  40593. */
  40594. showExplorer?: boolean;
  40595. /**
  40596. * Display the property inspector
  40597. */
  40598. showInspector?: boolean;
  40599. /**
  40600. * Display in embed mode (both panes on the right)
  40601. */
  40602. embedMode?: boolean;
  40603. /**
  40604. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40605. */
  40606. handleResize?: boolean;
  40607. /**
  40608. * Allow the panes to popup (default: true)
  40609. */
  40610. enablePopup?: boolean;
  40611. /**
  40612. * Allow the panes to be closed by users (default: true)
  40613. */
  40614. enableClose?: boolean;
  40615. /**
  40616. * Optional list of extensibility entries
  40617. */
  40618. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40619. /**
  40620. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40621. */
  40622. inspectorURL?: string;
  40623. }
  40624. interface Scene {
  40625. /**
  40626. * @hidden
  40627. * Backing field
  40628. */
  40629. _debugLayer: DebugLayer;
  40630. /**
  40631. * Gets the debug layer (aka Inspector) associated with the scene
  40632. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40633. */
  40634. debugLayer: DebugLayer;
  40635. }
  40636. /**
  40637. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40638. * what is happening in your scene
  40639. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40640. */
  40641. export class DebugLayer {
  40642. /**
  40643. * Define the url to get the inspector script from.
  40644. * By default it uses the babylonjs CDN.
  40645. * @ignoreNaming
  40646. */
  40647. static InspectorURL: string;
  40648. private _scene;
  40649. private BJSINSPECTOR;
  40650. /**
  40651. * Observable triggered when a property is changed through the inspector.
  40652. */
  40653. onPropertyChangedObservable: Observable<{
  40654. object: any;
  40655. property: string;
  40656. value: any;
  40657. initialValue: any;
  40658. }>;
  40659. /**
  40660. * Instantiates a new debug layer.
  40661. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40662. * what is happening in your scene
  40663. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40664. * @param scene Defines the scene to inspect
  40665. */
  40666. constructor(scene: Scene);
  40667. /** Creates the inspector window. */
  40668. private _createInspector;
  40669. /**
  40670. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40671. * @param entity defines the entity to select
  40672. * @param lineContainerTitle defines the specific block to highlight
  40673. */
  40674. select(entity: any, lineContainerTitle?: string): void;
  40675. /** Get the inspector from bundle or global */
  40676. private _getGlobalInspector;
  40677. /**
  40678. * Get if the inspector is visible or not.
  40679. * @returns true if visible otherwise, false
  40680. */
  40681. isVisible(): boolean;
  40682. /**
  40683. * Hide the inspector and close its window.
  40684. */
  40685. hide(): void;
  40686. /**
  40687. * Launch the debugLayer.
  40688. * @param config Define the configuration of the inspector
  40689. * @return a promise fulfilled when the debug layer is visible
  40690. */
  40691. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40692. }
  40693. }
  40694. declare module BABYLON {
  40695. /**
  40696. * Class containing static functions to help procedurally build meshes
  40697. */
  40698. export class BoxBuilder {
  40699. /**
  40700. * Creates a box mesh
  40701. * * The parameter `size` sets the size (float) of each box side (default 1)
  40702. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40703. * * 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)
  40704. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40706. * * 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
  40707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40708. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40709. * @param name defines the name of the mesh
  40710. * @param options defines the options used to create the mesh
  40711. * @param scene defines the hosting scene
  40712. * @returns the box mesh
  40713. */
  40714. static CreateBox(name: string, options: {
  40715. size?: number;
  40716. width?: number;
  40717. height?: number;
  40718. depth?: number;
  40719. faceUV?: Vector4[];
  40720. faceColors?: Color4[];
  40721. sideOrientation?: number;
  40722. frontUVs?: Vector4;
  40723. backUVs?: Vector4;
  40724. updatable?: boolean;
  40725. }, scene?: Nullable<Scene>): Mesh;
  40726. }
  40727. }
  40728. declare module BABYLON {
  40729. /**
  40730. * Class containing static functions to help procedurally build meshes
  40731. */
  40732. export class SphereBuilder {
  40733. /**
  40734. * Creates a sphere mesh
  40735. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40736. * * 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`)
  40737. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40738. * * 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
  40739. * * 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)
  40740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40741. * * 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
  40742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40743. * @param name defines the name of the mesh
  40744. * @param options defines the options used to create the mesh
  40745. * @param scene defines the hosting scene
  40746. * @returns the sphere mesh
  40747. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40748. */
  40749. static CreateSphere(name: string, options: {
  40750. segments?: number;
  40751. diameter?: number;
  40752. diameterX?: number;
  40753. diameterY?: number;
  40754. diameterZ?: number;
  40755. arc?: number;
  40756. slice?: number;
  40757. sideOrientation?: number;
  40758. frontUVs?: Vector4;
  40759. backUVs?: Vector4;
  40760. updatable?: boolean;
  40761. }, scene: any): Mesh;
  40762. }
  40763. }
  40764. declare module BABYLON.Debug {
  40765. /**
  40766. * Used to show the physics impostor around the specific mesh
  40767. */
  40768. export class PhysicsViewer {
  40769. /** @hidden */
  40770. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40771. /** @hidden */
  40772. protected _meshes: Array<Nullable<AbstractMesh>>;
  40773. /** @hidden */
  40774. protected _scene: Nullable<Scene>;
  40775. /** @hidden */
  40776. protected _numMeshes: number;
  40777. /** @hidden */
  40778. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40779. private _renderFunction;
  40780. private _utilityLayer;
  40781. private _debugBoxMesh;
  40782. private _debugSphereMesh;
  40783. private _debugMaterial;
  40784. private _debugMeshMeshes;
  40785. /**
  40786. * Creates a new PhysicsViewer
  40787. * @param scene defines the hosting scene
  40788. */
  40789. constructor(scene: Scene);
  40790. /** @hidden */
  40791. protected _updateDebugMeshes(): void;
  40792. /**
  40793. * Renders a specified physic impostor
  40794. * @param impostor defines the impostor to render
  40795. * @param targetMesh defines the mesh represented by the impostor
  40796. * @returns the new debug mesh used to render the impostor
  40797. */
  40798. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40799. /**
  40800. * Hides a specified physic impostor
  40801. * @param impostor defines the impostor to hide
  40802. */
  40803. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40804. private _getDebugMaterial;
  40805. private _getDebugBoxMesh;
  40806. private _getDebugSphereMesh;
  40807. private _getDebugMeshMesh;
  40808. private _getDebugMesh;
  40809. /** Releases all resources */
  40810. dispose(): void;
  40811. }
  40812. }
  40813. declare module BABYLON {
  40814. /**
  40815. * Class containing static functions to help procedurally build meshes
  40816. */
  40817. export class LinesBuilder {
  40818. /**
  40819. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40820. * * 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
  40821. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40822. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40823. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40824. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40825. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40826. * * 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
  40827. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40829. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40830. * @param name defines the name of the new line system
  40831. * @param options defines the options used to create the line system
  40832. * @param scene defines the hosting scene
  40833. * @returns a new line system mesh
  40834. */
  40835. static CreateLineSystem(name: string, options: {
  40836. lines: Vector3[][];
  40837. updatable?: boolean;
  40838. instance?: Nullable<LinesMesh>;
  40839. colors?: Nullable<Color4[][]>;
  40840. useVertexAlpha?: boolean;
  40841. }, scene: Nullable<Scene>): LinesMesh;
  40842. /**
  40843. * Creates a line mesh
  40844. * 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
  40845. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40846. * * The parameter `points` is an array successive Vector3
  40847. * * 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
  40848. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40849. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40850. * * When updating an instance, remember that only point positions can change, not the number of points
  40851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40853. * @param name defines the name of the new line system
  40854. * @param options defines the options used to create the line system
  40855. * @param scene defines the hosting scene
  40856. * @returns a new line mesh
  40857. */
  40858. static CreateLines(name: string, options: {
  40859. points: Vector3[];
  40860. updatable?: boolean;
  40861. instance?: Nullable<LinesMesh>;
  40862. colors?: Color4[];
  40863. useVertexAlpha?: boolean;
  40864. }, scene?: Nullable<Scene>): LinesMesh;
  40865. /**
  40866. * Creates a dashed line mesh
  40867. * * 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
  40868. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40869. * * The parameter `points` is an array successive Vector3
  40870. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40871. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40872. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40873. * * 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
  40874. * * When updating an instance, remember that only point positions can change, not the number of points
  40875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40876. * @param name defines the name of the mesh
  40877. * @param options defines the options used to create the mesh
  40878. * @param scene defines the hosting scene
  40879. * @returns the dashed line mesh
  40880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40881. */
  40882. static CreateDashedLines(name: string, options: {
  40883. points: Vector3[];
  40884. dashSize?: number;
  40885. gapSize?: number;
  40886. dashNb?: number;
  40887. updatable?: boolean;
  40888. instance?: LinesMesh;
  40889. }, scene?: Nullable<Scene>): LinesMesh;
  40890. }
  40891. }
  40892. declare module BABYLON {
  40893. /**
  40894. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40895. * in order to better appreciate the issue one might have.
  40896. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40897. */
  40898. export class RayHelper {
  40899. /**
  40900. * Defines the ray we are currently tryin to visualize.
  40901. */
  40902. ray: Nullable<Ray>;
  40903. private _renderPoints;
  40904. private _renderLine;
  40905. private _renderFunction;
  40906. private _scene;
  40907. private _updateToMeshFunction;
  40908. private _attachedToMesh;
  40909. private _meshSpaceDirection;
  40910. private _meshSpaceOrigin;
  40911. /**
  40912. * Helper function to create a colored helper in a scene in one line.
  40913. * @param ray Defines the ray we are currently tryin to visualize
  40914. * @param scene Defines the scene the ray is used in
  40915. * @param color Defines the color we want to see the ray in
  40916. * @returns The newly created ray helper.
  40917. */
  40918. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40919. /**
  40920. * Instantiate a new ray helper.
  40921. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40922. * in order to better appreciate the issue one might have.
  40923. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40924. * @param ray Defines the ray we are currently tryin to visualize
  40925. */
  40926. constructor(ray: Ray);
  40927. /**
  40928. * Shows the ray we are willing to debug.
  40929. * @param scene Defines the scene the ray needs to be rendered in
  40930. * @param color Defines the color the ray needs to be rendered in
  40931. */
  40932. show(scene: Scene, color?: Color3): void;
  40933. /**
  40934. * Hides the ray we are debugging.
  40935. */
  40936. hide(): void;
  40937. private _render;
  40938. /**
  40939. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40940. * @param mesh Defines the mesh we want the helper attached to
  40941. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40942. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40943. * @param length Defines the length of the ray
  40944. */
  40945. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40946. /**
  40947. * Detach the ray helper from the mesh it has previously been attached to.
  40948. */
  40949. detachFromMesh(): void;
  40950. private _updateToMesh;
  40951. /**
  40952. * Dispose the helper and release its associated resources.
  40953. */
  40954. dispose(): void;
  40955. }
  40956. }
  40957. declare module BABYLON.Debug {
  40958. /**
  40959. * Class used to render a debug view of a given skeleton
  40960. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40961. */
  40962. export class SkeletonViewer {
  40963. /** defines the skeleton to render */
  40964. skeleton: Skeleton;
  40965. /** defines the mesh attached to the skeleton */
  40966. mesh: AbstractMesh;
  40967. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40968. autoUpdateBonesMatrices: boolean;
  40969. /** defines the rendering group id to use with the viewer */
  40970. renderingGroupId: number;
  40971. /** Gets or sets the color used to render the skeleton */
  40972. color: Color3;
  40973. private _scene;
  40974. private _debugLines;
  40975. private _debugMesh;
  40976. private _isEnabled;
  40977. private _renderFunction;
  40978. private _utilityLayer;
  40979. /**
  40980. * Returns the mesh used to render the bones
  40981. */
  40982. readonly debugMesh: Nullable<LinesMesh>;
  40983. /**
  40984. * Creates a new SkeletonViewer
  40985. * @param skeleton defines the skeleton to render
  40986. * @param mesh defines the mesh attached to the skeleton
  40987. * @param scene defines the hosting scene
  40988. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40989. * @param renderingGroupId defines the rendering group id to use with the viewer
  40990. */
  40991. constructor(
  40992. /** defines the skeleton to render */
  40993. skeleton: Skeleton,
  40994. /** defines the mesh attached to the skeleton */
  40995. mesh: AbstractMesh, scene: Scene,
  40996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40997. autoUpdateBonesMatrices?: boolean,
  40998. /** defines the rendering group id to use with the viewer */
  40999. renderingGroupId?: number);
  41000. /** Gets or sets a boolean indicating if the viewer is enabled */
  41001. isEnabled: boolean;
  41002. private _getBonePosition;
  41003. private _getLinesForBonesWithLength;
  41004. private _getLinesForBonesNoLength;
  41005. /** Update the viewer to sync with current skeleton state */
  41006. update(): void;
  41007. /** Release associated resources */
  41008. dispose(): void;
  41009. }
  41010. }
  41011. declare module BABYLON {
  41012. /**
  41013. * Options to create the null engine
  41014. */
  41015. export class NullEngineOptions {
  41016. /**
  41017. * Render width (Default: 512)
  41018. */
  41019. renderWidth: number;
  41020. /**
  41021. * Render height (Default: 256)
  41022. */
  41023. renderHeight: number;
  41024. /**
  41025. * Texture size (Default: 512)
  41026. */
  41027. textureSize: number;
  41028. /**
  41029. * If delta time between frames should be constant
  41030. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41031. */
  41032. deterministicLockstep: boolean;
  41033. /**
  41034. * Maximum about of steps between frames (Default: 4)
  41035. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41036. */
  41037. lockstepMaxSteps: number;
  41038. }
  41039. /**
  41040. * The null engine class provides support for headless version of babylon.js.
  41041. * This can be used in server side scenario or for testing purposes
  41042. */
  41043. export class NullEngine extends Engine {
  41044. private _options;
  41045. /**
  41046. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41047. */
  41048. isDeterministicLockStep(): boolean;
  41049. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41050. getLockstepMaxSteps(): number;
  41051. /**
  41052. * Sets hardware scaling, used to save performance if needed
  41053. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41054. */
  41055. getHardwareScalingLevel(): number;
  41056. constructor(options?: NullEngineOptions);
  41057. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41058. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41059. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41060. getRenderWidth(useScreen?: boolean): number;
  41061. getRenderHeight(useScreen?: boolean): number;
  41062. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41063. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41064. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41065. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41066. bindSamplers(effect: Effect): void;
  41067. enableEffect(effect: Effect): void;
  41068. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41069. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41070. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41071. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41072. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41073. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41074. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41075. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41076. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41077. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41078. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41079. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41080. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41081. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41082. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41083. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41084. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41085. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41086. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41087. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41088. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41089. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41090. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41091. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41092. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41093. bindBuffers(vertexBuffers: {
  41094. [key: string]: VertexBuffer;
  41095. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41096. wipeCaches(bruteForce?: boolean): void;
  41097. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41098. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41099. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41100. /** @hidden */
  41101. _createTexture(): WebGLTexture;
  41102. /** @hidden */
  41103. _releaseTexture(texture: InternalTexture): void;
  41104. 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;
  41105. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41106. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41107. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41108. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41109. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41110. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41111. areAllEffectsReady(): boolean;
  41112. /**
  41113. * @hidden
  41114. * Get the current error code of the webGL context
  41115. * @returns the error code
  41116. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41117. */
  41118. getError(): number;
  41119. /** @hidden */
  41120. _getUnpackAlignement(): number;
  41121. /** @hidden */
  41122. _unpackFlipY(value: boolean): void;
  41123. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41124. /**
  41125. * Updates a dynamic vertex buffer.
  41126. * @param vertexBuffer the vertex buffer to update
  41127. * @param data the data used to update the vertex buffer
  41128. * @param byteOffset the byte offset of the data (optional)
  41129. * @param byteLength the byte length of the data (optional)
  41130. */
  41131. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41132. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41133. /** @hidden */
  41134. _bindTexture(channel: number, texture: InternalTexture): void;
  41135. /** @hidden */
  41136. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41137. releaseEffects(): void;
  41138. displayLoadingUI(): void;
  41139. hideLoadingUI(): void;
  41140. /** @hidden */
  41141. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41142. /** @hidden */
  41143. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41144. /** @hidden */
  41145. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41146. /** @hidden */
  41147. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41148. }
  41149. }
  41150. declare module BABYLON {
  41151. /** @hidden */
  41152. export class _OcclusionDataStorage {
  41153. /** @hidden */
  41154. occlusionInternalRetryCounter: number;
  41155. /** @hidden */
  41156. isOcclusionQueryInProgress: boolean;
  41157. /** @hidden */
  41158. isOccluded: boolean;
  41159. /** @hidden */
  41160. occlusionRetryCount: number;
  41161. /** @hidden */
  41162. occlusionType: number;
  41163. /** @hidden */
  41164. occlusionQueryAlgorithmType: number;
  41165. }
  41166. interface Engine {
  41167. /**
  41168. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41169. * @return the new query
  41170. */
  41171. createQuery(): WebGLQuery;
  41172. /**
  41173. * Delete and release a webGL query
  41174. * @param query defines the query to delete
  41175. * @return the current engine
  41176. */
  41177. deleteQuery(query: WebGLQuery): Engine;
  41178. /**
  41179. * Check if a given query has resolved and got its value
  41180. * @param query defines the query to check
  41181. * @returns true if the query got its value
  41182. */
  41183. isQueryResultAvailable(query: WebGLQuery): boolean;
  41184. /**
  41185. * Gets the value of a given query
  41186. * @param query defines the query to check
  41187. * @returns the value of the query
  41188. */
  41189. getQueryResult(query: WebGLQuery): number;
  41190. /**
  41191. * Initiates an occlusion query
  41192. * @param algorithmType defines the algorithm to use
  41193. * @param query defines the query to use
  41194. * @returns the current engine
  41195. * @see http://doc.babylonjs.com/features/occlusionquery
  41196. */
  41197. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41198. /**
  41199. * Ends an occlusion query
  41200. * @see http://doc.babylonjs.com/features/occlusionquery
  41201. * @param algorithmType defines the algorithm to use
  41202. * @returns the current engine
  41203. */
  41204. endOcclusionQuery(algorithmType: number): Engine;
  41205. /**
  41206. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41207. * Please note that only one query can be issued at a time
  41208. * @returns a time token used to track the time span
  41209. */
  41210. startTimeQuery(): Nullable<_TimeToken>;
  41211. /**
  41212. * Ends a time query
  41213. * @param token defines the token used to measure the time span
  41214. * @returns the time spent (in ns)
  41215. */
  41216. endTimeQuery(token: _TimeToken): int;
  41217. /** @hidden */
  41218. _currentNonTimestampToken: Nullable<_TimeToken>;
  41219. /** @hidden */
  41220. _createTimeQuery(): WebGLQuery;
  41221. /** @hidden */
  41222. _deleteTimeQuery(query: WebGLQuery): void;
  41223. /** @hidden */
  41224. _getGlAlgorithmType(algorithmType: number): number;
  41225. /** @hidden */
  41226. _getTimeQueryResult(query: WebGLQuery): any;
  41227. /** @hidden */
  41228. _getTimeQueryAvailability(query: WebGLQuery): any;
  41229. }
  41230. interface AbstractMesh {
  41231. /**
  41232. * Backing filed
  41233. * @hidden
  41234. */
  41235. __occlusionDataStorage: _OcclusionDataStorage;
  41236. /**
  41237. * Access property
  41238. * @hidden
  41239. */
  41240. _occlusionDataStorage: _OcclusionDataStorage;
  41241. /**
  41242. * 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.
  41243. * The default value is -1 which means don't break the query and wait till the result
  41244. * @see http://doc.babylonjs.com/features/occlusionquery
  41245. */
  41246. occlusionRetryCount: number;
  41247. /**
  41248. * 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:
  41249. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41250. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41251. * * 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.
  41252. * @see http://doc.babylonjs.com/features/occlusionquery
  41253. */
  41254. occlusionType: number;
  41255. /**
  41256. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41257. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41258. * * 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.
  41259. * @see http://doc.babylonjs.com/features/occlusionquery
  41260. */
  41261. occlusionQueryAlgorithmType: number;
  41262. /**
  41263. * 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
  41264. * @see http://doc.babylonjs.com/features/occlusionquery
  41265. */
  41266. isOccluded: boolean;
  41267. /**
  41268. * Flag to check the progress status of the query
  41269. * @see http://doc.babylonjs.com/features/occlusionquery
  41270. */
  41271. isOcclusionQueryInProgress: boolean;
  41272. }
  41273. }
  41274. declare module BABYLON {
  41275. /** @hidden */
  41276. export var _forceTransformFeedbackToBundle: boolean;
  41277. interface Engine {
  41278. /**
  41279. * Creates a webGL transform feedback object
  41280. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41281. * @returns the webGL transform feedback object
  41282. */
  41283. createTransformFeedback(): WebGLTransformFeedback;
  41284. /**
  41285. * Delete a webGL transform feedback object
  41286. * @param value defines the webGL transform feedback object to delete
  41287. */
  41288. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41289. /**
  41290. * Bind a webGL transform feedback object to the webgl context
  41291. * @param value defines the webGL transform feedback object to bind
  41292. */
  41293. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41294. /**
  41295. * Begins a transform feedback operation
  41296. * @param usePoints defines if points or triangles must be used
  41297. */
  41298. beginTransformFeedback(usePoints: boolean): void;
  41299. /**
  41300. * Ends a transform feedback operation
  41301. */
  41302. endTransformFeedback(): void;
  41303. /**
  41304. * Specify the varyings to use with transform feedback
  41305. * @param program defines the associated webGL program
  41306. * @param value defines the list of strings representing the varying names
  41307. */
  41308. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41309. /**
  41310. * Bind a webGL buffer for a transform feedback operation
  41311. * @param value defines the webGL buffer to bind
  41312. */
  41313. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41314. }
  41315. }
  41316. declare module BABYLON {
  41317. /**
  41318. * Gather the list of clipboard event types as constants.
  41319. */
  41320. export class ClipboardEventTypes {
  41321. /**
  41322. * The clipboard event is fired when a copy command is active (pressed).
  41323. */
  41324. static readonly COPY: number;
  41325. /**
  41326. * The clipboard event is fired when a cut command is active (pressed).
  41327. */
  41328. static readonly CUT: number;
  41329. /**
  41330. * The clipboard event is fired when a paste command is active (pressed).
  41331. */
  41332. static readonly PASTE: number;
  41333. }
  41334. /**
  41335. * This class is used to store clipboard related info for the onClipboardObservable event.
  41336. */
  41337. export class ClipboardInfo {
  41338. /**
  41339. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41340. */
  41341. type: number;
  41342. /**
  41343. * Defines the related dom event
  41344. */
  41345. event: ClipboardEvent;
  41346. /**
  41347. *Creates an instance of ClipboardInfo.
  41348. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41349. * @param event Defines the related dom event
  41350. */
  41351. constructor(
  41352. /**
  41353. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41354. */
  41355. type: number,
  41356. /**
  41357. * Defines the related dom event
  41358. */
  41359. event: ClipboardEvent);
  41360. /**
  41361. * Get the clipboard event's type from the keycode.
  41362. * @param keyCode Defines the keyCode for the current keyboard event.
  41363. * @return {number}
  41364. */
  41365. static GetTypeFromCharacter(keyCode: number): number;
  41366. }
  41367. }
  41368. declare module BABYLON {
  41369. /**
  41370. * Class used to represent data loading progression
  41371. */
  41372. export class SceneLoaderProgressEvent {
  41373. /** defines if data length to load can be evaluated */
  41374. readonly lengthComputable: boolean;
  41375. /** defines the loaded data length */
  41376. readonly loaded: number;
  41377. /** defines the data length to load */
  41378. readonly total: number;
  41379. /**
  41380. * Create a new progress event
  41381. * @param lengthComputable defines if data length to load can be evaluated
  41382. * @param loaded defines the loaded data length
  41383. * @param total defines the data length to load
  41384. */
  41385. constructor(
  41386. /** defines if data length to load can be evaluated */
  41387. lengthComputable: boolean,
  41388. /** defines the loaded data length */
  41389. loaded: number,
  41390. /** defines the data length to load */
  41391. total: number);
  41392. /**
  41393. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41394. * @param event defines the source event
  41395. * @returns a new SceneLoaderProgressEvent
  41396. */
  41397. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41398. }
  41399. /**
  41400. * Interface used by SceneLoader plugins to define supported file extensions
  41401. */
  41402. export interface ISceneLoaderPluginExtensions {
  41403. /**
  41404. * Defines the list of supported extensions
  41405. */
  41406. [extension: string]: {
  41407. isBinary: boolean;
  41408. };
  41409. }
  41410. /**
  41411. * Interface used by SceneLoader plugin factory
  41412. */
  41413. export interface ISceneLoaderPluginFactory {
  41414. /**
  41415. * Defines the name of the factory
  41416. */
  41417. name: string;
  41418. /**
  41419. * Function called to create a new plugin
  41420. * @return the new plugin
  41421. */
  41422. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41423. /**
  41424. * Boolean indicating if the plugin can direct load specific data
  41425. */
  41426. canDirectLoad?: (data: string) => boolean;
  41427. }
  41428. /**
  41429. * Interface used to define a SceneLoader plugin
  41430. */
  41431. export interface ISceneLoaderPlugin {
  41432. /**
  41433. * The friendly name of this plugin.
  41434. */
  41435. name: string;
  41436. /**
  41437. * The file extensions supported by this plugin.
  41438. */
  41439. extensions: string | ISceneLoaderPluginExtensions;
  41440. /**
  41441. * Import meshes into a scene.
  41442. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41443. * @param scene The scene to import into
  41444. * @param data The data to import
  41445. * @param rootUrl The root url for scene and resources
  41446. * @param meshes The meshes array to import into
  41447. * @param particleSystems The particle systems array to import into
  41448. * @param skeletons The skeletons array to import into
  41449. * @param onError The callback when import fails
  41450. * @returns True if successful or false otherwise
  41451. */
  41452. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41453. /**
  41454. * Load into a scene.
  41455. * @param scene The scene to load into
  41456. * @param data The data to import
  41457. * @param rootUrl The root url for scene and resources
  41458. * @param onError The callback when import fails
  41459. * @returns true if successful or false otherwise
  41460. */
  41461. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41462. /**
  41463. * The callback that returns true if the data can be directly loaded.
  41464. */
  41465. canDirectLoad?: (data: string) => boolean;
  41466. /**
  41467. * The callback that allows custom handling of the root url based on the response url.
  41468. */
  41469. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41470. /**
  41471. * Load into an asset container.
  41472. * @param scene The scene to load into
  41473. * @param data The data to import
  41474. * @param rootUrl The root url for scene and resources
  41475. * @param onError The callback when import fails
  41476. * @returns The loaded asset container
  41477. */
  41478. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41479. }
  41480. /**
  41481. * Interface used to define an async SceneLoader plugin
  41482. */
  41483. export interface ISceneLoaderPluginAsync {
  41484. /**
  41485. * The friendly name of this plugin.
  41486. */
  41487. name: string;
  41488. /**
  41489. * The file extensions supported by this plugin.
  41490. */
  41491. extensions: string | ISceneLoaderPluginExtensions;
  41492. /**
  41493. * Import meshes into a scene.
  41494. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41495. * @param scene The scene to import into
  41496. * @param data The data to import
  41497. * @param rootUrl The root url for scene and resources
  41498. * @param onProgress The callback when the load progresses
  41499. * @param fileName Defines the name of the file to load
  41500. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41501. */
  41502. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41503. meshes: AbstractMesh[];
  41504. particleSystems: IParticleSystem[];
  41505. skeletons: Skeleton[];
  41506. animationGroups: AnimationGroup[];
  41507. }>;
  41508. /**
  41509. * Load into a scene.
  41510. * @param scene The scene to load into
  41511. * @param data The data to import
  41512. * @param rootUrl The root url for scene and resources
  41513. * @param onProgress The callback when the load progresses
  41514. * @param fileName Defines the name of the file to load
  41515. * @returns Nothing
  41516. */
  41517. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41518. /**
  41519. * The callback that returns true if the data can be directly loaded.
  41520. */
  41521. canDirectLoad?: (data: string) => boolean;
  41522. /**
  41523. * The callback that allows custom handling of the root url based on the response url.
  41524. */
  41525. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41526. /**
  41527. * Load into an asset container.
  41528. * @param scene The scene to load into
  41529. * @param data The data to import
  41530. * @param rootUrl The root url for scene and resources
  41531. * @param onProgress The callback when the load progresses
  41532. * @param fileName Defines the name of the file to load
  41533. * @returns The loaded asset container
  41534. */
  41535. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41536. }
  41537. /**
  41538. * Class used to load scene from various file formats using registered plugins
  41539. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41540. */
  41541. export class SceneLoader {
  41542. /**
  41543. * No logging while loading
  41544. */
  41545. static readonly NO_LOGGING: number;
  41546. /**
  41547. * Minimal logging while loading
  41548. */
  41549. static readonly MINIMAL_LOGGING: number;
  41550. /**
  41551. * Summary logging while loading
  41552. */
  41553. static readonly SUMMARY_LOGGING: number;
  41554. /**
  41555. * Detailled logging while loading
  41556. */
  41557. static readonly DETAILED_LOGGING: number;
  41558. /**
  41559. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41560. */
  41561. static ForceFullSceneLoadingForIncremental: boolean;
  41562. /**
  41563. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41564. */
  41565. static ShowLoadingScreen: boolean;
  41566. /**
  41567. * Defines the current logging level (while loading the scene)
  41568. * @ignorenaming
  41569. */
  41570. static loggingLevel: number;
  41571. /**
  41572. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41573. */
  41574. static CleanBoneMatrixWeights: boolean;
  41575. /**
  41576. * Event raised when a plugin is used to load a scene
  41577. */
  41578. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41579. private static _registeredPlugins;
  41580. private static _getDefaultPlugin;
  41581. private static _getPluginForExtension;
  41582. private static _getPluginForDirectLoad;
  41583. private static _getPluginForFilename;
  41584. private static _getDirectLoad;
  41585. private static _loadData;
  41586. private static _getFileInfo;
  41587. /**
  41588. * Gets a plugin that can load the given extension
  41589. * @param extension defines the extension to load
  41590. * @returns a plugin or null if none works
  41591. */
  41592. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41593. /**
  41594. * Gets a boolean indicating that the given extension can be loaded
  41595. * @param extension defines the extension to load
  41596. * @returns true if the extension is supported
  41597. */
  41598. static IsPluginForExtensionAvailable(extension: string): boolean;
  41599. /**
  41600. * Adds a new plugin to the list of registered plugins
  41601. * @param plugin defines the plugin to add
  41602. */
  41603. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41604. /**
  41605. * Import meshes into a scene
  41606. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41607. * @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)
  41608. * @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)
  41609. * @param scene the instance of BABYLON.Scene to append to
  41610. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41611. * @param onProgress a callback with a progress event for each file being loaded
  41612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41613. * @param pluginExtension the extension used to determine the plugin
  41614. * @returns The loaded plugin
  41615. */
  41616. 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>;
  41617. /**
  41618. * Import meshes into a scene
  41619. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41620. * @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)
  41621. * @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)
  41622. * @param scene the instance of BABYLON.Scene to append to
  41623. * @param onProgress a callback with a progress event for each file being loaded
  41624. * @param pluginExtension the extension used to determine the plugin
  41625. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41626. */
  41627. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41628. meshes: AbstractMesh[];
  41629. particleSystems: IParticleSystem[];
  41630. skeletons: Skeleton[];
  41631. animationGroups: AnimationGroup[];
  41632. }>;
  41633. /**
  41634. * Load a scene
  41635. * @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)
  41636. * @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)
  41637. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41638. * @param onSuccess a callback with the scene when import succeeds
  41639. * @param onProgress a callback with a progress event for each file being loaded
  41640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41641. * @param pluginExtension the extension used to determine the plugin
  41642. * @returns The loaded plugin
  41643. */
  41644. 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>;
  41645. /**
  41646. * Load a scene
  41647. * @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)
  41648. * @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)
  41649. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41650. * @param onProgress a callback with a progress event for each file being loaded
  41651. * @param pluginExtension the extension used to determine the plugin
  41652. * @returns The loaded scene
  41653. */
  41654. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41655. /**
  41656. * Append a scene
  41657. * @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)
  41658. * @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)
  41659. * @param scene is the instance of BABYLON.Scene to append to
  41660. * @param onSuccess a callback with the scene when import succeeds
  41661. * @param onProgress a callback with a progress event for each file being loaded
  41662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41663. * @param pluginExtension the extension used to determine the plugin
  41664. * @returns The loaded plugin
  41665. */
  41666. 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>;
  41667. /**
  41668. * Append a scene
  41669. * @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)
  41670. * @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)
  41671. * @param scene is the instance of BABYLON.Scene to append to
  41672. * @param onProgress a callback with a progress event for each file being loaded
  41673. * @param pluginExtension the extension used to determine the plugin
  41674. * @returns The given scene
  41675. */
  41676. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41677. /**
  41678. * Load a scene into an asset container
  41679. * @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)
  41680. * @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)
  41681. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41682. * @param onSuccess a callback with the scene when import succeeds
  41683. * @param onProgress a callback with a progress event for each file being loaded
  41684. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41685. * @param pluginExtension the extension used to determine the plugin
  41686. * @returns The loaded plugin
  41687. */
  41688. 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>;
  41689. /**
  41690. * Load a scene into an asset container
  41691. * @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)
  41692. * @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)
  41693. * @param scene is the instance of Scene to append to
  41694. * @param onProgress a callback with a progress event for each file being loaded
  41695. * @param pluginExtension the extension used to determine the plugin
  41696. * @returns The loaded asset container
  41697. */
  41698. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41699. }
  41700. }
  41701. declare module BABYLON {
  41702. /**
  41703. * Google Daydream controller
  41704. */
  41705. export class DaydreamController extends WebVRController {
  41706. /**
  41707. * Base Url for the controller model.
  41708. */
  41709. static MODEL_BASE_URL: string;
  41710. /**
  41711. * File name for the controller model.
  41712. */
  41713. static MODEL_FILENAME: string;
  41714. /**
  41715. * Gamepad Id prefix used to identify Daydream Controller.
  41716. */
  41717. static readonly GAMEPAD_ID_PREFIX: string;
  41718. /**
  41719. * Creates a new DaydreamController from a gamepad
  41720. * @param vrGamepad the gamepad that the controller should be created from
  41721. */
  41722. constructor(vrGamepad: any);
  41723. /**
  41724. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41725. * @param scene scene in which to add meshes
  41726. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41727. */
  41728. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41729. /**
  41730. * Called once for each button that changed state since the last frame
  41731. * @param buttonIdx Which button index changed
  41732. * @param state New state of the button
  41733. * @param changes Which properties on the state changed since last frame
  41734. */
  41735. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41736. }
  41737. }
  41738. declare module BABYLON {
  41739. /**
  41740. * Gear VR Controller
  41741. */
  41742. export class GearVRController extends WebVRController {
  41743. /**
  41744. * Base Url for the controller model.
  41745. */
  41746. static MODEL_BASE_URL: string;
  41747. /**
  41748. * File name for the controller model.
  41749. */
  41750. static MODEL_FILENAME: string;
  41751. /**
  41752. * Gamepad Id prefix used to identify this controller.
  41753. */
  41754. static readonly GAMEPAD_ID_PREFIX: string;
  41755. private readonly _buttonIndexToObservableNameMap;
  41756. /**
  41757. * Creates a new GearVRController from a gamepad
  41758. * @param vrGamepad the gamepad that the controller should be created from
  41759. */
  41760. constructor(vrGamepad: any);
  41761. /**
  41762. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41763. * @param scene scene in which to add meshes
  41764. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41765. */
  41766. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41767. /**
  41768. * Called once for each button that changed state since the last frame
  41769. * @param buttonIdx Which button index changed
  41770. * @param state New state of the button
  41771. * @param changes Which properties on the state changed since last frame
  41772. */
  41773. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41774. }
  41775. }
  41776. declare module BABYLON {
  41777. /**
  41778. * Generic Controller
  41779. */
  41780. export class GenericController extends WebVRController {
  41781. /**
  41782. * Base Url for the controller model.
  41783. */
  41784. static readonly MODEL_BASE_URL: string;
  41785. /**
  41786. * File name for the controller model.
  41787. */
  41788. static readonly MODEL_FILENAME: string;
  41789. /**
  41790. * Creates a new GenericController from a gamepad
  41791. * @param vrGamepad the gamepad that the controller should be created from
  41792. */
  41793. constructor(vrGamepad: any);
  41794. /**
  41795. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41796. * @param scene scene in which to add meshes
  41797. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41798. */
  41799. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41800. /**
  41801. * Called once for each button that changed state since the last frame
  41802. * @param buttonIdx Which button index changed
  41803. * @param state New state of the button
  41804. * @param changes Which properties on the state changed since last frame
  41805. */
  41806. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41807. }
  41808. }
  41809. declare module BABYLON {
  41810. /**
  41811. * Oculus Touch Controller
  41812. */
  41813. export class OculusTouchController extends WebVRController {
  41814. /**
  41815. * Base Url for the controller model.
  41816. */
  41817. static MODEL_BASE_URL: string;
  41818. /**
  41819. * File name for the left controller model.
  41820. */
  41821. static MODEL_LEFT_FILENAME: string;
  41822. /**
  41823. * File name for the right controller model.
  41824. */
  41825. static MODEL_RIGHT_FILENAME: string;
  41826. /**
  41827. * Fired when the secondary trigger on this controller is modified
  41828. */
  41829. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41830. /**
  41831. * Fired when the thumb rest on this controller is modified
  41832. */
  41833. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41834. /**
  41835. * Creates a new OculusTouchController from a gamepad
  41836. * @param vrGamepad the gamepad that the controller should be created from
  41837. */
  41838. constructor(vrGamepad: any);
  41839. /**
  41840. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41841. * @param scene scene in which to add meshes
  41842. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41843. */
  41844. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41845. /**
  41846. * Fired when the A button on this controller is modified
  41847. */
  41848. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41849. /**
  41850. * Fired when the B button on this controller is modified
  41851. */
  41852. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41853. /**
  41854. * Fired when the X button on this controller is modified
  41855. */
  41856. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41857. /**
  41858. * Fired when the Y button on this controller is modified
  41859. */
  41860. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41861. /**
  41862. * Called once for each button that changed state since the last frame
  41863. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41864. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41865. * 2) secondary trigger (same)
  41866. * 3) A (right) X (left), touch, pressed = value
  41867. * 4) B / Y
  41868. * 5) thumb rest
  41869. * @param buttonIdx Which button index changed
  41870. * @param state New state of the button
  41871. * @param changes Which properties on the state changed since last frame
  41872. */
  41873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Vive Controller
  41879. */
  41880. export class ViveController extends WebVRController {
  41881. /**
  41882. * Base Url for the controller model.
  41883. */
  41884. static MODEL_BASE_URL: string;
  41885. /**
  41886. * File name for the controller model.
  41887. */
  41888. static MODEL_FILENAME: string;
  41889. /**
  41890. * Creates a new ViveController from a gamepad
  41891. * @param vrGamepad the gamepad that the controller should be created from
  41892. */
  41893. constructor(vrGamepad: any);
  41894. /**
  41895. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41896. * @param scene scene in which to add meshes
  41897. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41898. */
  41899. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41900. /**
  41901. * Fired when the left button on this controller is modified
  41902. */
  41903. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41904. /**
  41905. * Fired when the right button on this controller is modified
  41906. */
  41907. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41908. /**
  41909. * Fired when the menu button on this controller is modified
  41910. */
  41911. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41912. /**
  41913. * Called once for each button that changed state since the last frame
  41914. * Vive mapping:
  41915. * 0: touchpad
  41916. * 1: trigger
  41917. * 2: left AND right buttons
  41918. * 3: menu button
  41919. * @param buttonIdx Which button index changed
  41920. * @param state New state of the button
  41921. * @param changes Which properties on the state changed since last frame
  41922. */
  41923. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * Defines the WindowsMotionController object that the state of the windows motion controller
  41929. */
  41930. export class WindowsMotionController extends WebVRController {
  41931. /**
  41932. * The base url used to load the left and right controller models
  41933. */
  41934. static MODEL_BASE_URL: string;
  41935. /**
  41936. * The name of the left controller model file
  41937. */
  41938. static MODEL_LEFT_FILENAME: string;
  41939. /**
  41940. * The name of the right controller model file
  41941. */
  41942. static MODEL_RIGHT_FILENAME: string;
  41943. /**
  41944. * The controller name prefix for this controller type
  41945. */
  41946. static readonly GAMEPAD_ID_PREFIX: string;
  41947. /**
  41948. * The controller id pattern for this controller type
  41949. */
  41950. private static readonly GAMEPAD_ID_PATTERN;
  41951. private _loadedMeshInfo;
  41952. private readonly _mapping;
  41953. /**
  41954. * Fired when the trackpad on this controller is clicked
  41955. */
  41956. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41957. /**
  41958. * Fired when the trackpad on this controller is modified
  41959. */
  41960. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41961. /**
  41962. * The current x and y values of this controller's trackpad
  41963. */
  41964. trackpad: StickValues;
  41965. /**
  41966. * Creates a new WindowsMotionController from a gamepad
  41967. * @param vrGamepad the gamepad that the controller should be created from
  41968. */
  41969. constructor(vrGamepad: any);
  41970. /**
  41971. * Fired when the trigger on this controller is modified
  41972. */
  41973. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41974. /**
  41975. * Fired when the menu button on this controller is modified
  41976. */
  41977. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41978. /**
  41979. * Fired when the grip button on this controller is modified
  41980. */
  41981. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41982. /**
  41983. * Fired when the thumbstick button on this controller is modified
  41984. */
  41985. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41986. /**
  41987. * Fired when the touchpad button on this controller is modified
  41988. */
  41989. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41990. /**
  41991. * Fired when the touchpad values on this controller are modified
  41992. */
  41993. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41994. private _updateTrackpad;
  41995. /**
  41996. * Called once per frame by the engine.
  41997. */
  41998. update(): void;
  41999. /**
  42000. * Called once for each button that changed state since the last frame
  42001. * @param buttonIdx Which button index changed
  42002. * @param state New state of the button
  42003. * @param changes Which properties on the state changed since last frame
  42004. */
  42005. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42006. /**
  42007. * Moves the buttons on the controller mesh based on their current state
  42008. * @param buttonName the name of the button to move
  42009. * @param buttonValue the value of the button which determines the buttons new position
  42010. */
  42011. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42012. /**
  42013. * Moves the axis on the controller mesh based on its current state
  42014. * @param axis the index of the axis
  42015. * @param axisValue the value of the axis which determines the meshes new position
  42016. * @hidden
  42017. */
  42018. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42019. /**
  42020. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42021. * @param scene scene in which to add meshes
  42022. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42023. */
  42024. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42025. /**
  42026. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42027. * can be transformed by button presses and axes values, based on this._mapping.
  42028. *
  42029. * @param scene scene in which the meshes exist
  42030. * @param meshes list of meshes that make up the controller model to process
  42031. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42032. */
  42033. private processModel;
  42034. private createMeshInfo;
  42035. /**
  42036. * Gets the ray of the controller in the direction the controller is pointing
  42037. * @param length the length the resulting ray should be
  42038. * @returns a ray in the direction the controller is pointing
  42039. */
  42040. getForwardRay(length?: number): Ray;
  42041. /**
  42042. * Disposes of the controller
  42043. */
  42044. dispose(): void;
  42045. }
  42046. }
  42047. declare module BABYLON {
  42048. /**
  42049. * Single axis scale gizmo
  42050. */
  42051. export class AxisScaleGizmo extends Gizmo {
  42052. private _coloredMaterial;
  42053. /**
  42054. * Drag behavior responsible for the gizmos dragging interactions
  42055. */
  42056. dragBehavior: PointerDragBehavior;
  42057. private _pointerObserver;
  42058. /**
  42059. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42060. */
  42061. snapDistance: number;
  42062. /**
  42063. * Event that fires each time the gizmo snaps to a new location.
  42064. * * snapDistance is the the change in distance
  42065. */
  42066. onSnapObservable: Observable<{
  42067. snapDistance: number;
  42068. }>;
  42069. /**
  42070. * If the scaling operation should be done on all axis (default: false)
  42071. */
  42072. uniformScaling: boolean;
  42073. /**
  42074. * Creates an AxisScaleGizmo
  42075. * @param gizmoLayer The utility layer the gizmo will be added to
  42076. * @param dragAxis The axis which the gizmo will be able to scale on
  42077. * @param color The color of the gizmo
  42078. */
  42079. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42080. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42081. /**
  42082. * Disposes of the gizmo
  42083. */
  42084. dispose(): void;
  42085. /**
  42086. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42087. * @param mesh The mesh to replace the default mesh of the gizmo
  42088. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42089. */
  42090. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Bounding box gizmo
  42096. */
  42097. export class BoundingBoxGizmo extends Gizmo {
  42098. private _lineBoundingBox;
  42099. private _rotateSpheresParent;
  42100. private _scaleBoxesParent;
  42101. private _boundingDimensions;
  42102. private _renderObserver;
  42103. private _pointerObserver;
  42104. private _scaleDragSpeed;
  42105. private _tmpQuaternion;
  42106. private _tmpVector;
  42107. private _tmpRotationMatrix;
  42108. /**
  42109. * 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)
  42110. */
  42111. ignoreChildren: boolean;
  42112. /**
  42113. * 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)
  42114. */
  42115. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42116. /**
  42117. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42118. */
  42119. rotationSphereSize: number;
  42120. /**
  42121. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42122. */
  42123. scaleBoxSize: number;
  42124. /**
  42125. * 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)
  42126. */
  42127. fixedDragMeshScreenSize: boolean;
  42128. /**
  42129. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42130. */
  42131. fixedDragMeshScreenSizeDistanceFactor: number;
  42132. /**
  42133. * Fired when a rotation sphere or scale box is dragged
  42134. */
  42135. onDragStartObservable: Observable<{}>;
  42136. /**
  42137. * Fired when a scale box is dragged
  42138. */
  42139. onScaleBoxDragObservable: Observable<{}>;
  42140. /**
  42141. * Fired when a scale box drag is ended
  42142. */
  42143. onScaleBoxDragEndObservable: Observable<{}>;
  42144. /**
  42145. * Fired when a rotation sphere is dragged
  42146. */
  42147. onRotationSphereDragObservable: Observable<{}>;
  42148. /**
  42149. * Fired when a rotation sphere drag is ended
  42150. */
  42151. onRotationSphereDragEndObservable: Observable<{}>;
  42152. /**
  42153. * 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)
  42154. */
  42155. scalePivot: Nullable<Vector3>;
  42156. private _anchorMesh;
  42157. private _existingMeshScale;
  42158. private _dragMesh;
  42159. private pointerDragBehavior;
  42160. private coloredMaterial;
  42161. private hoverColoredMaterial;
  42162. /**
  42163. * Sets the color of the bounding box gizmo
  42164. * @param color the color to set
  42165. */
  42166. setColor(color: Color3): void;
  42167. /**
  42168. * Creates an BoundingBoxGizmo
  42169. * @param gizmoLayer The utility layer the gizmo will be added to
  42170. * @param color The color of the gizmo
  42171. */
  42172. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42174. private _selectNode;
  42175. /**
  42176. * Updates the bounding box information for the Gizmo
  42177. */
  42178. updateBoundingBox(): void;
  42179. private _updateRotationSpheres;
  42180. private _updateScaleBoxes;
  42181. /**
  42182. * Enables rotation on the specified axis and disables rotation on the others
  42183. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42184. */
  42185. setEnabledRotationAxis(axis: string): void;
  42186. /**
  42187. * Enables/disables scaling
  42188. * @param enable if scaling should be enabled
  42189. */
  42190. setEnabledScaling(enable: boolean): void;
  42191. private _updateDummy;
  42192. /**
  42193. * Enables a pointer drag behavior on the bounding box of the gizmo
  42194. */
  42195. enableDragBehavior(): void;
  42196. /**
  42197. * Disposes of the gizmo
  42198. */
  42199. dispose(): void;
  42200. /**
  42201. * 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)
  42202. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42203. * @returns the bounding box mesh with the passed in mesh as a child
  42204. */
  42205. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42206. /**
  42207. * CustomMeshes are not supported by this gizmo
  42208. * @param mesh The mesh to replace the default mesh of the gizmo
  42209. */
  42210. setCustomMesh(mesh: Mesh): void;
  42211. }
  42212. }
  42213. declare module BABYLON {
  42214. /**
  42215. * Single plane rotation gizmo
  42216. */
  42217. export class PlaneRotationGizmo extends Gizmo {
  42218. /**
  42219. * Drag behavior responsible for the gizmos dragging interactions
  42220. */
  42221. dragBehavior: PointerDragBehavior;
  42222. private _pointerObserver;
  42223. /**
  42224. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42225. */
  42226. snapDistance: number;
  42227. /**
  42228. * Event that fires each time the gizmo snaps to a new location.
  42229. * * snapDistance is the the change in distance
  42230. */
  42231. onSnapObservable: Observable<{
  42232. snapDistance: number;
  42233. }>;
  42234. /**
  42235. * Creates a PlaneRotationGizmo
  42236. * @param gizmoLayer The utility layer the gizmo will be added to
  42237. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42238. * @param color The color of the gizmo
  42239. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42240. */
  42241. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42243. /**
  42244. * Disposes of the gizmo
  42245. */
  42246. dispose(): void;
  42247. }
  42248. }
  42249. declare module BABYLON {
  42250. /**
  42251. * Gizmo that enables rotating a mesh along 3 axis
  42252. */
  42253. export class RotationGizmo extends Gizmo {
  42254. /**
  42255. * Internal gizmo used for interactions on the x axis
  42256. */
  42257. xGizmo: PlaneRotationGizmo;
  42258. /**
  42259. * Internal gizmo used for interactions on the y axis
  42260. */
  42261. yGizmo: PlaneRotationGizmo;
  42262. /**
  42263. * Internal gizmo used for interactions on the z axis
  42264. */
  42265. zGizmo: PlaneRotationGizmo;
  42266. /** Fires an event when any of it's sub gizmos are dragged */
  42267. onDragStartObservable: Observable<{}>;
  42268. /** Fires an event when any of it's sub gizmos are released from dragging */
  42269. onDragEndObservable: Observable<{}>;
  42270. attachedMesh: Nullable<AbstractMesh>;
  42271. /**
  42272. * Creates a RotationGizmo
  42273. * @param gizmoLayer The utility layer the gizmo will be added to
  42274. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42275. */
  42276. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42277. updateGizmoRotationToMatchAttachedMesh: boolean;
  42278. /**
  42279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42280. */
  42281. snapDistance: number;
  42282. /**
  42283. * Ratio for the scale of the gizmo (Default: 1)
  42284. */
  42285. scaleRatio: number;
  42286. /**
  42287. * Disposes of the gizmo
  42288. */
  42289. dispose(): void;
  42290. /**
  42291. * CustomMeshes are not supported by this gizmo
  42292. * @param mesh The mesh to replace the default mesh of the gizmo
  42293. */
  42294. setCustomMesh(mesh: Mesh): void;
  42295. }
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * Gizmo that enables dragging a mesh along 3 axis
  42300. */
  42301. export class PositionGizmo extends Gizmo {
  42302. /**
  42303. * Internal gizmo used for interactions on the x axis
  42304. */
  42305. xGizmo: AxisDragGizmo;
  42306. /**
  42307. * Internal gizmo used for interactions on the y axis
  42308. */
  42309. yGizmo: AxisDragGizmo;
  42310. /**
  42311. * Internal gizmo used for interactions on the z axis
  42312. */
  42313. zGizmo: AxisDragGizmo;
  42314. /** Fires an event when any of it's sub gizmos are dragged */
  42315. onDragStartObservable: Observable<{}>;
  42316. /** Fires an event when any of it's sub gizmos are released from dragging */
  42317. onDragEndObservable: Observable<{}>;
  42318. attachedMesh: Nullable<AbstractMesh>;
  42319. /**
  42320. * Creates a PositionGizmo
  42321. * @param gizmoLayer The utility layer the gizmo will be added to
  42322. */
  42323. constructor(gizmoLayer?: UtilityLayerRenderer);
  42324. updateGizmoRotationToMatchAttachedMesh: boolean;
  42325. /**
  42326. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42327. */
  42328. snapDistance: number;
  42329. /**
  42330. * Ratio for the scale of the gizmo (Default: 1)
  42331. */
  42332. scaleRatio: number;
  42333. /**
  42334. * Disposes of the gizmo
  42335. */
  42336. dispose(): void;
  42337. /**
  42338. * CustomMeshes are not supported by this gizmo
  42339. * @param mesh The mesh to replace the default mesh of the gizmo
  42340. */
  42341. setCustomMesh(mesh: Mesh): void;
  42342. }
  42343. }
  42344. declare module BABYLON {
  42345. /**
  42346. * Class containing static functions to help procedurally build meshes
  42347. */
  42348. export class PolyhedronBuilder {
  42349. /**
  42350. * Creates a polyhedron mesh
  42351. * * 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
  42352. * * The parameter `size` (positive float, default 1) sets the polygon size
  42353. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42354. * * 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`
  42355. * * 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
  42356. * * 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)`)
  42357. * * 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
  42358. * * 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
  42359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42360. * * 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
  42361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42362. * @param name defines the name of the mesh
  42363. * @param options defines the options used to create the mesh
  42364. * @param scene defines the hosting scene
  42365. * @returns the polyhedron mesh
  42366. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42367. */
  42368. static CreatePolyhedron(name: string, options: {
  42369. type?: number;
  42370. size?: number;
  42371. sizeX?: number;
  42372. sizeY?: number;
  42373. sizeZ?: number;
  42374. custom?: any;
  42375. faceUV?: Vector4[];
  42376. faceColors?: Color4[];
  42377. flat?: boolean;
  42378. updatable?: boolean;
  42379. sideOrientation?: number;
  42380. frontUVs?: Vector4;
  42381. backUVs?: Vector4;
  42382. }, scene: Scene): Mesh;
  42383. }
  42384. }
  42385. declare module BABYLON {
  42386. /**
  42387. * Gizmo that enables scaling a mesh along 3 axis
  42388. */
  42389. export class ScaleGizmo extends Gizmo {
  42390. /**
  42391. * Internal gizmo used for interactions on the x axis
  42392. */
  42393. xGizmo: AxisScaleGizmo;
  42394. /**
  42395. * Internal gizmo used for interactions on the y axis
  42396. */
  42397. yGizmo: AxisScaleGizmo;
  42398. /**
  42399. * Internal gizmo used for interactions on the z axis
  42400. */
  42401. zGizmo: AxisScaleGizmo;
  42402. /**
  42403. * Internal gizmo used to scale all axis equally
  42404. */
  42405. uniformScaleGizmo: AxisScaleGizmo;
  42406. /** Fires an event when any of it's sub gizmos are dragged */
  42407. onDragStartObservable: Observable<{}>;
  42408. /** Fires an event when any of it's sub gizmos are released from dragging */
  42409. onDragEndObservable: Observable<{}>;
  42410. attachedMesh: Nullable<AbstractMesh>;
  42411. /**
  42412. * Creates a ScaleGizmo
  42413. * @param gizmoLayer The utility layer the gizmo will be added to
  42414. */
  42415. constructor(gizmoLayer?: UtilityLayerRenderer);
  42416. updateGizmoRotationToMatchAttachedMesh: boolean;
  42417. /**
  42418. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42419. */
  42420. snapDistance: number;
  42421. /**
  42422. * Ratio for the scale of the gizmo (Default: 1)
  42423. */
  42424. scaleRatio: number;
  42425. /**
  42426. * Disposes of the gizmo
  42427. */
  42428. dispose(): void;
  42429. }
  42430. }
  42431. declare module BABYLON {
  42432. /**
  42433. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42434. */
  42435. export class GizmoManager implements IDisposable {
  42436. private scene;
  42437. /**
  42438. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42439. */
  42440. gizmos: {
  42441. positionGizmo: Nullable<PositionGizmo>;
  42442. rotationGizmo: Nullable<RotationGizmo>;
  42443. scaleGizmo: Nullable<ScaleGizmo>;
  42444. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42445. };
  42446. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42447. clearGizmoOnEmptyPointerEvent: boolean;
  42448. /** Fires an event when the manager is attached to a mesh */
  42449. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42450. private _gizmosEnabled;
  42451. private _pointerObserver;
  42452. private _attachedMesh;
  42453. private _boundingBoxColor;
  42454. private _defaultUtilityLayer;
  42455. private _defaultKeepDepthUtilityLayer;
  42456. /**
  42457. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42458. */
  42459. boundingBoxDragBehavior: SixDofDragBehavior;
  42460. /**
  42461. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42462. */
  42463. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42464. /**
  42465. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42466. */
  42467. usePointerToAttachGizmos: boolean;
  42468. /**
  42469. * Instatiates a gizmo manager
  42470. * @param scene the scene to overlay the gizmos on top of
  42471. */
  42472. constructor(scene: Scene);
  42473. /**
  42474. * Attaches a set of gizmos to the specified mesh
  42475. * @param mesh The mesh the gizmo's should be attached to
  42476. */
  42477. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42478. /**
  42479. * If the position gizmo is enabled
  42480. */
  42481. positionGizmoEnabled: boolean;
  42482. /**
  42483. * If the rotation gizmo is enabled
  42484. */
  42485. rotationGizmoEnabled: boolean;
  42486. /**
  42487. * If the scale gizmo is enabled
  42488. */
  42489. scaleGizmoEnabled: boolean;
  42490. /**
  42491. * If the boundingBox gizmo is enabled
  42492. */
  42493. boundingBoxGizmoEnabled: boolean;
  42494. /**
  42495. * Disposes of the gizmo manager
  42496. */
  42497. dispose(): void;
  42498. }
  42499. }
  42500. declare module BABYLON {
  42501. /**
  42502. * A directional light is defined by a direction (what a surprise!).
  42503. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42504. * 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.
  42505. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42506. */
  42507. export class DirectionalLight extends ShadowLight {
  42508. private _shadowFrustumSize;
  42509. /**
  42510. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42511. */
  42512. /**
  42513. * Specifies a fix frustum size for the shadow generation.
  42514. */
  42515. shadowFrustumSize: number;
  42516. private _shadowOrthoScale;
  42517. /**
  42518. * Gets the shadow projection scale against the optimal computed one.
  42519. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42520. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42521. */
  42522. /**
  42523. * Sets the shadow projection scale against the optimal computed one.
  42524. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42525. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42526. */
  42527. shadowOrthoScale: number;
  42528. /**
  42529. * Automatically compute the projection matrix to best fit (including all the casters)
  42530. * on each frame.
  42531. */
  42532. autoUpdateExtends: boolean;
  42533. private _orthoLeft;
  42534. private _orthoRight;
  42535. private _orthoTop;
  42536. private _orthoBottom;
  42537. /**
  42538. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42539. * The directional light is emitted from everywhere in the given direction.
  42540. * It can cast shadows.
  42541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42542. * @param name The friendly name of the light
  42543. * @param direction The direction of the light
  42544. * @param scene The scene the light belongs to
  42545. */
  42546. constructor(name: string, direction: Vector3, scene: Scene);
  42547. /**
  42548. * Returns the string "DirectionalLight".
  42549. * @return The class name
  42550. */
  42551. getClassName(): string;
  42552. /**
  42553. * Returns the integer 1.
  42554. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42555. */
  42556. getTypeID(): number;
  42557. /**
  42558. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42559. * Returns the DirectionalLight Shadow projection matrix.
  42560. */
  42561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42562. /**
  42563. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42564. * Returns the DirectionalLight Shadow projection matrix.
  42565. */
  42566. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42567. /**
  42568. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42569. * Returns the DirectionalLight Shadow projection matrix.
  42570. */
  42571. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42572. protected _buildUniformLayout(): void;
  42573. /**
  42574. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42575. * @param effect The effect to update
  42576. * @param lightIndex The index of the light in the effect to update
  42577. * @returns The directional light
  42578. */
  42579. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42580. /**
  42581. * Gets the minZ used for shadow according to both the scene and the light.
  42582. *
  42583. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42584. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42585. * @param activeCamera The camera we are returning the min for
  42586. * @returns the depth min z
  42587. */
  42588. getDepthMinZ(activeCamera: Camera): number;
  42589. /**
  42590. * Gets the maxZ used for shadow according to both the scene and the light.
  42591. *
  42592. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42593. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42594. * @param activeCamera The camera we are returning the max for
  42595. * @returns the depth max z
  42596. */
  42597. getDepthMaxZ(activeCamera: Camera): number;
  42598. /**
  42599. * Prepares the list of defines specific to the light type.
  42600. * @param defines the list of defines
  42601. * @param lightIndex defines the index of the light for the effect
  42602. */
  42603. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42604. }
  42605. }
  42606. declare module BABYLON {
  42607. /**
  42608. * Class containing static functions to help procedurally build meshes
  42609. */
  42610. export class HemisphereBuilder {
  42611. /**
  42612. * Creates a hemisphere mesh
  42613. * @param name defines the name of the mesh
  42614. * @param options defines the options used to create the mesh
  42615. * @param scene defines the hosting scene
  42616. * @returns the hemisphere mesh
  42617. */
  42618. static CreateHemisphere(name: string, options: {
  42619. segments?: number;
  42620. diameter?: number;
  42621. sideOrientation?: number;
  42622. }, scene: any): Mesh;
  42623. }
  42624. }
  42625. declare module BABYLON {
  42626. /**
  42627. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42628. * These values define a cone of light starting from the position, emitting toward the direction.
  42629. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42630. * and the exponent defines the speed of the decay of the light with distance (reach).
  42631. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42632. */
  42633. export class SpotLight extends ShadowLight {
  42634. private _angle;
  42635. private _innerAngle;
  42636. private _cosHalfAngle;
  42637. private _lightAngleScale;
  42638. private _lightAngleOffset;
  42639. /**
  42640. * Gets the cone angle of the spot light in Radians.
  42641. */
  42642. /**
  42643. * Sets the cone angle of the spot light in Radians.
  42644. */
  42645. angle: number;
  42646. /**
  42647. * Only used in gltf falloff mode, this defines the angle where
  42648. * the directional falloff will start before cutting at angle which could be seen
  42649. * as outer angle.
  42650. */
  42651. /**
  42652. * Only used in gltf falloff mode, this defines the angle where
  42653. * the directional falloff will start before cutting at angle which could be seen
  42654. * as outer angle.
  42655. */
  42656. innerAngle: number;
  42657. private _shadowAngleScale;
  42658. /**
  42659. * Allows scaling the angle of the light for shadow generation only.
  42660. */
  42661. /**
  42662. * Allows scaling the angle of the light for shadow generation only.
  42663. */
  42664. shadowAngleScale: number;
  42665. /**
  42666. * The light decay speed with the distance from the emission spot.
  42667. */
  42668. exponent: number;
  42669. private _projectionTextureMatrix;
  42670. /**
  42671. * Allows reading the projecton texture
  42672. */
  42673. readonly projectionTextureMatrix: Matrix;
  42674. protected _projectionTextureLightNear: number;
  42675. /**
  42676. * Gets the near clip of the Spotlight for texture projection.
  42677. */
  42678. /**
  42679. * Sets the near clip of the Spotlight for texture projection.
  42680. */
  42681. projectionTextureLightNear: number;
  42682. protected _projectionTextureLightFar: number;
  42683. /**
  42684. * Gets the far clip of the Spotlight for texture projection.
  42685. */
  42686. /**
  42687. * Sets the far clip of the Spotlight for texture projection.
  42688. */
  42689. projectionTextureLightFar: number;
  42690. protected _projectionTextureUpDirection: Vector3;
  42691. /**
  42692. * Gets the Up vector of the Spotlight for texture projection.
  42693. */
  42694. /**
  42695. * Sets the Up vector of the Spotlight for texture projection.
  42696. */
  42697. projectionTextureUpDirection: Vector3;
  42698. private _projectionTexture;
  42699. /**
  42700. * Gets the projection texture of the light.
  42701. */
  42702. /**
  42703. * Sets the projection texture of the light.
  42704. */
  42705. projectionTexture: Nullable<BaseTexture>;
  42706. private _projectionTextureViewLightDirty;
  42707. private _projectionTextureProjectionLightDirty;
  42708. private _projectionTextureDirty;
  42709. private _projectionTextureViewTargetVector;
  42710. private _projectionTextureViewLightMatrix;
  42711. private _projectionTextureProjectionLightMatrix;
  42712. private _projectionTextureScalingMatrix;
  42713. /**
  42714. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42715. * It can cast shadows.
  42716. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42717. * @param name The light friendly name
  42718. * @param position The position of the spot light in the scene
  42719. * @param direction The direction of the light in the scene
  42720. * @param angle The cone angle of the light in Radians
  42721. * @param exponent The light decay speed with the distance from the emission spot
  42722. * @param scene The scene the lights belongs to
  42723. */
  42724. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42725. /**
  42726. * Returns the string "SpotLight".
  42727. * @returns the class name
  42728. */
  42729. getClassName(): string;
  42730. /**
  42731. * Returns the integer 2.
  42732. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42733. */
  42734. getTypeID(): number;
  42735. /**
  42736. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42737. */
  42738. protected _setDirection(value: Vector3): void;
  42739. /**
  42740. * Overrides the position setter to recompute the projection texture view light Matrix.
  42741. */
  42742. protected _setPosition(value: Vector3): void;
  42743. /**
  42744. * 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.
  42745. * Returns the SpotLight.
  42746. */
  42747. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42748. protected _computeProjectionTextureViewLightMatrix(): void;
  42749. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42750. /**
  42751. * Main function for light texture projection matrix computing.
  42752. */
  42753. protected _computeProjectionTextureMatrix(): void;
  42754. protected _buildUniformLayout(): void;
  42755. private _computeAngleValues;
  42756. /**
  42757. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42758. * @param effect The effect to update
  42759. * @param lightIndex The index of the light in the effect to update
  42760. * @returns The spot light
  42761. */
  42762. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42763. /**
  42764. * Disposes the light and the associated resources.
  42765. */
  42766. dispose(): void;
  42767. /**
  42768. * Prepares the list of defines specific to the light type.
  42769. * @param defines the list of defines
  42770. * @param lightIndex defines the index of the light for the effect
  42771. */
  42772. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42773. }
  42774. }
  42775. declare module BABYLON {
  42776. /**
  42777. * Gizmo that enables viewing a light
  42778. */
  42779. export class LightGizmo extends Gizmo {
  42780. private _lightMesh;
  42781. private _material;
  42782. /**
  42783. * Creates a LightGizmo
  42784. * @param gizmoLayer The utility layer the gizmo will be added to
  42785. */
  42786. constructor(gizmoLayer?: UtilityLayerRenderer);
  42787. private _light;
  42788. /**
  42789. * The light that the gizmo is attached to
  42790. */
  42791. light: Nullable<Light>;
  42792. /**
  42793. * @hidden
  42794. * Updates the gizmo to match the attached mesh's position/rotation
  42795. */
  42796. protected _update(): void;
  42797. private static _Scale;
  42798. /**
  42799. * Creates the lines for a light mesh
  42800. */
  42801. private static _createLightLines;
  42802. private static _CreateHemisphericLightMesh;
  42803. private static _CreatePointLightMesh;
  42804. private static _CreateSpotLightMesh;
  42805. private static _CreateDirectionalLightMesh;
  42806. }
  42807. }
  42808. declare module BABYLON {
  42809. /** @hidden */
  42810. export var backgroundFragmentDeclaration: {
  42811. name: string;
  42812. shader: string;
  42813. };
  42814. }
  42815. declare module BABYLON {
  42816. /** @hidden */
  42817. export var backgroundUboDeclaration: {
  42818. name: string;
  42819. shader: string;
  42820. };
  42821. }
  42822. declare module BABYLON {
  42823. /** @hidden */
  42824. export var backgroundPixelShader: {
  42825. name: string;
  42826. shader: string;
  42827. };
  42828. }
  42829. declare module BABYLON {
  42830. /** @hidden */
  42831. export var backgroundVertexDeclaration: {
  42832. name: string;
  42833. shader: string;
  42834. };
  42835. }
  42836. declare module BABYLON {
  42837. /** @hidden */
  42838. export var backgroundVertexShader: {
  42839. name: string;
  42840. shader: string;
  42841. };
  42842. }
  42843. declare module BABYLON {
  42844. /**
  42845. * Background material used to create an efficient environement around your scene.
  42846. */
  42847. export class BackgroundMaterial extends PushMaterial {
  42848. /**
  42849. * Standard reflectance value at parallel view angle.
  42850. */
  42851. static StandardReflectance0: number;
  42852. /**
  42853. * Standard reflectance value at grazing angle.
  42854. */
  42855. static StandardReflectance90: number;
  42856. protected _primaryColor: Color3;
  42857. /**
  42858. * Key light Color (multiply against the environement texture)
  42859. */
  42860. primaryColor: Color3;
  42861. protected __perceptualColor: Nullable<Color3>;
  42862. /**
  42863. * Experimental Internal Use Only.
  42864. *
  42865. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42866. * This acts as a helper to set the primary color to a more "human friendly" value.
  42867. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42868. * output color as close as possible from the chosen value.
  42869. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42870. * part of lighting setup.)
  42871. */
  42872. _perceptualColor: Nullable<Color3>;
  42873. protected _primaryColorShadowLevel: float;
  42874. /**
  42875. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42876. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42877. */
  42878. primaryColorShadowLevel: float;
  42879. protected _primaryColorHighlightLevel: float;
  42880. /**
  42881. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42882. * The primary color is used at the level chosen to define what the white area would look.
  42883. */
  42884. primaryColorHighlightLevel: float;
  42885. protected _reflectionTexture: Nullable<BaseTexture>;
  42886. /**
  42887. * Reflection Texture used in the material.
  42888. * Should be author in a specific way for the best result (refer to the documentation).
  42889. */
  42890. reflectionTexture: Nullable<BaseTexture>;
  42891. protected _reflectionBlur: float;
  42892. /**
  42893. * Reflection Texture level of blur.
  42894. *
  42895. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42896. * texture twice.
  42897. */
  42898. reflectionBlur: float;
  42899. protected _diffuseTexture: Nullable<BaseTexture>;
  42900. /**
  42901. * Diffuse Texture used in the material.
  42902. * Should be author in a specific way for the best result (refer to the documentation).
  42903. */
  42904. diffuseTexture: Nullable<BaseTexture>;
  42905. protected _shadowLights: Nullable<IShadowLight[]>;
  42906. /**
  42907. * Specify the list of lights casting shadow on the material.
  42908. * All scene shadow lights will be included if null.
  42909. */
  42910. shadowLights: Nullable<IShadowLight[]>;
  42911. protected _shadowLevel: float;
  42912. /**
  42913. * Helps adjusting the shadow to a softer level if required.
  42914. * 0 means black shadows and 1 means no shadows.
  42915. */
  42916. shadowLevel: float;
  42917. protected _sceneCenter: Vector3;
  42918. /**
  42919. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42920. * It is usually zero but might be interesting to modify according to your setup.
  42921. */
  42922. sceneCenter: Vector3;
  42923. protected _opacityFresnel: boolean;
  42924. /**
  42925. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42926. * This helps ensuring a nice transition when the camera goes under the ground.
  42927. */
  42928. opacityFresnel: boolean;
  42929. protected _reflectionFresnel: boolean;
  42930. /**
  42931. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42932. * This helps adding a mirror texture on the ground.
  42933. */
  42934. reflectionFresnel: boolean;
  42935. protected _reflectionFalloffDistance: number;
  42936. /**
  42937. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42938. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42939. */
  42940. reflectionFalloffDistance: number;
  42941. protected _reflectionAmount: number;
  42942. /**
  42943. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42944. */
  42945. reflectionAmount: number;
  42946. protected _reflectionReflectance0: number;
  42947. /**
  42948. * This specifies the weight of the reflection at grazing angle.
  42949. */
  42950. reflectionReflectance0: number;
  42951. protected _reflectionReflectance90: number;
  42952. /**
  42953. * This specifies the weight of the reflection at a perpendicular point of view.
  42954. */
  42955. reflectionReflectance90: number;
  42956. /**
  42957. * Sets the reflection reflectance fresnel values according to the default standard
  42958. * empirically know to work well :-)
  42959. */
  42960. reflectionStandardFresnelWeight: number;
  42961. protected _useRGBColor: boolean;
  42962. /**
  42963. * Helps to directly use the maps channels instead of their level.
  42964. */
  42965. useRGBColor: boolean;
  42966. protected _enableNoise: boolean;
  42967. /**
  42968. * This helps reducing the banding effect that could occur on the background.
  42969. */
  42970. enableNoise: boolean;
  42971. /**
  42972. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42973. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42974. * Recommended to be keep at 1.0 except for special cases.
  42975. */
  42976. fovMultiplier: number;
  42977. private _fovMultiplier;
  42978. /**
  42979. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42980. */
  42981. useEquirectangularFOV: boolean;
  42982. private _maxSimultaneousLights;
  42983. /**
  42984. * Number of Simultaneous lights allowed on the material.
  42985. */
  42986. maxSimultaneousLights: int;
  42987. /**
  42988. * Default configuration related to image processing available in the Background Material.
  42989. */
  42990. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42991. /**
  42992. * Keep track of the image processing observer to allow dispose and replace.
  42993. */
  42994. private _imageProcessingObserver;
  42995. /**
  42996. * Attaches a new image processing configuration to the PBR Material.
  42997. * @param configuration (if null the scene configuration will be use)
  42998. */
  42999. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43000. /**
  43001. * Gets the image processing configuration used either in this material.
  43002. */
  43003. /**
  43004. * Sets the Default image processing configuration used either in the this material.
  43005. *
  43006. * If sets to null, the scene one is in use.
  43007. */
  43008. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43009. /**
  43010. * Gets wether the color curves effect is enabled.
  43011. */
  43012. /**
  43013. * Sets wether the color curves effect is enabled.
  43014. */
  43015. cameraColorCurvesEnabled: boolean;
  43016. /**
  43017. * Gets wether the color grading effect is enabled.
  43018. */
  43019. /**
  43020. * Gets wether the color grading effect is enabled.
  43021. */
  43022. cameraColorGradingEnabled: boolean;
  43023. /**
  43024. * Gets wether tonemapping is enabled or not.
  43025. */
  43026. /**
  43027. * Sets wether tonemapping is enabled or not
  43028. */
  43029. cameraToneMappingEnabled: boolean;
  43030. /**
  43031. * The camera exposure used on this material.
  43032. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43033. * This corresponds to a photographic exposure.
  43034. */
  43035. /**
  43036. * The camera exposure used on this material.
  43037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43038. * This corresponds to a photographic exposure.
  43039. */
  43040. cameraExposure: float;
  43041. /**
  43042. * Gets The camera contrast used on this material.
  43043. */
  43044. /**
  43045. * Sets The camera contrast used on this material.
  43046. */
  43047. cameraContrast: float;
  43048. /**
  43049. * Gets the Color Grading 2D Lookup Texture.
  43050. */
  43051. /**
  43052. * Sets the Color Grading 2D Lookup Texture.
  43053. */
  43054. cameraColorGradingTexture: Nullable<BaseTexture>;
  43055. /**
  43056. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43057. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43058. * 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;
  43059. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43060. */
  43061. /**
  43062. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43063. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43064. * 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;
  43065. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43066. */
  43067. cameraColorCurves: Nullable<ColorCurves>;
  43068. /**
  43069. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43070. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43071. */
  43072. switchToBGR: boolean;
  43073. private _renderTargets;
  43074. private _reflectionControls;
  43075. private _white;
  43076. private _primaryShadowColor;
  43077. private _primaryHighlightColor;
  43078. /**
  43079. * Instantiates a Background Material in the given scene
  43080. * @param name The friendly name of the material
  43081. * @param scene The scene to add the material to
  43082. */
  43083. constructor(name: string, scene: Scene);
  43084. /**
  43085. * Gets a boolean indicating that current material needs to register RTT
  43086. */
  43087. readonly hasRenderTargetTextures: boolean;
  43088. /**
  43089. * The entire material has been created in order to prevent overdraw.
  43090. * @returns false
  43091. */
  43092. needAlphaTesting(): boolean;
  43093. /**
  43094. * The entire material has been created in order to prevent overdraw.
  43095. * @returns true if blending is enable
  43096. */
  43097. needAlphaBlending(): boolean;
  43098. /**
  43099. * Checks wether the material is ready to be rendered for a given mesh.
  43100. * @param mesh The mesh to render
  43101. * @param subMesh The submesh to check against
  43102. * @param useInstances Specify wether or not the material is used with instances
  43103. * @returns true if all the dependencies are ready (Textures, Effects...)
  43104. */
  43105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43106. /**
  43107. * Compute the primary color according to the chosen perceptual color.
  43108. */
  43109. private _computePrimaryColorFromPerceptualColor;
  43110. /**
  43111. * Compute the highlights and shadow colors according to their chosen levels.
  43112. */
  43113. private _computePrimaryColors;
  43114. /**
  43115. * Build the uniform buffer used in the material.
  43116. */
  43117. buildUniformLayout(): void;
  43118. /**
  43119. * Unbind the material.
  43120. */
  43121. unbind(): void;
  43122. /**
  43123. * Bind only the world matrix to the material.
  43124. * @param world The world matrix to bind.
  43125. */
  43126. bindOnlyWorldMatrix(world: Matrix): void;
  43127. /**
  43128. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43129. * @param world The world matrix to bind.
  43130. * @param subMesh The submesh to bind for.
  43131. */
  43132. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43133. /**
  43134. * Dispose the material.
  43135. * @param forceDisposeEffect Force disposal of the associated effect.
  43136. * @param forceDisposeTextures Force disposal of the associated textures.
  43137. */
  43138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43139. /**
  43140. * Clones the material.
  43141. * @param name The cloned name.
  43142. * @returns The cloned material.
  43143. */
  43144. clone(name: string): BackgroundMaterial;
  43145. /**
  43146. * Serializes the current material to its JSON representation.
  43147. * @returns The JSON representation.
  43148. */
  43149. serialize(): any;
  43150. /**
  43151. * Gets the class name of the material
  43152. * @returns "BackgroundMaterial"
  43153. */
  43154. getClassName(): string;
  43155. /**
  43156. * Parse a JSON input to create back a background material.
  43157. * @param source The JSON data to parse
  43158. * @param scene The scene to create the parsed material in
  43159. * @param rootUrl The root url of the assets the material depends upon
  43160. * @returns the instantiated BackgroundMaterial.
  43161. */
  43162. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43163. }
  43164. }
  43165. declare module BABYLON {
  43166. /**
  43167. * Represents the different options available during the creation of
  43168. * a Environment helper.
  43169. *
  43170. * This can control the default ground, skybox and image processing setup of your scene.
  43171. */
  43172. export interface IEnvironmentHelperOptions {
  43173. /**
  43174. * Specifies wether or not to create a ground.
  43175. * True by default.
  43176. */
  43177. createGround: boolean;
  43178. /**
  43179. * Specifies the ground size.
  43180. * 15 by default.
  43181. */
  43182. groundSize: number;
  43183. /**
  43184. * The texture used on the ground for the main color.
  43185. * Comes from the BabylonJS CDN by default.
  43186. *
  43187. * Remarks: Can be either a texture or a url.
  43188. */
  43189. groundTexture: string | BaseTexture;
  43190. /**
  43191. * The color mixed in the ground texture by default.
  43192. * BabylonJS clearColor by default.
  43193. */
  43194. groundColor: Color3;
  43195. /**
  43196. * Specifies the ground opacity.
  43197. * 1 by default.
  43198. */
  43199. groundOpacity: number;
  43200. /**
  43201. * Enables the ground to receive shadows.
  43202. * True by default.
  43203. */
  43204. enableGroundShadow: boolean;
  43205. /**
  43206. * Helps preventing the shadow to be fully black on the ground.
  43207. * 0.5 by default.
  43208. */
  43209. groundShadowLevel: number;
  43210. /**
  43211. * Creates a mirror texture attach to the ground.
  43212. * false by default.
  43213. */
  43214. enableGroundMirror: boolean;
  43215. /**
  43216. * Specifies the ground mirror size ratio.
  43217. * 0.3 by default as the default kernel is 64.
  43218. */
  43219. groundMirrorSizeRatio: number;
  43220. /**
  43221. * Specifies the ground mirror blur kernel size.
  43222. * 64 by default.
  43223. */
  43224. groundMirrorBlurKernel: number;
  43225. /**
  43226. * Specifies the ground mirror visibility amount.
  43227. * 1 by default
  43228. */
  43229. groundMirrorAmount: number;
  43230. /**
  43231. * Specifies the ground mirror reflectance weight.
  43232. * This uses the standard weight of the background material to setup the fresnel effect
  43233. * of the mirror.
  43234. * 1 by default.
  43235. */
  43236. groundMirrorFresnelWeight: number;
  43237. /**
  43238. * Specifies the ground mirror Falloff distance.
  43239. * This can helps reducing the size of the reflection.
  43240. * 0 by Default.
  43241. */
  43242. groundMirrorFallOffDistance: number;
  43243. /**
  43244. * Specifies the ground mirror texture type.
  43245. * Unsigned Int by Default.
  43246. */
  43247. groundMirrorTextureType: number;
  43248. /**
  43249. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43250. * the shown objects.
  43251. */
  43252. groundYBias: number;
  43253. /**
  43254. * Specifies wether or not to create a skybox.
  43255. * True by default.
  43256. */
  43257. createSkybox: boolean;
  43258. /**
  43259. * Specifies the skybox size.
  43260. * 20 by default.
  43261. */
  43262. skyboxSize: number;
  43263. /**
  43264. * The texture used on the skybox for the main color.
  43265. * Comes from the BabylonJS CDN by default.
  43266. *
  43267. * Remarks: Can be either a texture or a url.
  43268. */
  43269. skyboxTexture: string | BaseTexture;
  43270. /**
  43271. * The color mixed in the skybox texture by default.
  43272. * BabylonJS clearColor by default.
  43273. */
  43274. skyboxColor: Color3;
  43275. /**
  43276. * The background rotation around the Y axis of the scene.
  43277. * This helps aligning the key lights of your scene with the background.
  43278. * 0 by default.
  43279. */
  43280. backgroundYRotation: number;
  43281. /**
  43282. * Compute automatically the size of the elements to best fit with the scene.
  43283. */
  43284. sizeAuto: boolean;
  43285. /**
  43286. * Default position of the rootMesh if autoSize is not true.
  43287. */
  43288. rootPosition: Vector3;
  43289. /**
  43290. * Sets up the image processing in the scene.
  43291. * true by default.
  43292. */
  43293. setupImageProcessing: boolean;
  43294. /**
  43295. * The texture used as your environment texture in the scene.
  43296. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43297. *
  43298. * Remarks: Can be either a texture or a url.
  43299. */
  43300. environmentTexture: string | BaseTexture;
  43301. /**
  43302. * The value of the exposure to apply to the scene.
  43303. * 0.6 by default if setupImageProcessing is true.
  43304. */
  43305. cameraExposure: number;
  43306. /**
  43307. * The value of the contrast to apply to the scene.
  43308. * 1.6 by default if setupImageProcessing is true.
  43309. */
  43310. cameraContrast: number;
  43311. /**
  43312. * Specifies wether or not tonemapping should be enabled in the scene.
  43313. * true by default if setupImageProcessing is true.
  43314. */
  43315. toneMappingEnabled: boolean;
  43316. }
  43317. /**
  43318. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43319. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43320. * It also helps with the default setup of your imageProcessing configuration.
  43321. */
  43322. export class EnvironmentHelper {
  43323. /**
  43324. * Default ground texture URL.
  43325. */
  43326. private static _groundTextureCDNUrl;
  43327. /**
  43328. * Default skybox texture URL.
  43329. */
  43330. private static _skyboxTextureCDNUrl;
  43331. /**
  43332. * Default environment texture URL.
  43333. */
  43334. private static _environmentTextureCDNUrl;
  43335. /**
  43336. * Creates the default options for the helper.
  43337. */
  43338. private static _getDefaultOptions;
  43339. private _rootMesh;
  43340. /**
  43341. * Gets the root mesh created by the helper.
  43342. */
  43343. readonly rootMesh: Mesh;
  43344. private _skybox;
  43345. /**
  43346. * Gets the skybox created by the helper.
  43347. */
  43348. readonly skybox: Nullable<Mesh>;
  43349. private _skyboxTexture;
  43350. /**
  43351. * Gets the skybox texture created by the helper.
  43352. */
  43353. readonly skyboxTexture: Nullable<BaseTexture>;
  43354. private _skyboxMaterial;
  43355. /**
  43356. * Gets the skybox material created by the helper.
  43357. */
  43358. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43359. private _ground;
  43360. /**
  43361. * Gets the ground mesh created by the helper.
  43362. */
  43363. readonly ground: Nullable<Mesh>;
  43364. private _groundTexture;
  43365. /**
  43366. * Gets the ground texture created by the helper.
  43367. */
  43368. readonly groundTexture: Nullable<BaseTexture>;
  43369. private _groundMirror;
  43370. /**
  43371. * Gets the ground mirror created by the helper.
  43372. */
  43373. readonly groundMirror: Nullable<MirrorTexture>;
  43374. /**
  43375. * Gets the ground mirror render list to helps pushing the meshes
  43376. * you wish in the ground reflection.
  43377. */
  43378. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43379. private _groundMaterial;
  43380. /**
  43381. * Gets the ground material created by the helper.
  43382. */
  43383. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43384. /**
  43385. * Stores the creation options.
  43386. */
  43387. private readonly _scene;
  43388. private _options;
  43389. /**
  43390. * This observable will be notified with any error during the creation of the environment,
  43391. * mainly texture creation errors.
  43392. */
  43393. onErrorObservable: Observable<{
  43394. message?: string;
  43395. exception?: any;
  43396. }>;
  43397. /**
  43398. * constructor
  43399. * @param options Defines the options we want to customize the helper
  43400. * @param scene The scene to add the material to
  43401. */
  43402. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43403. /**
  43404. * Updates the background according to the new options
  43405. * @param options
  43406. */
  43407. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43408. /**
  43409. * Sets the primary color of all the available elements.
  43410. * @param color the main color to affect to the ground and the background
  43411. */
  43412. setMainColor(color: Color3): void;
  43413. /**
  43414. * Setup the image processing according to the specified options.
  43415. */
  43416. private _setupImageProcessing;
  43417. /**
  43418. * Setup the environment texture according to the specified options.
  43419. */
  43420. private _setupEnvironmentTexture;
  43421. /**
  43422. * Setup the background according to the specified options.
  43423. */
  43424. private _setupBackground;
  43425. /**
  43426. * Get the scene sizes according to the setup.
  43427. */
  43428. private _getSceneSize;
  43429. /**
  43430. * Setup the ground according to the specified options.
  43431. */
  43432. private _setupGround;
  43433. /**
  43434. * Setup the ground material according to the specified options.
  43435. */
  43436. private _setupGroundMaterial;
  43437. /**
  43438. * Setup the ground diffuse texture according to the specified options.
  43439. */
  43440. private _setupGroundDiffuseTexture;
  43441. /**
  43442. * Setup the ground mirror texture according to the specified options.
  43443. */
  43444. private _setupGroundMirrorTexture;
  43445. /**
  43446. * Setup the ground to receive the mirror texture.
  43447. */
  43448. private _setupMirrorInGroundMaterial;
  43449. /**
  43450. * Setup the skybox according to the specified options.
  43451. */
  43452. private _setupSkybox;
  43453. /**
  43454. * Setup the skybox material according to the specified options.
  43455. */
  43456. private _setupSkyboxMaterial;
  43457. /**
  43458. * Setup the skybox reflection texture according to the specified options.
  43459. */
  43460. private _setupSkyboxReflectionTexture;
  43461. private _errorHandler;
  43462. /**
  43463. * Dispose all the elements created by the Helper.
  43464. */
  43465. dispose(): void;
  43466. }
  43467. }
  43468. declare module BABYLON {
  43469. /**
  43470. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43471. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43472. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43473. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43474. */
  43475. export class PhotoDome extends TransformNode {
  43476. private _useDirectMapping;
  43477. /**
  43478. * The texture being displayed on the sphere
  43479. */
  43480. protected _photoTexture: Texture;
  43481. /**
  43482. * Gets or sets the texture being displayed on the sphere
  43483. */
  43484. photoTexture: Texture;
  43485. /**
  43486. * Observable raised when an error occured while loading the 360 image
  43487. */
  43488. onLoadErrorObservable: Observable<string>;
  43489. /**
  43490. * The skybox material
  43491. */
  43492. protected _material: BackgroundMaterial;
  43493. /**
  43494. * The surface used for the skybox
  43495. */
  43496. protected _mesh: Mesh;
  43497. /**
  43498. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43499. * Also see the options.resolution property.
  43500. */
  43501. fovMultiplier: number;
  43502. /**
  43503. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43504. * @param name Element's name, child elements will append suffixes for their own names.
  43505. * @param urlsOfPhoto defines the url of the photo to display
  43506. * @param options defines an object containing optional or exposed sub element properties
  43507. * @param onError defines a callback called when an error occured while loading the texture
  43508. */
  43509. constructor(name: string, urlOfPhoto: string, options: {
  43510. resolution?: number;
  43511. size?: number;
  43512. useDirectMapping?: boolean;
  43513. faceForward?: boolean;
  43514. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43515. /**
  43516. * Releases resources associated with this node.
  43517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43519. */
  43520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43521. }
  43522. }
  43523. declare module BABYLON {
  43524. /**
  43525. * Class used to host texture specific utilities
  43526. */
  43527. export class BRDFTextureTools {
  43528. /**
  43529. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43530. * @param texture the texture to expand.
  43531. */
  43532. private static _ExpandDefaultBRDFTexture;
  43533. /**
  43534. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43535. * @param scene defines the hosting scene
  43536. * @returns the environment BRDF texture
  43537. */
  43538. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43539. private static _environmentBRDFBase64Texture;
  43540. }
  43541. }
  43542. declare module BABYLON {
  43543. /**
  43544. * @hidden
  43545. */
  43546. export interface IMaterialClearCoatDefines {
  43547. CLEARCOAT: boolean;
  43548. CLEARCOAT_DEFAULTIOR: boolean;
  43549. CLEARCOAT_TEXTURE: boolean;
  43550. CLEARCOAT_TEXTUREDIRECTUV: number;
  43551. CLEARCOAT_BUMP: boolean;
  43552. CLEARCOAT_BUMPDIRECTUV: number;
  43553. CLEARCOAT_TINT: boolean;
  43554. CLEARCOAT_TINT_TEXTURE: boolean;
  43555. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43556. /** @hidden */
  43557. _areTexturesDirty: boolean;
  43558. }
  43559. /**
  43560. * Define the code related to the clear coat parameters of the pbr material.
  43561. */
  43562. export class PBRClearCoatConfiguration {
  43563. /**
  43564. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43565. * The default fits with a polyurethane material.
  43566. */
  43567. private static readonly _DefaultIndiceOfRefraction;
  43568. private _isEnabled;
  43569. /**
  43570. * Defines if the clear coat is enabled in the material.
  43571. */
  43572. isEnabled: boolean;
  43573. /**
  43574. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43575. */
  43576. intensity: number;
  43577. /**
  43578. * Defines the clear coat layer roughness.
  43579. */
  43580. roughness: number;
  43581. private _indiceOfRefraction;
  43582. /**
  43583. * Defines the indice of refraction of the clear coat.
  43584. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43585. * The default fits with a polyurethane material.
  43586. * Changing the default value is more performance intensive.
  43587. */
  43588. indiceOfRefraction: number;
  43589. private _texture;
  43590. /**
  43591. * Stores the clear coat values in a texture.
  43592. */
  43593. texture: Nullable<BaseTexture>;
  43594. private _bumpTexture;
  43595. /**
  43596. * Define the clear coat specific bump texture.
  43597. */
  43598. bumpTexture: Nullable<BaseTexture>;
  43599. private _isTintEnabled;
  43600. /**
  43601. * Defines if the clear coat tint is enabled in the material.
  43602. */
  43603. isTintEnabled: boolean;
  43604. /**
  43605. * Defines if the clear coat tint is enabled in the material.
  43606. * This is only use if tint is enabled
  43607. */
  43608. tintColor: Color3;
  43609. /**
  43610. * Defines if the distance at which the tint color should be found in the
  43611. * clear coat media.
  43612. * This is only use if tint is enabled
  43613. */
  43614. tintColorAtDistance: number;
  43615. /**
  43616. * Defines the clear coat layer thickness.
  43617. * This is only use if tint is enabled
  43618. */
  43619. tintThickness: number;
  43620. private _tintTexture;
  43621. /**
  43622. * Stores the clear tint values in a texture.
  43623. * rgb is tint
  43624. * a is a thickness factor
  43625. */
  43626. tintTexture: Nullable<BaseTexture>;
  43627. /** @hidden */
  43628. private _internalMarkAllSubMeshesAsTexturesDirty;
  43629. /** @hidden */
  43630. _markAllSubMeshesAsTexturesDirty(): void;
  43631. /**
  43632. * Instantiate a new istance of clear coat configuration.
  43633. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43634. */
  43635. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43636. /**
  43637. * Specifies that the submesh is ready to be used.
  43638. * @param defines the list of "defines" to update.
  43639. * @param scene defines the scene the material belongs to.
  43640. * @param engine defines the engine the material belongs to.
  43641. * @param disableBumpMap defines wether the material disables bump or not.
  43642. * @returns - boolean indicating that the submesh is ready or not.
  43643. */
  43644. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43645. /**
  43646. * Checks to see if a texture is used in the material.
  43647. * @param defines the list of "defines" to update.
  43648. * @param scene defines the scene to the material belongs to.
  43649. */
  43650. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43651. /**
  43652. * Binds the material data.
  43653. * @param uniformBuffer defines the Uniform buffer to fill in.
  43654. * @param scene defines the scene the material belongs to.
  43655. * @param engine defines the engine the material belongs to.
  43656. * @param disableBumpMap defines wether the material disables bump or not.
  43657. * @param isFrozen defines wether the material is frozen or not.
  43658. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43659. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43660. */
  43661. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43662. /**
  43663. * Checks to see if a texture is used in the material.
  43664. * @param texture - Base texture to use.
  43665. * @returns - Boolean specifying if a texture is used in the material.
  43666. */
  43667. hasTexture(texture: BaseTexture): boolean;
  43668. /**
  43669. * Returns an array of the actively used textures.
  43670. * @param activeTextures Array of BaseTextures
  43671. */
  43672. getActiveTextures(activeTextures: BaseTexture[]): void;
  43673. /**
  43674. * Returns the animatable textures.
  43675. * @param animatables Array of animatable textures.
  43676. */
  43677. getAnimatables(animatables: IAnimatable[]): void;
  43678. /**
  43679. * Disposes the resources of the material.
  43680. * @param forceDisposeTextures - Forces the disposal of all textures.
  43681. */
  43682. dispose(forceDisposeTextures?: boolean): void;
  43683. /**
  43684. * Get the current class name of the texture useful for serialization or dynamic coding.
  43685. * @returns "PBRClearCoatConfiguration"
  43686. */
  43687. getClassName(): string;
  43688. /**
  43689. * Add fallbacks to the effect fallbacks list.
  43690. * @param defines defines the Base texture to use.
  43691. * @param fallbacks defines the current fallback list.
  43692. * @param currentRank defines the current fallback rank.
  43693. * @returns the new fallback rank.
  43694. */
  43695. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43696. /**
  43697. * Add the required uniforms to the current list.
  43698. * @param uniforms defines the current uniform list.
  43699. */
  43700. static AddUniforms(uniforms: string[]): void;
  43701. /**
  43702. * Add the required samplers to the current list.
  43703. * @param samplers defines the current sampler list.
  43704. */
  43705. static AddSamplers(samplers: string[]): void;
  43706. /**
  43707. * Add the required uniforms to the current buffer.
  43708. * @param uniformBuffer defines the current uniform buffer.
  43709. */
  43710. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43711. /**
  43712. * Makes a duplicate of the current configuration into another one.
  43713. * @param clearCoatConfiguration define the config where to copy the info
  43714. */
  43715. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43716. /**
  43717. * Serializes this clear coat configuration.
  43718. * @returns - An object with the serialized config.
  43719. */
  43720. serialize(): any;
  43721. /**
  43722. * Parses a Clear Coat Configuration from a serialized object.
  43723. * @param source - Serialized object.
  43724. */
  43725. parse(source: any): void;
  43726. }
  43727. }
  43728. declare module BABYLON {
  43729. /**
  43730. * @hidden
  43731. */
  43732. export interface IMaterialAnisotropicDefines {
  43733. ANISOTROPIC: boolean;
  43734. ANISOTROPIC_TEXTURE: boolean;
  43735. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43736. MAINUV1: boolean;
  43737. _areTexturesDirty: boolean;
  43738. _needUVs: boolean;
  43739. }
  43740. /**
  43741. * Define the code related to the anisotropic parameters of the pbr material.
  43742. */
  43743. export class PBRAnisotropicConfiguration {
  43744. private _isEnabled;
  43745. /**
  43746. * Defines if the anisotropy is enabled in the material.
  43747. */
  43748. isEnabled: boolean;
  43749. /**
  43750. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43751. */
  43752. intensity: number;
  43753. /**
  43754. * Defines if the effect is along the tangents, bitangents or in between.
  43755. * By default, the effect is "strectching" the highlights along the tangents.
  43756. */
  43757. direction: Vector2;
  43758. private _texture;
  43759. /**
  43760. * Stores the anisotropy values in a texture.
  43761. * rg is direction (like normal from -1 to 1)
  43762. * b is a intensity
  43763. */
  43764. texture: Nullable<BaseTexture>;
  43765. /** @hidden */
  43766. private _internalMarkAllSubMeshesAsTexturesDirty;
  43767. /** @hidden */
  43768. _markAllSubMeshesAsTexturesDirty(): void;
  43769. /**
  43770. * Instantiate a new istance of anisotropy configuration.
  43771. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43772. */
  43773. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43774. /**
  43775. * Specifies that the submesh is ready to be used.
  43776. * @param defines the list of "defines" to update.
  43777. * @param scene defines the scene the material belongs to.
  43778. * @returns - boolean indicating that the submesh is ready or not.
  43779. */
  43780. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43781. /**
  43782. * Checks to see if a texture is used in the material.
  43783. * @param defines the list of "defines" to update.
  43784. * @param mesh the mesh we are preparing the defines for.
  43785. * @param scene defines the scene the material belongs to.
  43786. */
  43787. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43788. /**
  43789. * Binds the material data.
  43790. * @param uniformBuffer defines the Uniform buffer to fill in.
  43791. * @param scene defines the scene the material belongs to.
  43792. * @param isFrozen defines wether the material is frozen or not.
  43793. */
  43794. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43795. /**
  43796. * Checks to see if a texture is used in the material.
  43797. * @param texture - Base texture to use.
  43798. * @returns - Boolean specifying if a texture is used in the material.
  43799. */
  43800. hasTexture(texture: BaseTexture): boolean;
  43801. /**
  43802. * Returns an array of the actively used textures.
  43803. * @param activeTextures Array of BaseTextures
  43804. */
  43805. getActiveTextures(activeTextures: BaseTexture[]): void;
  43806. /**
  43807. * Returns the animatable textures.
  43808. * @param animatables Array of animatable textures.
  43809. */
  43810. getAnimatables(animatables: IAnimatable[]): void;
  43811. /**
  43812. * Disposes the resources of the material.
  43813. * @param forceDisposeTextures - Forces the disposal of all textures.
  43814. */
  43815. dispose(forceDisposeTextures?: boolean): void;
  43816. /**
  43817. * Get the current class name of the texture useful for serialization or dynamic coding.
  43818. * @returns "PBRAnisotropicConfiguration"
  43819. */
  43820. getClassName(): string;
  43821. /**
  43822. * Add fallbacks to the effect fallbacks list.
  43823. * @param defines defines the Base texture to use.
  43824. * @param fallbacks defines the current fallback list.
  43825. * @param currentRank defines the current fallback rank.
  43826. * @returns the new fallback rank.
  43827. */
  43828. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43829. /**
  43830. * Add the required uniforms to the current list.
  43831. * @param uniforms defines the current uniform list.
  43832. */
  43833. static AddUniforms(uniforms: string[]): void;
  43834. /**
  43835. * Add the required uniforms to the current buffer.
  43836. * @param uniformBuffer defines the current uniform buffer.
  43837. */
  43838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43839. /**
  43840. * Add the required samplers to the current list.
  43841. * @param samplers defines the current sampler list.
  43842. */
  43843. static AddSamplers(samplers: string[]): void;
  43844. /**
  43845. * Makes a duplicate of the current configuration into another one.
  43846. * @param anisotropicConfiguration define the config where to copy the info
  43847. */
  43848. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43849. /**
  43850. * Serializes this anisotropy configuration.
  43851. * @returns - An object with the serialized config.
  43852. */
  43853. serialize(): any;
  43854. /**
  43855. * Parses a anisotropy Configuration from a serialized object.
  43856. * @param source - Serialized object.
  43857. */
  43858. parse(source: any): void;
  43859. }
  43860. }
  43861. declare module BABYLON {
  43862. /**
  43863. * @hidden
  43864. */
  43865. export interface IMaterialBRDFDefines {
  43866. BRDF_V_HEIGHT_CORRELATED: boolean;
  43867. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43868. /** @hidden */
  43869. _areMiscDirty: boolean;
  43870. }
  43871. /**
  43872. * Define the code related to the BRDF parameters of the pbr material.
  43873. */
  43874. export class PBRBRDFConfiguration {
  43875. /**
  43876. * Default value used for the energy conservation.
  43877. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43878. */
  43879. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43880. /**
  43881. * Default value used for the Smith Visibility Height Correlated mode.
  43882. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43883. */
  43884. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43885. private _useEnergyConservation;
  43886. /**
  43887. * Defines if the material uses energy conservation.
  43888. */
  43889. useEnergyConservation: boolean;
  43890. private _useSmithVisibilityHeightCorrelated;
  43891. /**
  43892. * LEGACY Mode set to false
  43893. * Defines if the material uses height smith correlated visibility term.
  43894. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43895. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43896. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43897. * Not relying on height correlated will also disable energy conservation.
  43898. */
  43899. useSmithVisibilityHeightCorrelated: boolean;
  43900. /** @hidden */
  43901. private _internalMarkAllSubMeshesAsMiscDirty;
  43902. /** @hidden */
  43903. _markAllSubMeshesAsMiscDirty(): void;
  43904. /**
  43905. * Instantiate a new istance of clear coat configuration.
  43906. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43907. */
  43908. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43909. /**
  43910. * Checks to see if a texture is used in the material.
  43911. * @param defines the list of "defines" to update.
  43912. */
  43913. prepareDefines(defines: IMaterialBRDFDefines): void;
  43914. /**
  43915. * Get the current class name of the texture useful for serialization or dynamic coding.
  43916. * @returns "PBRClearCoatConfiguration"
  43917. */
  43918. getClassName(): string;
  43919. /**
  43920. * Makes a duplicate of the current configuration into another one.
  43921. * @param brdfConfiguration define the config where to copy the info
  43922. */
  43923. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43924. /**
  43925. * Serializes this BRDF configuration.
  43926. * @returns - An object with the serialized config.
  43927. */
  43928. serialize(): any;
  43929. /**
  43930. * Parses a BRDF Configuration from a serialized object.
  43931. * @param source - Serialized object.
  43932. */
  43933. parse(source: any): void;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. /**
  43938. * @hidden
  43939. */
  43940. export interface IMaterialSheenDefines {
  43941. SHEEN: boolean;
  43942. SHEEN_TEXTURE: boolean;
  43943. SHEEN_TEXTUREDIRECTUV: number;
  43944. SHEEN_LINKWITHALBEDO: boolean;
  43945. /** @hidden */
  43946. _areTexturesDirty: boolean;
  43947. }
  43948. /**
  43949. * Define the code related to the Sheen parameters of the pbr material.
  43950. */
  43951. export class PBRSheenConfiguration {
  43952. private _isEnabled;
  43953. /**
  43954. * Defines if the material uses sheen.
  43955. */
  43956. isEnabled: boolean;
  43957. private _linkSheenWithAlbedo;
  43958. /**
  43959. * Defines if the sheen is linked to the sheen color.
  43960. */
  43961. linkSheenWithAlbedo: boolean;
  43962. /**
  43963. * Defines the sheen intensity.
  43964. */
  43965. intensity: number;
  43966. /**
  43967. * Defines the sheen color.
  43968. */
  43969. color: Color3;
  43970. private _texture;
  43971. /**
  43972. * Stores the sheen tint values in a texture.
  43973. * rgb is tint
  43974. * a is a intensity
  43975. */
  43976. texture: Nullable<BaseTexture>;
  43977. /** @hidden */
  43978. private _internalMarkAllSubMeshesAsTexturesDirty;
  43979. /** @hidden */
  43980. _markAllSubMeshesAsTexturesDirty(): void;
  43981. /**
  43982. * Instantiate a new istance of clear coat configuration.
  43983. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43984. */
  43985. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43986. /**
  43987. * Specifies that the submesh is ready to be used.
  43988. * @param defines the list of "defines" to update.
  43989. * @param scene defines the scene the material belongs to.
  43990. * @returns - boolean indicating that the submesh is ready or not.
  43991. */
  43992. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43993. /**
  43994. * Checks to see if a texture is used in the material.
  43995. * @param defines the list of "defines" to update.
  43996. * @param scene defines the scene the material belongs to.
  43997. */
  43998. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43999. /**
  44000. * Binds the material data.
  44001. * @param uniformBuffer defines the Uniform buffer to fill in.
  44002. * @param scene defines the scene the material belongs to.
  44003. * @param isFrozen defines wether the material is frozen or not.
  44004. */
  44005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44006. /**
  44007. * Checks to see if a texture is used in the material.
  44008. * @param texture - Base texture to use.
  44009. * @returns - Boolean specifying if a texture is used in the material.
  44010. */
  44011. hasTexture(texture: BaseTexture): boolean;
  44012. /**
  44013. * Returns an array of the actively used textures.
  44014. * @param activeTextures Array of BaseTextures
  44015. */
  44016. getActiveTextures(activeTextures: BaseTexture[]): void;
  44017. /**
  44018. * Returns the animatable textures.
  44019. * @param animatables Array of animatable textures.
  44020. */
  44021. getAnimatables(animatables: IAnimatable[]): void;
  44022. /**
  44023. * Disposes the resources of the material.
  44024. * @param forceDisposeTextures - Forces the disposal of all textures.
  44025. */
  44026. dispose(forceDisposeTextures?: boolean): void;
  44027. /**
  44028. * Get the current class name of the texture useful for serialization or dynamic coding.
  44029. * @returns "PBRSheenConfiguration"
  44030. */
  44031. getClassName(): string;
  44032. /**
  44033. * Add fallbacks to the effect fallbacks list.
  44034. * @param defines defines the Base texture to use.
  44035. * @param fallbacks defines the current fallback list.
  44036. * @param currentRank defines the current fallback rank.
  44037. * @returns the new fallback rank.
  44038. */
  44039. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44040. /**
  44041. * Add the required uniforms to the current list.
  44042. * @param uniforms defines the current uniform list.
  44043. */
  44044. static AddUniforms(uniforms: string[]): void;
  44045. /**
  44046. * Add the required uniforms to the current buffer.
  44047. * @param uniformBuffer defines the current uniform buffer.
  44048. */
  44049. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44050. /**
  44051. * Add the required samplers to the current list.
  44052. * @param samplers defines the current sampler list.
  44053. */
  44054. static AddSamplers(samplers: string[]): void;
  44055. /**
  44056. * Makes a duplicate of the current configuration into another one.
  44057. * @param sheenConfiguration define the config where to copy the info
  44058. */
  44059. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44060. /**
  44061. * Serializes this BRDF configuration.
  44062. * @returns - An object with the serialized config.
  44063. */
  44064. serialize(): any;
  44065. /**
  44066. * Parses a Sheen Configuration from a serialized object.
  44067. * @param source - Serialized object.
  44068. */
  44069. parse(source: any): void;
  44070. }
  44071. }
  44072. declare module BABYLON {
  44073. /** @hidden */
  44074. export var pbrFragmentDeclaration: {
  44075. name: string;
  44076. shader: string;
  44077. };
  44078. }
  44079. declare module BABYLON {
  44080. /** @hidden */
  44081. export var pbrUboDeclaration: {
  44082. name: string;
  44083. shader: string;
  44084. };
  44085. }
  44086. declare module BABYLON {
  44087. /** @hidden */
  44088. export var pbrFragmentExtraDeclaration: {
  44089. name: string;
  44090. shader: string;
  44091. };
  44092. }
  44093. declare module BABYLON {
  44094. /** @hidden */
  44095. export var pbrFragmentSamplersDeclaration: {
  44096. name: string;
  44097. shader: string;
  44098. };
  44099. }
  44100. declare module BABYLON {
  44101. /** @hidden */
  44102. export var pbrHelperFunctions: {
  44103. name: string;
  44104. shader: string;
  44105. };
  44106. }
  44107. declare module BABYLON {
  44108. /** @hidden */
  44109. export var harmonicsFunctions: {
  44110. name: string;
  44111. shader: string;
  44112. };
  44113. }
  44114. declare module BABYLON {
  44115. /** @hidden */
  44116. export var pbrDirectLightingSetupFunctions: {
  44117. name: string;
  44118. shader: string;
  44119. };
  44120. }
  44121. declare module BABYLON {
  44122. /** @hidden */
  44123. export var pbrDirectLightingFalloffFunctions: {
  44124. name: string;
  44125. shader: string;
  44126. };
  44127. }
  44128. declare module BABYLON {
  44129. /** @hidden */
  44130. export var pbrBRDFFunctions: {
  44131. name: string;
  44132. shader: string;
  44133. };
  44134. }
  44135. declare module BABYLON {
  44136. /** @hidden */
  44137. export var pbrDirectLightingFunctions: {
  44138. name: string;
  44139. shader: string;
  44140. };
  44141. }
  44142. declare module BABYLON {
  44143. /** @hidden */
  44144. export var pbrIBLFunctions: {
  44145. name: string;
  44146. shader: string;
  44147. };
  44148. }
  44149. declare module BABYLON {
  44150. /** @hidden */
  44151. export var pbrDebug: {
  44152. name: string;
  44153. shader: string;
  44154. };
  44155. }
  44156. declare module BABYLON {
  44157. /** @hidden */
  44158. export var pbrPixelShader: {
  44159. name: string;
  44160. shader: string;
  44161. };
  44162. }
  44163. declare module BABYLON {
  44164. /** @hidden */
  44165. export var pbrVertexDeclaration: {
  44166. name: string;
  44167. shader: string;
  44168. };
  44169. }
  44170. declare module BABYLON {
  44171. /** @hidden */
  44172. export var pbrVertexShader: {
  44173. name: string;
  44174. shader: string;
  44175. };
  44176. }
  44177. declare module BABYLON {
  44178. /**
  44179. * Manages the defines for the PBR Material.
  44180. * @hidden
  44181. */
  44182. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  44183. PBR: boolean;
  44184. MAINUV1: boolean;
  44185. MAINUV2: boolean;
  44186. UV1: boolean;
  44187. UV2: boolean;
  44188. ALBEDO: boolean;
  44189. ALBEDODIRECTUV: number;
  44190. VERTEXCOLOR: boolean;
  44191. AMBIENT: boolean;
  44192. AMBIENTDIRECTUV: number;
  44193. AMBIENTINGRAYSCALE: boolean;
  44194. OPACITY: boolean;
  44195. VERTEXALPHA: boolean;
  44196. OPACITYDIRECTUV: number;
  44197. OPACITYRGB: boolean;
  44198. ALPHATEST: boolean;
  44199. DEPTHPREPASS: boolean;
  44200. ALPHABLEND: boolean;
  44201. ALPHAFROMALBEDO: boolean;
  44202. ALPHATESTVALUE: string;
  44203. SPECULAROVERALPHA: boolean;
  44204. RADIANCEOVERALPHA: boolean;
  44205. ALPHAFRESNEL: boolean;
  44206. LINEARALPHAFRESNEL: boolean;
  44207. PREMULTIPLYALPHA: boolean;
  44208. EMISSIVE: boolean;
  44209. EMISSIVEDIRECTUV: number;
  44210. REFLECTIVITY: boolean;
  44211. REFLECTIVITYDIRECTUV: number;
  44212. SPECULARTERM: boolean;
  44213. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44214. MICROSURFACEAUTOMATIC: boolean;
  44215. LODBASEDMICROSFURACE: boolean;
  44216. MICROSURFACEMAP: boolean;
  44217. MICROSURFACEMAPDIRECTUV: number;
  44218. METALLICWORKFLOW: boolean;
  44219. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44220. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44221. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44222. AOSTOREINMETALMAPRED: boolean;
  44223. ENVIRONMENTBRDF: boolean;
  44224. ENVIRONMENTBRDF_RGBD: boolean;
  44225. NORMAL: boolean;
  44226. TANGENT: boolean;
  44227. BUMP: boolean;
  44228. BUMPDIRECTUV: number;
  44229. OBJECTSPACE_NORMALMAP: boolean;
  44230. PARALLAX: boolean;
  44231. PARALLAXOCCLUSION: boolean;
  44232. NORMALXYSCALE: boolean;
  44233. LIGHTMAP: boolean;
  44234. LIGHTMAPDIRECTUV: number;
  44235. USELIGHTMAPASSHADOWMAP: boolean;
  44236. GAMMALIGHTMAP: boolean;
  44237. REFLECTION: boolean;
  44238. REFLECTIONMAP_3D: boolean;
  44239. REFLECTIONMAP_SPHERICAL: boolean;
  44240. REFLECTIONMAP_PLANAR: boolean;
  44241. REFLECTIONMAP_CUBIC: boolean;
  44242. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44243. REFLECTIONMAP_PROJECTION: boolean;
  44244. REFLECTIONMAP_SKYBOX: boolean;
  44245. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44246. REFLECTIONMAP_EXPLICIT: boolean;
  44247. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44248. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44249. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44250. INVERTCUBICMAP: boolean;
  44251. USESPHERICALFROMREFLECTIONMAP: boolean;
  44252. USESPHERICALINVERTEX: boolean;
  44253. REFLECTIONMAP_OPPOSITEZ: boolean;
  44254. LODINREFLECTIONALPHA: boolean;
  44255. GAMMAREFLECTION: boolean;
  44256. RGBDREFLECTION: boolean;
  44257. RADIANCEOCCLUSION: boolean;
  44258. HORIZONOCCLUSION: boolean;
  44259. REFRACTION: boolean;
  44260. REFRACTIONMAP_3D: boolean;
  44261. REFRACTIONMAP_OPPOSITEZ: boolean;
  44262. LODINREFRACTIONALPHA: boolean;
  44263. GAMMAREFRACTION: boolean;
  44264. RGBDREFRACTION: boolean;
  44265. LINKREFRACTIONTOTRANSPARENCY: boolean;
  44266. INSTANCES: boolean;
  44267. NUM_BONE_INFLUENCERS: number;
  44268. BonesPerMesh: number;
  44269. BONETEXTURE: boolean;
  44270. NONUNIFORMSCALING: boolean;
  44271. MORPHTARGETS: boolean;
  44272. MORPHTARGETS_NORMAL: boolean;
  44273. MORPHTARGETS_TANGENT: boolean;
  44274. NUM_MORPH_INFLUENCERS: number;
  44275. IMAGEPROCESSING: boolean;
  44276. VIGNETTE: boolean;
  44277. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44278. VIGNETTEBLENDMODEOPAQUE: boolean;
  44279. TONEMAPPING: boolean;
  44280. TONEMAPPING_ACES: boolean;
  44281. CONTRAST: boolean;
  44282. COLORCURVES: boolean;
  44283. COLORGRADING: boolean;
  44284. COLORGRADING3D: boolean;
  44285. SAMPLER3DGREENDEPTH: boolean;
  44286. SAMPLER3DBGRMAP: boolean;
  44287. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44288. EXPOSURE: boolean;
  44289. MULTIVIEW: boolean;
  44290. USEPHYSICALLIGHTFALLOFF: boolean;
  44291. USEGLTFLIGHTFALLOFF: boolean;
  44292. TWOSIDEDLIGHTING: boolean;
  44293. SHADOWFLOAT: boolean;
  44294. CLIPPLANE: boolean;
  44295. CLIPPLANE2: boolean;
  44296. CLIPPLANE3: boolean;
  44297. CLIPPLANE4: boolean;
  44298. POINTSIZE: boolean;
  44299. FOG: boolean;
  44300. LOGARITHMICDEPTH: boolean;
  44301. FORCENORMALFORWARD: boolean;
  44302. SPECULARAA: boolean;
  44303. CLEARCOAT: boolean;
  44304. CLEARCOAT_DEFAULTIOR: boolean;
  44305. CLEARCOAT_TEXTURE: boolean;
  44306. CLEARCOAT_TEXTUREDIRECTUV: number;
  44307. CLEARCOAT_BUMP: boolean;
  44308. CLEARCOAT_BUMPDIRECTUV: number;
  44309. CLEARCOAT_TINT: boolean;
  44310. CLEARCOAT_TINT_TEXTURE: boolean;
  44311. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44312. ANISOTROPIC: boolean;
  44313. ANISOTROPIC_TEXTURE: boolean;
  44314. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44315. BRDF_V_HEIGHT_CORRELATED: boolean;
  44316. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44317. SHEEN: boolean;
  44318. SHEEN_TEXTURE: boolean;
  44319. SHEEN_TEXTUREDIRECTUV: number;
  44320. SHEEN_LINKWITHALBEDO: boolean;
  44321. UNLIT: boolean;
  44322. DEBUGMODE: number;
  44323. /**
  44324. * Initializes the PBR Material defines.
  44325. */
  44326. constructor();
  44327. /**
  44328. * Resets the PBR Material defines.
  44329. */
  44330. reset(): void;
  44331. }
  44332. /**
  44333. * The Physically based material base class of BJS.
  44334. *
  44335. * This offers the main features of a standard PBR material.
  44336. * For more information, please refer to the documentation :
  44337. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44338. */
  44339. export abstract class PBRBaseMaterial extends PushMaterial {
  44340. /**
  44341. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44342. */
  44343. static readonly PBRMATERIAL_OPAQUE: number;
  44344. /**
  44345. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44346. */
  44347. static readonly PBRMATERIAL_ALPHATEST: number;
  44348. /**
  44349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44350. */
  44351. static readonly PBRMATERIAL_ALPHABLEND: number;
  44352. /**
  44353. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44354. * They are also discarded below the alpha cutoff threshold to improve performances.
  44355. */
  44356. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44357. /**
  44358. * Defines the default value of how much AO map is occluding the analytical lights
  44359. * (point spot...).
  44360. */
  44361. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44362. /**
  44363. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44364. */
  44365. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44366. /**
  44367. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44368. * to enhance interoperability with other engines.
  44369. */
  44370. static readonly LIGHTFALLOFF_GLTF: number;
  44371. /**
  44372. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44373. * to enhance interoperability with other materials.
  44374. */
  44375. static readonly LIGHTFALLOFF_STANDARD: number;
  44376. /**
  44377. * Intensity of the direct lights e.g. the four lights available in your scene.
  44378. * This impacts both the direct diffuse and specular highlights.
  44379. */
  44380. protected _directIntensity: number;
  44381. /**
  44382. * Intensity of the emissive part of the material.
  44383. * This helps controlling the emissive effect without modifying the emissive color.
  44384. */
  44385. protected _emissiveIntensity: number;
  44386. /**
  44387. * Intensity of the environment e.g. how much the environment will light the object
  44388. * either through harmonics for rough material or through the refelction for shiny ones.
  44389. */
  44390. protected _environmentIntensity: number;
  44391. /**
  44392. * This is a special control allowing the reduction of the specular highlights coming from the
  44393. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44394. */
  44395. protected _specularIntensity: number;
  44396. /**
  44397. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44398. */
  44399. private _lightingInfos;
  44400. /**
  44401. * Debug Control allowing disabling the bump map on this material.
  44402. */
  44403. protected _disableBumpMap: boolean;
  44404. /**
  44405. * AKA Diffuse Texture in standard nomenclature.
  44406. */
  44407. protected _albedoTexture: BaseTexture;
  44408. /**
  44409. * AKA Occlusion Texture in other nomenclature.
  44410. */
  44411. protected _ambientTexture: BaseTexture;
  44412. /**
  44413. * AKA Occlusion Texture Intensity in other nomenclature.
  44414. */
  44415. protected _ambientTextureStrength: number;
  44416. /**
  44417. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44418. * 1 means it completely occludes it
  44419. * 0 mean it has no impact
  44420. */
  44421. protected _ambientTextureImpactOnAnalyticalLights: number;
  44422. /**
  44423. * Stores the alpha values in a texture.
  44424. */
  44425. protected _opacityTexture: BaseTexture;
  44426. /**
  44427. * Stores the reflection values in a texture.
  44428. */
  44429. protected _reflectionTexture: BaseTexture;
  44430. /**
  44431. * Stores the refraction values in a texture.
  44432. */
  44433. protected _refractionTexture: BaseTexture;
  44434. /**
  44435. * Stores the emissive values in a texture.
  44436. */
  44437. protected _emissiveTexture: BaseTexture;
  44438. /**
  44439. * AKA Specular texture in other nomenclature.
  44440. */
  44441. protected _reflectivityTexture: BaseTexture;
  44442. /**
  44443. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44444. */
  44445. protected _metallicTexture: BaseTexture;
  44446. /**
  44447. * Specifies the metallic scalar of the metallic/roughness workflow.
  44448. * Can also be used to scale the metalness values of the metallic texture.
  44449. */
  44450. protected _metallic: Nullable<number>;
  44451. /**
  44452. * Specifies the roughness scalar of the metallic/roughness workflow.
  44453. * Can also be used to scale the roughness values of the metallic texture.
  44454. */
  44455. protected _roughness: Nullable<number>;
  44456. /**
  44457. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44458. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44459. */
  44460. protected _microSurfaceTexture: BaseTexture;
  44461. /**
  44462. * Stores surface normal data used to displace a mesh in a texture.
  44463. */
  44464. protected _bumpTexture: BaseTexture;
  44465. /**
  44466. * Stores the pre-calculated light information of a mesh in a texture.
  44467. */
  44468. protected _lightmapTexture: BaseTexture;
  44469. /**
  44470. * The color of a material in ambient lighting.
  44471. */
  44472. protected _ambientColor: Color3;
  44473. /**
  44474. * AKA Diffuse Color in other nomenclature.
  44475. */
  44476. protected _albedoColor: Color3;
  44477. /**
  44478. * AKA Specular Color in other nomenclature.
  44479. */
  44480. protected _reflectivityColor: Color3;
  44481. /**
  44482. * The color applied when light is reflected from a material.
  44483. */
  44484. protected _reflectionColor: Color3;
  44485. /**
  44486. * The color applied when light is emitted from a material.
  44487. */
  44488. protected _emissiveColor: Color3;
  44489. /**
  44490. * AKA Glossiness in other nomenclature.
  44491. */
  44492. protected _microSurface: number;
  44493. /**
  44494. * source material index of refraction (IOR)' / 'destination material IOR.
  44495. */
  44496. protected _indexOfRefraction: number;
  44497. /**
  44498. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44499. */
  44500. protected _invertRefractionY: boolean;
  44501. /**
  44502. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44503. * Materials half opaque for instance using refraction could benefit from this control.
  44504. */
  44505. protected _linkRefractionWithTransparency: boolean;
  44506. /**
  44507. * Specifies that the material will use the light map as a show map.
  44508. */
  44509. protected _useLightmapAsShadowmap: boolean;
  44510. /**
  44511. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44512. * makes the reflect vector face the model (under horizon).
  44513. */
  44514. protected _useHorizonOcclusion: boolean;
  44515. /**
  44516. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44517. * too much the area relying on ambient texture to define their ambient occlusion.
  44518. */
  44519. protected _useRadianceOcclusion: boolean;
  44520. /**
  44521. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44522. */
  44523. protected _useAlphaFromAlbedoTexture: boolean;
  44524. /**
  44525. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44526. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44527. */
  44528. protected _useSpecularOverAlpha: boolean;
  44529. /**
  44530. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44531. */
  44532. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44533. /**
  44534. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44535. */
  44536. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44537. /**
  44538. * Specifies if the metallic texture contains the roughness information in its green channel.
  44539. */
  44540. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44541. /**
  44542. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44543. */
  44544. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44545. /**
  44546. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44547. */
  44548. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44549. /**
  44550. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44551. */
  44552. protected _useAmbientInGrayScale: boolean;
  44553. /**
  44554. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44555. * The material will try to infer what glossiness each pixel should be.
  44556. */
  44557. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44558. /**
  44559. * Defines the falloff type used in this material.
  44560. * It by default is Physical.
  44561. */
  44562. protected _lightFalloff: number;
  44563. /**
  44564. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44565. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44566. */
  44567. protected _useRadianceOverAlpha: boolean;
  44568. /**
  44569. * Allows using an object space normal map (instead of tangent space).
  44570. */
  44571. protected _useObjectSpaceNormalMap: boolean;
  44572. /**
  44573. * Allows using the bump map in parallax mode.
  44574. */
  44575. protected _useParallax: boolean;
  44576. /**
  44577. * Allows using the bump map in parallax occlusion mode.
  44578. */
  44579. protected _useParallaxOcclusion: boolean;
  44580. /**
  44581. * Controls the scale bias of the parallax mode.
  44582. */
  44583. protected _parallaxScaleBias: number;
  44584. /**
  44585. * If sets to true, disables all the lights affecting the material.
  44586. */
  44587. protected _disableLighting: boolean;
  44588. /**
  44589. * Number of Simultaneous lights allowed on the material.
  44590. */
  44591. protected _maxSimultaneousLights: number;
  44592. /**
  44593. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44594. */
  44595. protected _invertNormalMapX: boolean;
  44596. /**
  44597. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44598. */
  44599. protected _invertNormalMapY: boolean;
  44600. /**
  44601. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44602. */
  44603. protected _twoSidedLighting: boolean;
  44604. /**
  44605. * Defines the alpha limits in alpha test mode.
  44606. */
  44607. protected _alphaCutOff: number;
  44608. /**
  44609. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44610. */
  44611. protected _forceAlphaTest: boolean;
  44612. /**
  44613. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44614. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44615. */
  44616. protected _useAlphaFresnel: boolean;
  44617. /**
  44618. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44619. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44620. */
  44621. protected _useLinearAlphaFresnel: boolean;
  44622. /**
  44623. * The transparency mode of the material.
  44624. */
  44625. protected _transparencyMode: Nullable<number>;
  44626. /**
  44627. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44628. * from cos thetav and roughness:
  44629. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44630. */
  44631. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44632. /**
  44633. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44634. */
  44635. protected _forceIrradianceInFragment: boolean;
  44636. /**
  44637. * Force normal to face away from face.
  44638. */
  44639. protected _forceNormalForward: boolean;
  44640. /**
  44641. * Enables specular anti aliasing in the PBR shader.
  44642. * It will both interacts on the Geometry for analytical and IBL lighting.
  44643. * It also prefilter the roughness map based on the bump values.
  44644. */
  44645. protected _enableSpecularAntiAliasing: boolean;
  44646. /**
  44647. * Default configuration related to image processing available in the PBR Material.
  44648. */
  44649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44650. /**
  44651. * Keep track of the image processing observer to allow dispose and replace.
  44652. */
  44653. private _imageProcessingObserver;
  44654. /**
  44655. * Attaches a new image processing configuration to the PBR Material.
  44656. * @param configuration
  44657. */
  44658. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44659. /**
  44660. * Stores the available render targets.
  44661. */
  44662. private _renderTargets;
  44663. /**
  44664. * Sets the global ambient color for the material used in lighting calculations.
  44665. */
  44666. private _globalAmbientColor;
  44667. /**
  44668. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44669. */
  44670. private _useLogarithmicDepth;
  44671. /**
  44672. * If set to true, no lighting calculations will be applied.
  44673. */
  44674. private _unlit;
  44675. private _debugMode;
  44676. /**
  44677. * @hidden
  44678. * This is reserved for the inspector.
  44679. * Defines the material debug mode.
  44680. * It helps seeing only some components of the material while troubleshooting.
  44681. */
  44682. debugMode: number;
  44683. /**
  44684. * @hidden
  44685. * This is reserved for the inspector.
  44686. * Specify from where on screen the debug mode should start.
  44687. * The value goes from -1 (full screen) to 1 (not visible)
  44688. * It helps with side by side comparison against the final render
  44689. * This defaults to -1
  44690. */
  44691. private debugLimit;
  44692. /**
  44693. * @hidden
  44694. * This is reserved for the inspector.
  44695. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44696. * You can use the factor to better multiply the final value.
  44697. */
  44698. private debugFactor;
  44699. /**
  44700. * Defines the clear coat layer parameters for the material.
  44701. */
  44702. readonly clearCoat: PBRClearCoatConfiguration;
  44703. /**
  44704. * Defines the anisotropic parameters for the material.
  44705. */
  44706. readonly anisotropy: PBRAnisotropicConfiguration;
  44707. /**
  44708. * Defines the BRDF parameters for the material.
  44709. */
  44710. readonly brdf: PBRBRDFConfiguration;
  44711. /**
  44712. * Defines the Sheen parameters for the material.
  44713. */
  44714. readonly sheen: PBRSheenConfiguration;
  44715. /**
  44716. * Custom callback helping to override the default shader used in the material.
  44717. */
  44718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44719. /**
  44720. * Instantiates a new PBRMaterial instance.
  44721. *
  44722. * @param name The material name
  44723. * @param scene The scene the material will be use in.
  44724. */
  44725. constructor(name: string, scene: Scene);
  44726. /**
  44727. * Gets a boolean indicating that current material needs to register RTT
  44728. */
  44729. readonly hasRenderTargetTextures: boolean;
  44730. /**
  44731. * Gets the name of the material class.
  44732. */
  44733. getClassName(): string;
  44734. /**
  44735. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44736. */
  44737. /**
  44738. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44739. */
  44740. useLogarithmicDepth: boolean;
  44741. /**
  44742. * Gets the current transparency mode.
  44743. */
  44744. /**
  44745. * Sets the transparency mode of the material.
  44746. *
  44747. * | Value | Type | Description |
  44748. * | ----- | ----------------------------------- | ----------- |
  44749. * | 0 | OPAQUE | |
  44750. * | 1 | ALPHATEST | |
  44751. * | 2 | ALPHABLEND | |
  44752. * | 3 | ALPHATESTANDBLEND | |
  44753. *
  44754. */
  44755. transparencyMode: Nullable<number>;
  44756. /**
  44757. * Returns true if alpha blending should be disabled.
  44758. */
  44759. private readonly _disableAlphaBlending;
  44760. /**
  44761. * Specifies whether or not this material should be rendered in alpha blend mode.
  44762. */
  44763. needAlphaBlending(): boolean;
  44764. /**
  44765. * Specifies if the mesh will require alpha blending.
  44766. * @param mesh - BJS mesh.
  44767. */
  44768. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44769. /**
  44770. * Specifies whether or not this material should be rendered in alpha test mode.
  44771. */
  44772. needAlphaTesting(): boolean;
  44773. /**
  44774. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44775. */
  44776. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44777. /**
  44778. * Gets the texture used for the alpha test.
  44779. */
  44780. getAlphaTestTexture(): BaseTexture;
  44781. /**
  44782. * Specifies that the submesh is ready to be used.
  44783. * @param mesh - BJS mesh.
  44784. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44785. * @param useInstances - Specifies that instances should be used.
  44786. * @returns - boolean indicating that the submesh is ready or not.
  44787. */
  44788. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44789. /**
  44790. * Specifies if the material uses metallic roughness workflow.
  44791. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44792. */
  44793. isMetallicWorkflow(): boolean;
  44794. private _prepareEffect;
  44795. private _prepareDefines;
  44796. /**
  44797. * Force shader compilation
  44798. */
  44799. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44800. clipPlane: boolean;
  44801. }>): void;
  44802. /**
  44803. * Initializes the uniform buffer layout for the shader.
  44804. */
  44805. buildUniformLayout(): void;
  44806. /**
  44807. * Unbinds the textures.
  44808. */
  44809. unbind(): void;
  44810. /**
  44811. * Binds the submesh data.
  44812. * @param world - The world matrix.
  44813. * @param mesh - The BJS mesh.
  44814. * @param subMesh - A submesh of the BJS mesh.
  44815. */
  44816. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44817. /**
  44818. * Returns the animatable textures.
  44819. * @returns - Array of animatable textures.
  44820. */
  44821. getAnimatables(): IAnimatable[];
  44822. /**
  44823. * Returns the texture used for reflections.
  44824. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44825. */
  44826. private _getReflectionTexture;
  44827. /**
  44828. * Returns the texture used for refraction or null if none is used.
  44829. * @returns - Refection texture if present. If no refraction texture and refraction
  44830. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44831. */
  44832. private _getRefractionTexture;
  44833. /**
  44834. * Returns an array of the actively used textures.
  44835. * @returns - Array of BaseTextures
  44836. */
  44837. getActiveTextures(): BaseTexture[];
  44838. /**
  44839. * Checks to see if a texture is used in the material.
  44840. * @param texture - Base texture to use.
  44841. * @returns - Boolean specifying if a texture is used in the material.
  44842. */
  44843. hasTexture(texture: BaseTexture): boolean;
  44844. /**
  44845. * Disposes the resources of the material.
  44846. * @param forceDisposeEffect - Forces the disposal of effects.
  44847. * @param forceDisposeTextures - Forces the disposal of all textures.
  44848. */
  44849. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44850. }
  44851. }
  44852. declare module BABYLON {
  44853. /**
  44854. * The Physically based material of BJS.
  44855. *
  44856. * This offers the main features of a standard PBR material.
  44857. * For more information, please refer to the documentation :
  44858. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44859. */
  44860. export class PBRMaterial extends PBRBaseMaterial {
  44861. /**
  44862. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44863. */
  44864. static readonly PBRMATERIAL_OPAQUE: number;
  44865. /**
  44866. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44867. */
  44868. static readonly PBRMATERIAL_ALPHATEST: number;
  44869. /**
  44870. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44871. */
  44872. static readonly PBRMATERIAL_ALPHABLEND: number;
  44873. /**
  44874. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44875. * They are also discarded below the alpha cutoff threshold to improve performances.
  44876. */
  44877. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44878. /**
  44879. * Defines the default value of how much AO map is occluding the analytical lights
  44880. * (point spot...).
  44881. */
  44882. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44883. /**
  44884. * Intensity of the direct lights e.g. the four lights available in your scene.
  44885. * This impacts both the direct diffuse and specular highlights.
  44886. */
  44887. directIntensity: number;
  44888. /**
  44889. * Intensity of the emissive part of the material.
  44890. * This helps controlling the emissive effect without modifying the emissive color.
  44891. */
  44892. emissiveIntensity: number;
  44893. /**
  44894. * Intensity of the environment e.g. how much the environment will light the object
  44895. * either through harmonics for rough material or through the refelction for shiny ones.
  44896. */
  44897. environmentIntensity: number;
  44898. /**
  44899. * This is a special control allowing the reduction of the specular highlights coming from the
  44900. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44901. */
  44902. specularIntensity: number;
  44903. /**
  44904. * Debug Control allowing disabling the bump map on this material.
  44905. */
  44906. disableBumpMap: boolean;
  44907. /**
  44908. * AKA Diffuse Texture in standard nomenclature.
  44909. */
  44910. albedoTexture: BaseTexture;
  44911. /**
  44912. * AKA Occlusion Texture in other nomenclature.
  44913. */
  44914. ambientTexture: BaseTexture;
  44915. /**
  44916. * AKA Occlusion Texture Intensity in other nomenclature.
  44917. */
  44918. ambientTextureStrength: number;
  44919. /**
  44920. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44921. * 1 means it completely occludes it
  44922. * 0 mean it has no impact
  44923. */
  44924. ambientTextureImpactOnAnalyticalLights: number;
  44925. /**
  44926. * Stores the alpha values in a texture.
  44927. */
  44928. opacityTexture: BaseTexture;
  44929. /**
  44930. * Stores the reflection values in a texture.
  44931. */
  44932. reflectionTexture: Nullable<BaseTexture>;
  44933. /**
  44934. * Stores the emissive values in a texture.
  44935. */
  44936. emissiveTexture: BaseTexture;
  44937. /**
  44938. * AKA Specular texture in other nomenclature.
  44939. */
  44940. reflectivityTexture: BaseTexture;
  44941. /**
  44942. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44943. */
  44944. metallicTexture: BaseTexture;
  44945. /**
  44946. * Specifies the metallic scalar of the metallic/roughness workflow.
  44947. * Can also be used to scale the metalness values of the metallic texture.
  44948. */
  44949. metallic: Nullable<number>;
  44950. /**
  44951. * Specifies the roughness scalar of the metallic/roughness workflow.
  44952. * Can also be used to scale the roughness values of the metallic texture.
  44953. */
  44954. roughness: Nullable<number>;
  44955. /**
  44956. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44957. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44958. */
  44959. microSurfaceTexture: BaseTexture;
  44960. /**
  44961. * Stores surface normal data used to displace a mesh in a texture.
  44962. */
  44963. bumpTexture: BaseTexture;
  44964. /**
  44965. * Stores the pre-calculated light information of a mesh in a texture.
  44966. */
  44967. lightmapTexture: BaseTexture;
  44968. /**
  44969. * Stores the refracted light information in a texture.
  44970. */
  44971. refractionTexture: BaseTexture;
  44972. /**
  44973. * The color of a material in ambient lighting.
  44974. */
  44975. ambientColor: Color3;
  44976. /**
  44977. * AKA Diffuse Color in other nomenclature.
  44978. */
  44979. albedoColor: Color3;
  44980. /**
  44981. * AKA Specular Color in other nomenclature.
  44982. */
  44983. reflectivityColor: Color3;
  44984. /**
  44985. * The color reflected from the material.
  44986. */
  44987. reflectionColor: Color3;
  44988. /**
  44989. * The color emitted from the material.
  44990. */
  44991. emissiveColor: Color3;
  44992. /**
  44993. * AKA Glossiness in other nomenclature.
  44994. */
  44995. microSurface: number;
  44996. /**
  44997. * source material index of refraction (IOR)' / 'destination material IOR.
  44998. */
  44999. indexOfRefraction: number;
  45000. /**
  45001. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45002. */
  45003. invertRefractionY: boolean;
  45004. /**
  45005. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45006. * Materials half opaque for instance using refraction could benefit from this control.
  45007. */
  45008. linkRefractionWithTransparency: boolean;
  45009. /**
  45010. * If true, the light map contains occlusion information instead of lighting info.
  45011. */
  45012. useLightmapAsShadowmap: boolean;
  45013. /**
  45014. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45015. */
  45016. useAlphaFromAlbedoTexture: boolean;
  45017. /**
  45018. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45019. */
  45020. forceAlphaTest: boolean;
  45021. /**
  45022. * Defines the alpha limits in alpha test mode.
  45023. */
  45024. alphaCutOff: number;
  45025. /**
  45026. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45027. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45028. */
  45029. useSpecularOverAlpha: boolean;
  45030. /**
  45031. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45032. */
  45033. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45034. /**
  45035. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45036. */
  45037. useRoughnessFromMetallicTextureAlpha: boolean;
  45038. /**
  45039. * Specifies if the metallic texture contains the roughness information in its green channel.
  45040. */
  45041. useRoughnessFromMetallicTextureGreen: boolean;
  45042. /**
  45043. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45044. */
  45045. useMetallnessFromMetallicTextureBlue: boolean;
  45046. /**
  45047. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45048. */
  45049. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45050. /**
  45051. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45052. */
  45053. useAmbientInGrayScale: boolean;
  45054. /**
  45055. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45056. * The material will try to infer what glossiness each pixel should be.
  45057. */
  45058. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45059. /**
  45060. * BJS is using an harcoded light falloff based on a manually sets up range.
  45061. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45062. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45063. */
  45064. /**
  45065. * BJS is using an harcoded light falloff based on a manually sets up range.
  45066. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45067. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45068. */
  45069. usePhysicalLightFalloff: boolean;
  45070. /**
  45071. * In order to support the falloff compatibility with gltf, a special mode has been added
  45072. * to reproduce the gltf light falloff.
  45073. */
  45074. /**
  45075. * In order to support the falloff compatibility with gltf, a special mode has been added
  45076. * to reproduce the gltf light falloff.
  45077. */
  45078. useGLTFLightFalloff: boolean;
  45079. /**
  45080. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45081. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45082. */
  45083. useRadianceOverAlpha: boolean;
  45084. /**
  45085. * Allows using an object space normal map (instead of tangent space).
  45086. */
  45087. useObjectSpaceNormalMap: boolean;
  45088. /**
  45089. * Allows using the bump map in parallax mode.
  45090. */
  45091. useParallax: boolean;
  45092. /**
  45093. * Allows using the bump map in parallax occlusion mode.
  45094. */
  45095. useParallaxOcclusion: boolean;
  45096. /**
  45097. * Controls the scale bias of the parallax mode.
  45098. */
  45099. parallaxScaleBias: number;
  45100. /**
  45101. * If sets to true, disables all the lights affecting the material.
  45102. */
  45103. disableLighting: boolean;
  45104. /**
  45105. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45106. */
  45107. forceIrradianceInFragment: boolean;
  45108. /**
  45109. * Number of Simultaneous lights allowed on the material.
  45110. */
  45111. maxSimultaneousLights: number;
  45112. /**
  45113. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45114. */
  45115. invertNormalMapX: boolean;
  45116. /**
  45117. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45118. */
  45119. invertNormalMapY: boolean;
  45120. /**
  45121. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45122. */
  45123. twoSidedLighting: boolean;
  45124. /**
  45125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45126. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45127. */
  45128. useAlphaFresnel: boolean;
  45129. /**
  45130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45131. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45132. */
  45133. useLinearAlphaFresnel: boolean;
  45134. /**
  45135. * Let user defines the brdf lookup texture used for IBL.
  45136. * A default 8bit version is embedded but you could point at :
  45137. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45138. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45139. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45140. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45141. */
  45142. environmentBRDFTexture: Nullable<BaseTexture>;
  45143. /**
  45144. * Force normal to face away from face.
  45145. */
  45146. forceNormalForward: boolean;
  45147. /**
  45148. * Enables specular anti aliasing in the PBR shader.
  45149. * It will both interacts on the Geometry for analytical and IBL lighting.
  45150. * It also prefilter the roughness map based on the bump values.
  45151. */
  45152. enableSpecularAntiAliasing: boolean;
  45153. /**
  45154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45155. * makes the reflect vector face the model (under horizon).
  45156. */
  45157. useHorizonOcclusion: boolean;
  45158. /**
  45159. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45160. * too much the area relying on ambient texture to define their ambient occlusion.
  45161. */
  45162. useRadianceOcclusion: boolean;
  45163. /**
  45164. * If set to true, no lighting calculations will be applied.
  45165. */
  45166. unlit: boolean;
  45167. /**
  45168. * Gets the image processing configuration used either in this material.
  45169. */
  45170. /**
  45171. * Sets the Default image processing configuration used either in the this material.
  45172. *
  45173. * If sets to null, the scene one is in use.
  45174. */
  45175. imageProcessingConfiguration: ImageProcessingConfiguration;
  45176. /**
  45177. * Gets wether the color curves effect is enabled.
  45178. */
  45179. /**
  45180. * Sets wether the color curves effect is enabled.
  45181. */
  45182. cameraColorCurvesEnabled: boolean;
  45183. /**
  45184. * Gets wether the color grading effect is enabled.
  45185. */
  45186. /**
  45187. * Gets wether the color grading effect is enabled.
  45188. */
  45189. cameraColorGradingEnabled: boolean;
  45190. /**
  45191. * Gets wether tonemapping is enabled or not.
  45192. */
  45193. /**
  45194. * Sets wether tonemapping is enabled or not
  45195. */
  45196. cameraToneMappingEnabled: boolean;
  45197. /**
  45198. * The camera exposure used on this material.
  45199. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45200. * This corresponds to a photographic exposure.
  45201. */
  45202. /**
  45203. * The camera exposure used on this material.
  45204. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45205. * This corresponds to a photographic exposure.
  45206. */
  45207. cameraExposure: number;
  45208. /**
  45209. * Gets The camera contrast used on this material.
  45210. */
  45211. /**
  45212. * Sets The camera contrast used on this material.
  45213. */
  45214. cameraContrast: number;
  45215. /**
  45216. * Gets the Color Grading 2D Lookup Texture.
  45217. */
  45218. /**
  45219. * Sets the Color Grading 2D Lookup Texture.
  45220. */
  45221. cameraColorGradingTexture: Nullable<BaseTexture>;
  45222. /**
  45223. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45224. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45225. * 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;
  45226. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45227. */
  45228. /**
  45229. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45230. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45231. * 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;
  45232. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45233. */
  45234. cameraColorCurves: Nullable<ColorCurves>;
  45235. /**
  45236. * Instantiates a new PBRMaterial instance.
  45237. *
  45238. * @param name The material name
  45239. * @param scene The scene the material will be use in.
  45240. */
  45241. constructor(name: string, scene: Scene);
  45242. /**
  45243. * Returns the name of this material class.
  45244. */
  45245. getClassName(): string;
  45246. /**
  45247. * Makes a duplicate of the current material.
  45248. * @param name - name to use for the new material.
  45249. */
  45250. clone(name: string): PBRMaterial;
  45251. /**
  45252. * Serializes this PBR Material.
  45253. * @returns - An object with the serialized material.
  45254. */
  45255. serialize(): any;
  45256. /**
  45257. * Parses a PBR Material from a serialized object.
  45258. * @param source - Serialized object.
  45259. * @param scene - BJS scene instance.
  45260. * @param rootUrl - url for the scene object
  45261. * @returns - PBRMaterial
  45262. */
  45263. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /**
  45268. * Direct draw surface info
  45269. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45270. */
  45271. export interface DDSInfo {
  45272. /**
  45273. * Width of the texture
  45274. */
  45275. width: number;
  45276. /**
  45277. * Width of the texture
  45278. */
  45279. height: number;
  45280. /**
  45281. * Number of Mipmaps for the texture
  45282. * @see https://en.wikipedia.org/wiki/Mipmap
  45283. */
  45284. mipmapCount: number;
  45285. /**
  45286. * If the textures format is a known fourCC format
  45287. * @see https://www.fourcc.org/
  45288. */
  45289. isFourCC: boolean;
  45290. /**
  45291. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45292. */
  45293. isRGB: boolean;
  45294. /**
  45295. * If the texture is a lumincance format
  45296. */
  45297. isLuminance: boolean;
  45298. /**
  45299. * If this is a cube texture
  45300. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45301. */
  45302. isCube: boolean;
  45303. /**
  45304. * If the texture is a compressed format eg. FOURCC_DXT1
  45305. */
  45306. isCompressed: boolean;
  45307. /**
  45308. * The dxgiFormat of the texture
  45309. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45310. */
  45311. dxgiFormat: number;
  45312. /**
  45313. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45314. */
  45315. textureType: number;
  45316. /**
  45317. * Sphericle polynomial created for the dds texture
  45318. */
  45319. sphericalPolynomial?: SphericalPolynomial;
  45320. }
  45321. /**
  45322. * Class used to provide DDS decompression tools
  45323. */
  45324. export class DDSTools {
  45325. /**
  45326. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45327. */
  45328. static StoreLODInAlphaChannel: boolean;
  45329. /**
  45330. * Gets DDS information from an array buffer
  45331. * @param arrayBuffer defines the array buffer to read data from
  45332. * @returns the DDS information
  45333. */
  45334. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45335. private static _FloatView;
  45336. private static _Int32View;
  45337. private static _ToHalfFloat;
  45338. private static _FromHalfFloat;
  45339. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45340. private static _GetHalfFloatRGBAArrayBuffer;
  45341. private static _GetFloatRGBAArrayBuffer;
  45342. private static _GetFloatAsUIntRGBAArrayBuffer;
  45343. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45344. private static _GetRGBAArrayBuffer;
  45345. private static _ExtractLongWordOrder;
  45346. private static _GetRGBArrayBuffer;
  45347. private static _GetLuminanceArrayBuffer;
  45348. /**
  45349. * Uploads DDS Levels to a Babylon Texture
  45350. * @hidden
  45351. */
  45352. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45353. }
  45354. interface Engine {
  45355. /**
  45356. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45357. * @param rootUrl defines the url where the file to load is located
  45358. * @param scene defines the current scene
  45359. * @param lodScale defines scale to apply to the mip map selection
  45360. * @param lodOffset defines offset to apply to the mip map selection
  45361. * @param onLoad defines an optional callback raised when the texture is loaded
  45362. * @param onError defines an optional callback raised if there is an issue to load the texture
  45363. * @param format defines the format of the data
  45364. * @param forcedExtension defines the extension to use to pick the right loader
  45365. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45366. * @returns the cube texture as an InternalTexture
  45367. */
  45368. 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;
  45369. }
  45370. }
  45371. declare module BABYLON {
  45372. /**
  45373. * Implementation of the DDS Texture Loader.
  45374. * @hidden
  45375. */
  45376. export class _DDSTextureLoader implements IInternalTextureLoader {
  45377. /**
  45378. * Defines wether the loader supports cascade loading the different faces.
  45379. */
  45380. readonly supportCascades: boolean;
  45381. /**
  45382. * This returns if the loader support the current file information.
  45383. * @param extension defines the file extension of the file being loaded
  45384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45385. * @param fallback defines the fallback internal texture if any
  45386. * @param isBase64 defines whether the texture is encoded as a base64
  45387. * @param isBuffer defines whether the texture data are stored as a buffer
  45388. * @returns true if the loader can load the specified file
  45389. */
  45390. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45391. /**
  45392. * Transform the url before loading if required.
  45393. * @param rootUrl the url of the texture
  45394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45395. * @returns the transformed texture
  45396. */
  45397. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45398. /**
  45399. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45400. * @param rootUrl the url of the texture
  45401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45402. * @returns the fallback texture
  45403. */
  45404. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45405. /**
  45406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45407. * @param data contains the texture data
  45408. * @param texture defines the BabylonJS internal texture
  45409. * @param createPolynomials will be true if polynomials have been requested
  45410. * @param onLoad defines the callback to trigger once the texture is ready
  45411. * @param onError defines the callback to trigger in case of error
  45412. */
  45413. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45414. /**
  45415. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45416. * @param data contains the texture data
  45417. * @param texture defines the BabylonJS internal texture
  45418. * @param callback defines the method to call once ready to upload
  45419. */
  45420. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45421. }
  45422. }
  45423. declare module BABYLON {
  45424. /** @hidden */
  45425. export var rgbdEncodePixelShader: {
  45426. name: string;
  45427. shader: string;
  45428. };
  45429. }
  45430. declare module BABYLON {
  45431. /** @hidden */
  45432. export var rgbdDecodePixelShader: {
  45433. name: string;
  45434. shader: string;
  45435. };
  45436. }
  45437. declare module BABYLON {
  45438. /**
  45439. * Raw texture data and descriptor sufficient for WebGL texture upload
  45440. */
  45441. export interface EnvironmentTextureInfo {
  45442. /**
  45443. * Version of the environment map
  45444. */
  45445. version: number;
  45446. /**
  45447. * Width of image
  45448. */
  45449. width: number;
  45450. /**
  45451. * Irradiance information stored in the file.
  45452. */
  45453. irradiance: any;
  45454. /**
  45455. * Specular information stored in the file.
  45456. */
  45457. specular: any;
  45458. }
  45459. /**
  45460. * Sets of helpers addressing the serialization and deserialization of environment texture
  45461. * stored in a BabylonJS env file.
  45462. * Those files are usually stored as .env files.
  45463. */
  45464. export class EnvironmentTextureTools {
  45465. /**
  45466. * Magic number identifying the env file.
  45467. */
  45468. private static _MagicBytes;
  45469. /**
  45470. * Gets the environment info from an env file.
  45471. * @param data The array buffer containing the .env bytes.
  45472. * @returns the environment file info (the json header) if successfully parsed.
  45473. */
  45474. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45475. /**
  45476. * Creates an environment texture from a loaded cube texture.
  45477. * @param texture defines the cube texture to convert in env file
  45478. * @return a promise containing the environment data if succesfull.
  45479. */
  45480. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45481. /**
  45482. * Creates a JSON representation of the spherical data.
  45483. * @param texture defines the texture containing the polynomials
  45484. * @return the JSON representation of the spherical info
  45485. */
  45486. private static _CreateEnvTextureIrradiance;
  45487. /**
  45488. * Uploads the texture info contained in the env file to the GPU.
  45489. * @param texture defines the internal texture to upload to
  45490. * @param arrayBuffer defines the buffer cotaining the data to load
  45491. * @param info defines the texture info retrieved through the GetEnvInfo method
  45492. * @returns a promise
  45493. */
  45494. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45495. /**
  45496. * Uploads the levels of image data to the GPU.
  45497. * @param texture defines the internal texture to upload to
  45498. * @param imageData defines the array buffer views of image data [mipmap][face]
  45499. * @returns a promise
  45500. */
  45501. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45502. /**
  45503. * Uploads spherical polynomials information to the texture.
  45504. * @param texture defines the texture we are trying to upload the information to
  45505. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45506. */
  45507. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45508. /** @hidden */
  45509. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45510. }
  45511. }
  45512. declare module BABYLON {
  45513. /**
  45514. * Implementation of the ENV Texture Loader.
  45515. * @hidden
  45516. */
  45517. export class _ENVTextureLoader implements IInternalTextureLoader {
  45518. /**
  45519. * Defines wether the loader supports cascade loading the different faces.
  45520. */
  45521. readonly supportCascades: boolean;
  45522. /**
  45523. * This returns if the loader support the current file information.
  45524. * @param extension defines the file extension of the file being loaded
  45525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45526. * @param fallback defines the fallback internal texture if any
  45527. * @param isBase64 defines whether the texture is encoded as a base64
  45528. * @param isBuffer defines whether the texture data are stored as a buffer
  45529. * @returns true if the loader can load the specified file
  45530. */
  45531. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45532. /**
  45533. * Transform the url before loading if required.
  45534. * @param rootUrl the url of the texture
  45535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45536. * @returns the transformed texture
  45537. */
  45538. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45539. /**
  45540. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45541. * @param rootUrl the url of the texture
  45542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45543. * @returns the fallback texture
  45544. */
  45545. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45546. /**
  45547. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45548. * @param data contains the texture data
  45549. * @param texture defines the BabylonJS internal texture
  45550. * @param createPolynomials will be true if polynomials have been requested
  45551. * @param onLoad defines the callback to trigger once the texture is ready
  45552. * @param onError defines the callback to trigger in case of error
  45553. */
  45554. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45555. /**
  45556. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45557. * @param data contains the texture data
  45558. * @param texture defines the BabylonJS internal texture
  45559. * @param callback defines the method to call once ready to upload
  45560. */
  45561. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45562. }
  45563. }
  45564. declare module BABYLON {
  45565. /**
  45566. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45567. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45568. */
  45569. export class KhronosTextureContainer {
  45570. /** contents of the KTX container file */
  45571. arrayBuffer: any;
  45572. private static HEADER_LEN;
  45573. private static COMPRESSED_2D;
  45574. private static COMPRESSED_3D;
  45575. private static TEX_2D;
  45576. private static TEX_3D;
  45577. /**
  45578. * Gets the openGL type
  45579. */
  45580. glType: number;
  45581. /**
  45582. * Gets the openGL type size
  45583. */
  45584. glTypeSize: number;
  45585. /**
  45586. * Gets the openGL format
  45587. */
  45588. glFormat: number;
  45589. /**
  45590. * Gets the openGL internal format
  45591. */
  45592. glInternalFormat: number;
  45593. /**
  45594. * Gets the base internal format
  45595. */
  45596. glBaseInternalFormat: number;
  45597. /**
  45598. * Gets image width in pixel
  45599. */
  45600. pixelWidth: number;
  45601. /**
  45602. * Gets image height in pixel
  45603. */
  45604. pixelHeight: number;
  45605. /**
  45606. * Gets image depth in pixels
  45607. */
  45608. pixelDepth: number;
  45609. /**
  45610. * Gets the number of array elements
  45611. */
  45612. numberOfArrayElements: number;
  45613. /**
  45614. * Gets the number of faces
  45615. */
  45616. numberOfFaces: number;
  45617. /**
  45618. * Gets the number of mipmap levels
  45619. */
  45620. numberOfMipmapLevels: number;
  45621. /**
  45622. * Gets the bytes of key value data
  45623. */
  45624. bytesOfKeyValueData: number;
  45625. /**
  45626. * Gets the load type
  45627. */
  45628. loadType: number;
  45629. /**
  45630. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45631. */
  45632. isInvalid: boolean;
  45633. /**
  45634. * Creates a new KhronosTextureContainer
  45635. * @param arrayBuffer contents of the KTX container file
  45636. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45637. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45638. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45639. */
  45640. constructor(
  45641. /** contents of the KTX container file */
  45642. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45643. /**
  45644. * Uploads KTX content to a Babylon Texture.
  45645. * It is assumed that the texture has already been created & is currently bound
  45646. * @hidden
  45647. */
  45648. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45649. private _upload2DCompressedLevels;
  45650. }
  45651. }
  45652. declare module BABYLON {
  45653. /**
  45654. * Implementation of the KTX Texture Loader.
  45655. * @hidden
  45656. */
  45657. export class _KTXTextureLoader implements IInternalTextureLoader {
  45658. /**
  45659. * Defines wether the loader supports cascade loading the different faces.
  45660. */
  45661. readonly supportCascades: boolean;
  45662. /**
  45663. * This returns if the loader support the current file information.
  45664. * @param extension defines the file extension of the file being loaded
  45665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45666. * @param fallback defines the fallback internal texture if any
  45667. * @param isBase64 defines whether the texture is encoded as a base64
  45668. * @param isBuffer defines whether the texture data are stored as a buffer
  45669. * @returns true if the loader can load the specified file
  45670. */
  45671. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45672. /**
  45673. * Transform the url before loading if required.
  45674. * @param rootUrl the url of the texture
  45675. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45676. * @returns the transformed texture
  45677. */
  45678. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45679. /**
  45680. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45681. * @param rootUrl the url of the texture
  45682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45683. * @returns the fallback texture
  45684. */
  45685. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45686. /**
  45687. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45688. * @param data contains the texture data
  45689. * @param texture defines the BabylonJS internal texture
  45690. * @param createPolynomials will be true if polynomials have been requested
  45691. * @param onLoad defines the callback to trigger once the texture is ready
  45692. * @param onError defines the callback to trigger in case of error
  45693. */
  45694. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45695. /**
  45696. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45697. * @param data contains the texture data
  45698. * @param texture defines the BabylonJS internal texture
  45699. * @param callback defines the method to call once ready to upload
  45700. */
  45701. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45702. }
  45703. }
  45704. declare module BABYLON {
  45705. /** @hidden */
  45706. export var _forceSceneHelpersToBundle: boolean;
  45707. interface Scene {
  45708. /**
  45709. * Creates a default light for the scene.
  45710. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45711. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45712. */
  45713. createDefaultLight(replace?: boolean): void;
  45714. /**
  45715. * Creates a default camera for the scene.
  45716. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45717. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45718. * @param replace has default false, when true replaces the active camera in the scene
  45719. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45720. */
  45721. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45722. /**
  45723. * Creates a default camera and a default light.
  45724. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45725. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45726. * @param replace has the default false, when true replaces the active camera/light in the scene
  45727. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45728. */
  45729. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45730. /**
  45731. * Creates a new sky box
  45732. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45733. * @param environmentTexture defines the texture to use as environment texture
  45734. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45735. * @param scale defines the overall scale of the skybox
  45736. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45737. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45738. * @returns a new mesh holding the sky box
  45739. */
  45740. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45741. /**
  45742. * Creates a new environment
  45743. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45744. * @param options defines the options you can use to configure the environment
  45745. * @returns the new EnvironmentHelper
  45746. */
  45747. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45748. /**
  45749. * Creates a new VREXperienceHelper
  45750. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45751. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45752. * @returns a new VREXperienceHelper
  45753. */
  45754. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45755. /**
  45756. * Creates a new XREXperienceHelper
  45757. * @see http://doc.babylonjs.com/how_to/webxr
  45758. * @returns a promise for a new XREXperienceHelper
  45759. */
  45760. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45761. }
  45762. }
  45763. declare module BABYLON {
  45764. /**
  45765. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45766. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45767. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45768. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45769. */
  45770. export class VideoDome extends TransformNode {
  45771. /**
  45772. * Define the video source as a Monoscopic panoramic 360 video.
  45773. */
  45774. static readonly MODE_MONOSCOPIC: number;
  45775. /**
  45776. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45777. */
  45778. static readonly MODE_TOPBOTTOM: number;
  45779. /**
  45780. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45781. */
  45782. static readonly MODE_SIDEBYSIDE: number;
  45783. private _useDirectMapping;
  45784. /**
  45785. * The video texture being displayed on the sphere
  45786. */
  45787. protected _videoTexture: VideoTexture;
  45788. /**
  45789. * Gets the video texture being displayed on the sphere
  45790. */
  45791. readonly videoTexture: VideoTexture;
  45792. /**
  45793. * The skybox material
  45794. */
  45795. protected _material: BackgroundMaterial;
  45796. /**
  45797. * The surface used for the skybox
  45798. */
  45799. protected _mesh: Mesh;
  45800. /**
  45801. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45802. * Also see the options.resolution property.
  45803. */
  45804. fovMultiplier: number;
  45805. private _videoMode;
  45806. /**
  45807. * Gets or set the current video mode for the video. It can be:
  45808. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45809. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45810. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45811. */
  45812. videoMode: number;
  45813. /**
  45814. * Oberserver used in Stereoscopic VR Mode.
  45815. */
  45816. private _onBeforeCameraRenderObserver;
  45817. /**
  45818. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45819. * @param name Element's name, child elements will append suffixes for their own names.
  45820. * @param urlsOrVideo defines the url(s) or the video element to use
  45821. * @param options An object containing optional or exposed sub element properties
  45822. */
  45823. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45824. resolution?: number;
  45825. clickToPlay?: boolean;
  45826. autoPlay?: boolean;
  45827. loop?: boolean;
  45828. size?: number;
  45829. poster?: string;
  45830. faceForward?: boolean;
  45831. useDirectMapping?: boolean;
  45832. }, scene: Scene);
  45833. private _changeVideoMode;
  45834. /**
  45835. * Releases resources associated with this node.
  45836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45838. */
  45839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45840. }
  45841. }
  45842. declare module BABYLON {
  45843. /**
  45844. * This class can be used to get instrumentation data from a Babylon engine
  45845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45846. */
  45847. export class EngineInstrumentation implements IDisposable {
  45848. /**
  45849. * Define the instrumented engine.
  45850. */
  45851. engine: Engine;
  45852. private _captureGPUFrameTime;
  45853. private _gpuFrameTimeToken;
  45854. private _gpuFrameTime;
  45855. private _captureShaderCompilationTime;
  45856. private _shaderCompilationTime;
  45857. private _onBeginFrameObserver;
  45858. private _onEndFrameObserver;
  45859. private _onBeforeShaderCompilationObserver;
  45860. private _onAfterShaderCompilationObserver;
  45861. /**
  45862. * Gets the perf counter used for GPU frame time
  45863. */
  45864. readonly gpuFrameTimeCounter: PerfCounter;
  45865. /**
  45866. * Gets the GPU frame time capture status
  45867. */
  45868. /**
  45869. * Enable or disable the GPU frame time capture
  45870. */
  45871. captureGPUFrameTime: boolean;
  45872. /**
  45873. * Gets the perf counter used for shader compilation time
  45874. */
  45875. readonly shaderCompilationTimeCounter: PerfCounter;
  45876. /**
  45877. * Gets the shader compilation time capture status
  45878. */
  45879. /**
  45880. * Enable or disable the shader compilation time capture
  45881. */
  45882. captureShaderCompilationTime: boolean;
  45883. /**
  45884. * Instantiates a new engine instrumentation.
  45885. * This class can be used to get instrumentation data from a Babylon engine
  45886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45887. * @param engine Defines the engine to instrument
  45888. */
  45889. constructor(
  45890. /**
  45891. * Define the instrumented engine.
  45892. */
  45893. engine: Engine);
  45894. /**
  45895. * Dispose and release associated resources.
  45896. */
  45897. dispose(): void;
  45898. }
  45899. }
  45900. declare module BABYLON {
  45901. /**
  45902. * This class can be used to get instrumentation data from a Babylon engine
  45903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45904. */
  45905. export class SceneInstrumentation implements IDisposable {
  45906. /**
  45907. * Defines the scene to instrument
  45908. */
  45909. scene: Scene;
  45910. private _captureActiveMeshesEvaluationTime;
  45911. private _activeMeshesEvaluationTime;
  45912. private _captureRenderTargetsRenderTime;
  45913. private _renderTargetsRenderTime;
  45914. private _captureFrameTime;
  45915. private _frameTime;
  45916. private _captureRenderTime;
  45917. private _renderTime;
  45918. private _captureInterFrameTime;
  45919. private _interFrameTime;
  45920. private _captureParticlesRenderTime;
  45921. private _particlesRenderTime;
  45922. private _captureSpritesRenderTime;
  45923. private _spritesRenderTime;
  45924. private _capturePhysicsTime;
  45925. private _physicsTime;
  45926. private _captureAnimationsTime;
  45927. private _animationsTime;
  45928. private _captureCameraRenderTime;
  45929. private _cameraRenderTime;
  45930. private _onBeforeActiveMeshesEvaluationObserver;
  45931. private _onAfterActiveMeshesEvaluationObserver;
  45932. private _onBeforeRenderTargetsRenderObserver;
  45933. private _onAfterRenderTargetsRenderObserver;
  45934. private _onAfterRenderObserver;
  45935. private _onBeforeDrawPhaseObserver;
  45936. private _onAfterDrawPhaseObserver;
  45937. private _onBeforeAnimationsObserver;
  45938. private _onBeforeParticlesRenderingObserver;
  45939. private _onAfterParticlesRenderingObserver;
  45940. private _onBeforeSpritesRenderingObserver;
  45941. private _onAfterSpritesRenderingObserver;
  45942. private _onBeforePhysicsObserver;
  45943. private _onAfterPhysicsObserver;
  45944. private _onAfterAnimationsObserver;
  45945. private _onBeforeCameraRenderObserver;
  45946. private _onAfterCameraRenderObserver;
  45947. /**
  45948. * Gets the perf counter used for active meshes evaluation time
  45949. */
  45950. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45951. /**
  45952. * Gets the active meshes evaluation time capture status
  45953. */
  45954. /**
  45955. * Enable or disable the active meshes evaluation time capture
  45956. */
  45957. captureActiveMeshesEvaluationTime: boolean;
  45958. /**
  45959. * Gets the perf counter used for render targets render time
  45960. */
  45961. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45962. /**
  45963. * Gets the render targets render time capture status
  45964. */
  45965. /**
  45966. * Enable or disable the render targets render time capture
  45967. */
  45968. captureRenderTargetsRenderTime: boolean;
  45969. /**
  45970. * Gets the perf counter used for particles render time
  45971. */
  45972. readonly particlesRenderTimeCounter: PerfCounter;
  45973. /**
  45974. * Gets the particles render time capture status
  45975. */
  45976. /**
  45977. * Enable or disable the particles render time capture
  45978. */
  45979. captureParticlesRenderTime: boolean;
  45980. /**
  45981. * Gets the perf counter used for sprites render time
  45982. */
  45983. readonly spritesRenderTimeCounter: PerfCounter;
  45984. /**
  45985. * Gets the sprites render time capture status
  45986. */
  45987. /**
  45988. * Enable or disable the sprites render time capture
  45989. */
  45990. captureSpritesRenderTime: boolean;
  45991. /**
  45992. * Gets the perf counter used for physics time
  45993. */
  45994. readonly physicsTimeCounter: PerfCounter;
  45995. /**
  45996. * Gets the physics time capture status
  45997. */
  45998. /**
  45999. * Enable or disable the physics time capture
  46000. */
  46001. capturePhysicsTime: boolean;
  46002. /**
  46003. * Gets the perf counter used for animations time
  46004. */
  46005. readonly animationsTimeCounter: PerfCounter;
  46006. /**
  46007. * Gets the animations time capture status
  46008. */
  46009. /**
  46010. * Enable or disable the animations time capture
  46011. */
  46012. captureAnimationsTime: boolean;
  46013. /**
  46014. * Gets the perf counter used for frame time capture
  46015. */
  46016. readonly frameTimeCounter: PerfCounter;
  46017. /**
  46018. * Gets the frame time capture status
  46019. */
  46020. /**
  46021. * Enable or disable the frame time capture
  46022. */
  46023. captureFrameTime: boolean;
  46024. /**
  46025. * Gets the perf counter used for inter-frames time capture
  46026. */
  46027. readonly interFrameTimeCounter: PerfCounter;
  46028. /**
  46029. * Gets the inter-frames time capture status
  46030. */
  46031. /**
  46032. * Enable or disable the inter-frames time capture
  46033. */
  46034. captureInterFrameTime: boolean;
  46035. /**
  46036. * Gets the perf counter used for render time capture
  46037. */
  46038. readonly renderTimeCounter: PerfCounter;
  46039. /**
  46040. * Gets the render time capture status
  46041. */
  46042. /**
  46043. * Enable or disable the render time capture
  46044. */
  46045. captureRenderTime: boolean;
  46046. /**
  46047. * Gets the perf counter used for camera render time capture
  46048. */
  46049. readonly cameraRenderTimeCounter: PerfCounter;
  46050. /**
  46051. * Gets the camera render time capture status
  46052. */
  46053. /**
  46054. * Enable or disable the camera render time capture
  46055. */
  46056. captureCameraRenderTime: boolean;
  46057. /**
  46058. * Gets the perf counter used for draw calls
  46059. */
  46060. readonly drawCallsCounter: PerfCounter;
  46061. /**
  46062. * Gets the perf counter used for texture collisions
  46063. */
  46064. readonly textureCollisionsCounter: PerfCounter;
  46065. /**
  46066. * Instantiates a new scene instrumentation.
  46067. * This class can be used to get instrumentation data from a Babylon engine
  46068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46069. * @param scene Defines the scene to instrument
  46070. */
  46071. constructor(
  46072. /**
  46073. * Defines the scene to instrument
  46074. */
  46075. scene: Scene);
  46076. /**
  46077. * Dispose and release associated resources.
  46078. */
  46079. dispose(): void;
  46080. }
  46081. }
  46082. declare module BABYLON {
  46083. /** @hidden */
  46084. export var glowMapGenerationPixelShader: {
  46085. name: string;
  46086. shader: string;
  46087. };
  46088. }
  46089. declare module BABYLON {
  46090. /** @hidden */
  46091. export var glowMapGenerationVertexShader: {
  46092. name: string;
  46093. shader: string;
  46094. };
  46095. }
  46096. declare module BABYLON {
  46097. /**
  46098. * Effect layer options. This helps customizing the behaviour
  46099. * of the effect layer.
  46100. */
  46101. export interface IEffectLayerOptions {
  46102. /**
  46103. * Multiplication factor apply to the canvas size to compute the render target size
  46104. * used to generated the objects (the smaller the faster).
  46105. */
  46106. mainTextureRatio: number;
  46107. /**
  46108. * Enforces a fixed size texture to ensure effect stability across devices.
  46109. */
  46110. mainTextureFixedSize?: number;
  46111. /**
  46112. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46113. */
  46114. alphaBlendingMode: number;
  46115. /**
  46116. * The camera attached to the layer.
  46117. */
  46118. camera: Nullable<Camera>;
  46119. /**
  46120. * The rendering group to draw the layer in.
  46121. */
  46122. renderingGroupId: number;
  46123. }
  46124. /**
  46125. * The effect layer Helps adding post process effect blended with the main pass.
  46126. *
  46127. * This can be for instance use to generate glow or higlight effects on the scene.
  46128. *
  46129. * The effect layer class can not be used directly and is intented to inherited from to be
  46130. * customized per effects.
  46131. */
  46132. export abstract class EffectLayer {
  46133. private _vertexBuffers;
  46134. private _indexBuffer;
  46135. private _cachedDefines;
  46136. private _effectLayerMapGenerationEffect;
  46137. private _effectLayerOptions;
  46138. private _mergeEffect;
  46139. protected _scene: Scene;
  46140. protected _engine: Engine;
  46141. protected _maxSize: number;
  46142. protected _mainTextureDesiredSize: ISize;
  46143. protected _mainTexture: RenderTargetTexture;
  46144. protected _shouldRender: boolean;
  46145. protected _postProcesses: PostProcess[];
  46146. protected _textures: BaseTexture[];
  46147. protected _emissiveTextureAndColor: {
  46148. texture: Nullable<BaseTexture>;
  46149. color: Color4;
  46150. };
  46151. /**
  46152. * The name of the layer
  46153. */
  46154. name: string;
  46155. /**
  46156. * The clear color of the texture used to generate the glow map.
  46157. */
  46158. neutralColor: Color4;
  46159. /**
  46160. * Specifies wether the highlight layer is enabled or not.
  46161. */
  46162. isEnabled: boolean;
  46163. /**
  46164. * Gets the camera attached to the layer.
  46165. */
  46166. readonly camera: Nullable<Camera>;
  46167. /**
  46168. * Gets the rendering group id the layer should render in.
  46169. */
  46170. readonly renderingGroupId: number;
  46171. /**
  46172. * An event triggered when the effect layer has been disposed.
  46173. */
  46174. onDisposeObservable: Observable<EffectLayer>;
  46175. /**
  46176. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46177. */
  46178. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46179. /**
  46180. * An event triggered when the generated texture is being merged in the scene.
  46181. */
  46182. onBeforeComposeObservable: Observable<EffectLayer>;
  46183. /**
  46184. * An event triggered when the generated texture has been merged in the scene.
  46185. */
  46186. onAfterComposeObservable: Observable<EffectLayer>;
  46187. /**
  46188. * An event triggered when the efffect layer changes its size.
  46189. */
  46190. onSizeChangedObservable: Observable<EffectLayer>;
  46191. /** @hidden */
  46192. static _SceneComponentInitialization: (scene: Scene) => void;
  46193. /**
  46194. * Instantiates a new effect Layer and references it in the scene.
  46195. * @param name The name of the layer
  46196. * @param scene The scene to use the layer in
  46197. */
  46198. constructor(
  46199. /** The Friendly of the effect in the scene */
  46200. name: string, scene: Scene);
  46201. /**
  46202. * Get the effect name of the layer.
  46203. * @return The effect name
  46204. */
  46205. abstract getEffectName(): string;
  46206. /**
  46207. * Checks for the readiness of the element composing the layer.
  46208. * @param subMesh the mesh to check for
  46209. * @param useInstances specify wether or not to use instances to render the mesh
  46210. * @return true if ready otherwise, false
  46211. */
  46212. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46213. /**
  46214. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46215. * @returns true if the effect requires stencil during the main canvas render pass.
  46216. */
  46217. abstract needStencil(): boolean;
  46218. /**
  46219. * Create the merge effect. This is the shader use to blit the information back
  46220. * to the main canvas at the end of the scene rendering.
  46221. * @returns The effect containing the shader used to merge the effect on the main canvas
  46222. */
  46223. protected abstract _createMergeEffect(): Effect;
  46224. /**
  46225. * Creates the render target textures and post processes used in the effect layer.
  46226. */
  46227. protected abstract _createTextureAndPostProcesses(): void;
  46228. /**
  46229. * Implementation specific of rendering the generating effect on the main canvas.
  46230. * @param effect The effect used to render through
  46231. */
  46232. protected abstract _internalRender(effect: Effect): void;
  46233. /**
  46234. * Sets the required values for both the emissive texture and and the main color.
  46235. */
  46236. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46237. /**
  46238. * Free any resources and references associated to a mesh.
  46239. * Internal use
  46240. * @param mesh The mesh to free.
  46241. */
  46242. abstract _disposeMesh(mesh: Mesh): void;
  46243. /**
  46244. * Serializes this layer (Glow or Highlight for example)
  46245. * @returns a serialized layer object
  46246. */
  46247. abstract serialize?(): any;
  46248. /**
  46249. * Initializes the effect layer with the required options.
  46250. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46251. */
  46252. protected _init(options: Partial<IEffectLayerOptions>): void;
  46253. /**
  46254. * Generates the index buffer of the full screen quad blending to the main canvas.
  46255. */
  46256. private _generateIndexBuffer;
  46257. /**
  46258. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46259. */
  46260. private _genrateVertexBuffer;
  46261. /**
  46262. * Sets the main texture desired size which is the closest power of two
  46263. * of the engine canvas size.
  46264. */
  46265. private _setMainTextureSize;
  46266. /**
  46267. * Creates the main texture for the effect layer.
  46268. */
  46269. protected _createMainTexture(): void;
  46270. /**
  46271. * Adds specific effects defines.
  46272. * @param defines The defines to add specifics to.
  46273. */
  46274. protected _addCustomEffectDefines(defines: string[]): void;
  46275. /**
  46276. * Checks for the readiness of the element composing the layer.
  46277. * @param subMesh the mesh to check for
  46278. * @param useInstances specify wether or not to use instances to render the mesh
  46279. * @param emissiveTexture the associated emissive texture used to generate the glow
  46280. * @return true if ready otherwise, false
  46281. */
  46282. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46283. /**
  46284. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46285. */
  46286. render(): void;
  46287. /**
  46288. * Determine if a given mesh will be used in the current effect.
  46289. * @param mesh mesh to test
  46290. * @returns true if the mesh will be used
  46291. */
  46292. hasMesh(mesh: AbstractMesh): boolean;
  46293. /**
  46294. * Returns true if the layer contains information to display, otherwise false.
  46295. * @returns true if the glow layer should be rendered
  46296. */
  46297. shouldRender(): boolean;
  46298. /**
  46299. * Returns true if the mesh should render, otherwise false.
  46300. * @param mesh The mesh to render
  46301. * @returns true if it should render otherwise false
  46302. */
  46303. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46304. /**
  46305. * Returns true if the mesh can be rendered, otherwise false.
  46306. * @param mesh The mesh to render
  46307. * @param material The material used on the mesh
  46308. * @returns true if it can be rendered otherwise false
  46309. */
  46310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46311. /**
  46312. * Returns true if the mesh should render, otherwise false.
  46313. * @param mesh The mesh to render
  46314. * @returns true if it should render otherwise false
  46315. */
  46316. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46317. /**
  46318. * Renders the submesh passed in parameter to the generation map.
  46319. */
  46320. protected _renderSubMesh(subMesh: SubMesh): void;
  46321. /**
  46322. * Rebuild the required buffers.
  46323. * @hidden Internal use only.
  46324. */
  46325. _rebuild(): void;
  46326. /**
  46327. * Dispose only the render target textures and post process.
  46328. */
  46329. private _disposeTextureAndPostProcesses;
  46330. /**
  46331. * Dispose the highlight layer and free resources.
  46332. */
  46333. dispose(): void;
  46334. /**
  46335. * Gets the class name of the effect layer
  46336. * @returns the string with the class name of the effect layer
  46337. */
  46338. getClassName(): string;
  46339. /**
  46340. * Creates an effect layer from parsed effect layer data
  46341. * @param parsedEffectLayer defines effect layer data
  46342. * @param scene defines the current scene
  46343. * @param rootUrl defines the root URL containing the effect layer information
  46344. * @returns a parsed effect Layer
  46345. */
  46346. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. interface AbstractScene {
  46351. /**
  46352. * The list of effect layers (highlights/glow) added to the scene
  46353. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46354. * @see http://doc.babylonjs.com/how_to/glow_layer
  46355. */
  46356. effectLayers: Array<EffectLayer>;
  46357. /**
  46358. * Removes the given effect layer from this scene.
  46359. * @param toRemove defines the effect layer to remove
  46360. * @returns the index of the removed effect layer
  46361. */
  46362. removeEffectLayer(toRemove: EffectLayer): number;
  46363. /**
  46364. * Adds the given effect layer to this scene
  46365. * @param newEffectLayer defines the effect layer to add
  46366. */
  46367. addEffectLayer(newEffectLayer: EffectLayer): void;
  46368. }
  46369. /**
  46370. * Defines the layer scene component responsible to manage any effect layers
  46371. * in a given scene.
  46372. */
  46373. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46374. /**
  46375. * The component name helpfull to identify the component in the list of scene components.
  46376. */
  46377. readonly name: string;
  46378. /**
  46379. * The scene the component belongs to.
  46380. */
  46381. scene: Scene;
  46382. private _engine;
  46383. private _renderEffects;
  46384. private _needStencil;
  46385. private _previousStencilState;
  46386. /**
  46387. * Creates a new instance of the component for the given scene
  46388. * @param scene Defines the scene to register the component in
  46389. */
  46390. constructor(scene: Scene);
  46391. /**
  46392. * Registers the component in a given scene
  46393. */
  46394. register(): void;
  46395. /**
  46396. * Rebuilds the elements related to this component in case of
  46397. * context lost for instance.
  46398. */
  46399. rebuild(): void;
  46400. /**
  46401. * Serializes the component data to the specified json object
  46402. * @param serializationObject The object to serialize to
  46403. */
  46404. serialize(serializationObject: any): void;
  46405. /**
  46406. * Adds all the element from the container to the scene
  46407. * @param container the container holding the elements
  46408. */
  46409. addFromContainer(container: AbstractScene): void;
  46410. /**
  46411. * Removes all the elements in the container from the scene
  46412. * @param container contains the elements to remove
  46413. * @param dispose if the removed element should be disposed (default: false)
  46414. */
  46415. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46416. /**
  46417. * Disposes the component and the associated ressources.
  46418. */
  46419. dispose(): void;
  46420. private _isReadyForMesh;
  46421. private _renderMainTexture;
  46422. private _setStencil;
  46423. private _setStencilBack;
  46424. private _draw;
  46425. private _drawCamera;
  46426. private _drawRenderingGroup;
  46427. }
  46428. }
  46429. declare module BABYLON {
  46430. /** @hidden */
  46431. export var glowMapMergePixelShader: {
  46432. name: string;
  46433. shader: string;
  46434. };
  46435. }
  46436. declare module BABYLON {
  46437. /** @hidden */
  46438. export var glowMapMergeVertexShader: {
  46439. name: string;
  46440. shader: string;
  46441. };
  46442. }
  46443. declare module BABYLON {
  46444. interface AbstractScene {
  46445. /**
  46446. * Return a the first highlight layer of the scene with a given name.
  46447. * @param name The name of the highlight layer to look for.
  46448. * @return The highlight layer if found otherwise null.
  46449. */
  46450. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46451. }
  46452. /**
  46453. * Glow layer options. This helps customizing the behaviour
  46454. * of the glow layer.
  46455. */
  46456. export interface IGlowLayerOptions {
  46457. /**
  46458. * Multiplication factor apply to the canvas size to compute the render target size
  46459. * used to generated the glowing objects (the smaller the faster).
  46460. */
  46461. mainTextureRatio: number;
  46462. /**
  46463. * Enforces a fixed size texture to ensure resize independant blur.
  46464. */
  46465. mainTextureFixedSize?: number;
  46466. /**
  46467. * How big is the kernel of the blur texture.
  46468. */
  46469. blurKernelSize: number;
  46470. /**
  46471. * The camera attached to the layer.
  46472. */
  46473. camera: Nullable<Camera>;
  46474. /**
  46475. * Enable MSAA by chosing the number of samples.
  46476. */
  46477. mainTextureSamples?: number;
  46478. /**
  46479. * The rendering group to draw the layer in.
  46480. */
  46481. renderingGroupId: number;
  46482. }
  46483. /**
  46484. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46485. *
  46486. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46487. * glowy meshes to your scene.
  46488. *
  46489. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46490. */
  46491. export class GlowLayer extends EffectLayer {
  46492. /**
  46493. * Effect Name of the layer.
  46494. */
  46495. static readonly EffectName: string;
  46496. /**
  46497. * The default blur kernel size used for the glow.
  46498. */
  46499. static DefaultBlurKernelSize: number;
  46500. /**
  46501. * The default texture size ratio used for the glow.
  46502. */
  46503. static DefaultTextureRatio: number;
  46504. /**
  46505. * Sets the kernel size of the blur.
  46506. */
  46507. /**
  46508. * Gets the kernel size of the blur.
  46509. */
  46510. blurKernelSize: number;
  46511. /**
  46512. * Sets the glow intensity.
  46513. */
  46514. /**
  46515. * Gets the glow intensity.
  46516. */
  46517. intensity: number;
  46518. private _options;
  46519. private _intensity;
  46520. private _horizontalBlurPostprocess1;
  46521. private _verticalBlurPostprocess1;
  46522. private _horizontalBlurPostprocess2;
  46523. private _verticalBlurPostprocess2;
  46524. private _blurTexture1;
  46525. private _blurTexture2;
  46526. private _postProcesses1;
  46527. private _postProcesses2;
  46528. private _includedOnlyMeshes;
  46529. private _excludedMeshes;
  46530. /**
  46531. * Callback used to let the user override the color selection on a per mesh basis
  46532. */
  46533. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46534. /**
  46535. * Callback used to let the user override the texture selection on a per mesh basis
  46536. */
  46537. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46538. /**
  46539. * Instantiates a new glow Layer and references it to the scene.
  46540. * @param name The name of the layer
  46541. * @param scene The scene to use the layer in
  46542. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46543. */
  46544. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46545. /**
  46546. * Get the effect name of the layer.
  46547. * @return The effect name
  46548. */
  46549. getEffectName(): string;
  46550. /**
  46551. * Create the merge effect. This is the shader use to blit the information back
  46552. * to the main canvas at the end of the scene rendering.
  46553. */
  46554. protected _createMergeEffect(): Effect;
  46555. /**
  46556. * Creates the render target textures and post processes used in the glow layer.
  46557. */
  46558. protected _createTextureAndPostProcesses(): void;
  46559. /**
  46560. * Checks for the readiness of the element composing the layer.
  46561. * @param subMesh the mesh to check for
  46562. * @param useInstances specify wether or not to use instances to render the mesh
  46563. * @param emissiveTexture the associated emissive texture used to generate the glow
  46564. * @return true if ready otherwise, false
  46565. */
  46566. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46567. /**
  46568. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46569. */
  46570. needStencil(): boolean;
  46571. /**
  46572. * Returns true if the mesh can be rendered, otherwise false.
  46573. * @param mesh The mesh to render
  46574. * @param material The material used on the mesh
  46575. * @returns true if it can be rendered otherwise false
  46576. */
  46577. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46578. /**
  46579. * Implementation specific of rendering the generating effect on the main canvas.
  46580. * @param effect The effect used to render through
  46581. */
  46582. protected _internalRender(effect: Effect): void;
  46583. /**
  46584. * Sets the required values for both the emissive texture and and the main color.
  46585. */
  46586. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46587. /**
  46588. * Returns true if the mesh should render, otherwise false.
  46589. * @param mesh The mesh to render
  46590. * @returns true if it should render otherwise false
  46591. */
  46592. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46593. /**
  46594. * Adds specific effects defines.
  46595. * @param defines The defines to add specifics to.
  46596. */
  46597. protected _addCustomEffectDefines(defines: string[]): void;
  46598. /**
  46599. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46600. * @param mesh The mesh to exclude from the glow layer
  46601. */
  46602. addExcludedMesh(mesh: Mesh): void;
  46603. /**
  46604. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46605. * @param mesh The mesh to remove
  46606. */
  46607. removeExcludedMesh(mesh: Mesh): void;
  46608. /**
  46609. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46610. * @param mesh The mesh to include in the glow layer
  46611. */
  46612. addIncludedOnlyMesh(mesh: Mesh): void;
  46613. /**
  46614. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46615. * @param mesh The mesh to remove
  46616. */
  46617. removeIncludedOnlyMesh(mesh: Mesh): void;
  46618. /**
  46619. * Determine if a given mesh will be used in the glow layer
  46620. * @param mesh The mesh to test
  46621. * @returns true if the mesh will be highlighted by the current glow layer
  46622. */
  46623. hasMesh(mesh: AbstractMesh): boolean;
  46624. /**
  46625. * Free any resources and references associated to a mesh.
  46626. * Internal use
  46627. * @param mesh The mesh to free.
  46628. * @hidden
  46629. */
  46630. _disposeMesh(mesh: Mesh): void;
  46631. /**
  46632. * Gets the class name of the effect layer
  46633. * @returns the string with the class name of the effect layer
  46634. */
  46635. getClassName(): string;
  46636. /**
  46637. * Serializes this glow layer
  46638. * @returns a serialized glow layer object
  46639. */
  46640. serialize(): any;
  46641. /**
  46642. * Creates a Glow Layer from parsed glow layer data
  46643. * @param parsedGlowLayer defines glow layer data
  46644. * @param scene defines the current scene
  46645. * @param rootUrl defines the root URL containing the glow layer information
  46646. * @returns a parsed Glow Layer
  46647. */
  46648. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46649. }
  46650. }
  46651. declare module BABYLON {
  46652. /** @hidden */
  46653. export var glowBlurPostProcessPixelShader: {
  46654. name: string;
  46655. shader: string;
  46656. };
  46657. }
  46658. declare module BABYLON {
  46659. interface AbstractScene {
  46660. /**
  46661. * Return a the first highlight layer of the scene with a given name.
  46662. * @param name The name of the highlight layer to look for.
  46663. * @return The highlight layer if found otherwise null.
  46664. */
  46665. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46666. }
  46667. /**
  46668. * Highlight layer options. This helps customizing the behaviour
  46669. * of the highlight layer.
  46670. */
  46671. export interface IHighlightLayerOptions {
  46672. /**
  46673. * Multiplication factor apply to the canvas size to compute the render target size
  46674. * used to generated the glowing objects (the smaller the faster).
  46675. */
  46676. mainTextureRatio: number;
  46677. /**
  46678. * Enforces a fixed size texture to ensure resize independant blur.
  46679. */
  46680. mainTextureFixedSize?: number;
  46681. /**
  46682. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46683. * of the picture to blur (the smaller the faster).
  46684. */
  46685. blurTextureSizeRatio: number;
  46686. /**
  46687. * How big in texel of the blur texture is the vertical blur.
  46688. */
  46689. blurVerticalSize: number;
  46690. /**
  46691. * How big in texel of the blur texture is the horizontal blur.
  46692. */
  46693. blurHorizontalSize: number;
  46694. /**
  46695. * Alpha blending mode used to apply the blur. Default is combine.
  46696. */
  46697. alphaBlendingMode: number;
  46698. /**
  46699. * The camera attached to the layer.
  46700. */
  46701. camera: Nullable<Camera>;
  46702. /**
  46703. * Should we display highlight as a solid stroke?
  46704. */
  46705. isStroke?: boolean;
  46706. /**
  46707. * The rendering group to draw the layer in.
  46708. */
  46709. renderingGroupId: number;
  46710. }
  46711. /**
  46712. * The highlight layer Helps adding a glow effect around a mesh.
  46713. *
  46714. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46715. * glowy meshes to your scene.
  46716. *
  46717. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46718. */
  46719. export class HighlightLayer extends EffectLayer {
  46720. name: string;
  46721. /**
  46722. * Effect Name of the highlight layer.
  46723. */
  46724. static readonly EffectName: string;
  46725. /**
  46726. * The neutral color used during the preparation of the glow effect.
  46727. * This is black by default as the blend operation is a blend operation.
  46728. */
  46729. static NeutralColor: Color4;
  46730. /**
  46731. * Stencil value used for glowing meshes.
  46732. */
  46733. static GlowingMeshStencilReference: number;
  46734. /**
  46735. * Stencil value used for the other meshes in the scene.
  46736. */
  46737. static NormalMeshStencilReference: number;
  46738. /**
  46739. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46740. */
  46741. innerGlow: boolean;
  46742. /**
  46743. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46744. */
  46745. outerGlow: boolean;
  46746. /**
  46747. * Specifies the horizontal size of the blur.
  46748. */
  46749. /**
  46750. * Gets the horizontal size of the blur.
  46751. */
  46752. blurHorizontalSize: number;
  46753. /**
  46754. * Specifies the vertical size of the blur.
  46755. */
  46756. /**
  46757. * Gets the vertical size of the blur.
  46758. */
  46759. blurVerticalSize: number;
  46760. /**
  46761. * An event triggered when the highlight layer is being blurred.
  46762. */
  46763. onBeforeBlurObservable: Observable<HighlightLayer>;
  46764. /**
  46765. * An event triggered when the highlight layer has been blurred.
  46766. */
  46767. onAfterBlurObservable: Observable<HighlightLayer>;
  46768. private _instanceGlowingMeshStencilReference;
  46769. private _options;
  46770. private _downSamplePostprocess;
  46771. private _horizontalBlurPostprocess;
  46772. private _verticalBlurPostprocess;
  46773. private _blurTexture;
  46774. private _meshes;
  46775. private _excludedMeshes;
  46776. /**
  46777. * Instantiates a new highlight Layer and references it to the scene..
  46778. * @param name The name of the layer
  46779. * @param scene The scene to use the layer in
  46780. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46781. */
  46782. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46783. /**
  46784. * Get the effect name of the layer.
  46785. * @return The effect name
  46786. */
  46787. getEffectName(): string;
  46788. /**
  46789. * Create the merge effect. This is the shader use to blit the information back
  46790. * to the main canvas at the end of the scene rendering.
  46791. */
  46792. protected _createMergeEffect(): Effect;
  46793. /**
  46794. * Creates the render target textures and post processes used in the highlight layer.
  46795. */
  46796. protected _createTextureAndPostProcesses(): void;
  46797. /**
  46798. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46799. */
  46800. needStencil(): boolean;
  46801. /**
  46802. * Checks for the readiness of the element composing the layer.
  46803. * @param subMesh the mesh to check for
  46804. * @param useInstances specify wether or not to use instances to render the mesh
  46805. * @param emissiveTexture the associated emissive texture used to generate the glow
  46806. * @return true if ready otherwise, false
  46807. */
  46808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46809. /**
  46810. * Implementation specific of rendering the generating effect on the main canvas.
  46811. * @param effect The effect used to render through
  46812. */
  46813. protected _internalRender(effect: Effect): void;
  46814. /**
  46815. * Returns true if the layer contains information to display, otherwise false.
  46816. */
  46817. shouldRender(): boolean;
  46818. /**
  46819. * Returns true if the mesh should render, otherwise false.
  46820. * @param mesh The mesh to render
  46821. * @returns true if it should render otherwise false
  46822. */
  46823. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46824. /**
  46825. * Sets the required values for both the emissive texture and and the main color.
  46826. */
  46827. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46828. /**
  46829. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46830. * @param mesh The mesh to exclude from the highlight layer
  46831. */
  46832. addExcludedMesh(mesh: Mesh): void;
  46833. /**
  46834. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46835. * @param mesh The mesh to highlight
  46836. */
  46837. removeExcludedMesh(mesh: Mesh): void;
  46838. /**
  46839. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46840. * @param mesh mesh to test
  46841. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46842. */
  46843. hasMesh(mesh: AbstractMesh): boolean;
  46844. /**
  46845. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46846. * @param mesh The mesh to highlight
  46847. * @param color The color of the highlight
  46848. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46849. */
  46850. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46851. /**
  46852. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46853. * @param mesh The mesh to highlight
  46854. */
  46855. removeMesh(mesh: Mesh): void;
  46856. /**
  46857. * Force the stencil to the normal expected value for none glowing parts
  46858. */
  46859. private _defaultStencilReference;
  46860. /**
  46861. * Free any resources and references associated to a mesh.
  46862. * Internal use
  46863. * @param mesh The mesh to free.
  46864. * @hidden
  46865. */
  46866. _disposeMesh(mesh: Mesh): void;
  46867. /**
  46868. * Dispose the highlight layer and free resources.
  46869. */
  46870. dispose(): void;
  46871. /**
  46872. * Gets the class name of the effect layer
  46873. * @returns the string with the class name of the effect layer
  46874. */
  46875. getClassName(): string;
  46876. /**
  46877. * Serializes this Highlight layer
  46878. * @returns a serialized Highlight layer object
  46879. */
  46880. serialize(): any;
  46881. /**
  46882. * Creates a Highlight layer from parsed Highlight layer data
  46883. * @param parsedHightlightLayer defines the Highlight layer data
  46884. * @param scene defines the current scene
  46885. * @param rootUrl defines the root URL containing the Highlight layer information
  46886. * @returns a parsed Highlight layer
  46887. */
  46888. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46889. }
  46890. }
  46891. declare module BABYLON {
  46892. /** @hidden */
  46893. export var lensFlarePixelShader: {
  46894. name: string;
  46895. shader: string;
  46896. };
  46897. }
  46898. declare module BABYLON {
  46899. /** @hidden */
  46900. export var lensFlareVertexShader: {
  46901. name: string;
  46902. shader: string;
  46903. };
  46904. }
  46905. declare module BABYLON {
  46906. /**
  46907. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46908. * It is usually composed of several `lensFlare`.
  46909. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46910. */
  46911. export class LensFlareSystem {
  46912. /**
  46913. * Define the name of the lens flare system
  46914. */
  46915. name: string;
  46916. /**
  46917. * List of lens flares used in this system.
  46918. */
  46919. lensFlares: LensFlare[];
  46920. /**
  46921. * Define a limit from the border the lens flare can be visible.
  46922. */
  46923. borderLimit: number;
  46924. /**
  46925. * Define a viewport border we do not want to see the lens flare in.
  46926. */
  46927. viewportBorder: number;
  46928. /**
  46929. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46930. */
  46931. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46932. /**
  46933. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46934. */
  46935. layerMask: number;
  46936. /**
  46937. * Define the id of the lens flare system in the scene.
  46938. * (equal to name by default)
  46939. */
  46940. id: string;
  46941. private _scene;
  46942. private _emitter;
  46943. private _vertexBuffers;
  46944. private _indexBuffer;
  46945. private _effect;
  46946. private _positionX;
  46947. private _positionY;
  46948. private _isEnabled;
  46949. /** @hidden */
  46950. static _SceneComponentInitialization: (scene: Scene) => void;
  46951. /**
  46952. * Instantiates a lens flare system.
  46953. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46954. * It is usually composed of several `lensFlare`.
  46955. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46956. * @param name Define the name of the lens flare system in the scene
  46957. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46958. * @param scene Define the scene the lens flare system belongs to
  46959. */
  46960. constructor(
  46961. /**
  46962. * Define the name of the lens flare system
  46963. */
  46964. name: string, emitter: any, scene: Scene);
  46965. /**
  46966. * Define if the lens flare system is enabled.
  46967. */
  46968. isEnabled: boolean;
  46969. /**
  46970. * Get the scene the effects belongs to.
  46971. * @returns the scene holding the lens flare system
  46972. */
  46973. getScene(): Scene;
  46974. /**
  46975. * Get the emitter of the lens flare system.
  46976. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46977. * @returns the emitter of the lens flare system
  46978. */
  46979. getEmitter(): any;
  46980. /**
  46981. * Set the emitter of the lens flare system.
  46982. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46983. * @param newEmitter Define the new emitter of the system
  46984. */
  46985. setEmitter(newEmitter: any): void;
  46986. /**
  46987. * Get the lens flare system emitter position.
  46988. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46989. * @returns the position
  46990. */
  46991. getEmitterPosition(): Vector3;
  46992. /**
  46993. * @hidden
  46994. */
  46995. computeEffectivePosition(globalViewport: Viewport): boolean;
  46996. /** @hidden */
  46997. _isVisible(): boolean;
  46998. /**
  46999. * @hidden
  47000. */
  47001. render(): boolean;
  47002. /**
  47003. * Dispose and release the lens flare with its associated resources.
  47004. */
  47005. dispose(): void;
  47006. /**
  47007. * Parse a lens flare system from a JSON repressentation
  47008. * @param parsedLensFlareSystem Define the JSON to parse
  47009. * @param scene Define the scene the parsed system should be instantiated in
  47010. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47011. * @returns the parsed system
  47012. */
  47013. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47014. /**
  47015. * Serialize the current Lens Flare System into a JSON representation.
  47016. * @returns the serialized JSON
  47017. */
  47018. serialize(): any;
  47019. }
  47020. }
  47021. declare module BABYLON {
  47022. /**
  47023. * This represents one of the lens effect in a `lensFlareSystem`.
  47024. * It controls one of the indiviual texture used in the effect.
  47025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47026. */
  47027. export class LensFlare {
  47028. /**
  47029. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47030. */
  47031. size: number;
  47032. /**
  47033. * 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.
  47034. */
  47035. position: number;
  47036. /**
  47037. * Define the lens color.
  47038. */
  47039. color: Color3;
  47040. /**
  47041. * Define the lens texture.
  47042. */
  47043. texture: Nullable<Texture>;
  47044. /**
  47045. * Define the alpha mode to render this particular lens.
  47046. */
  47047. alphaMode: number;
  47048. private _system;
  47049. /**
  47050. * Creates a new Lens Flare.
  47051. * This represents one of the lens effect in a `lensFlareSystem`.
  47052. * It controls one of the indiviual texture used in the effect.
  47053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47054. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47055. * @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.
  47056. * @param color Define the lens color
  47057. * @param imgUrl Define the lens texture url
  47058. * @param system Define the `lensFlareSystem` this flare is part of
  47059. * @returns The newly created Lens Flare
  47060. */
  47061. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47062. /**
  47063. * Instantiates a new Lens Flare.
  47064. * This represents one of the lens effect in a `lensFlareSystem`.
  47065. * It controls one of the indiviual texture used in the effect.
  47066. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47067. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47068. * @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.
  47069. * @param color Define the lens color
  47070. * @param imgUrl Define the lens texture url
  47071. * @param system Define the `lensFlareSystem` this flare is part of
  47072. */
  47073. constructor(
  47074. /**
  47075. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47076. */
  47077. size: number,
  47078. /**
  47079. * 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.
  47080. */
  47081. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47082. /**
  47083. * Dispose and release the lens flare with its associated resources.
  47084. */
  47085. dispose(): void;
  47086. }
  47087. }
  47088. declare module BABYLON {
  47089. interface AbstractScene {
  47090. /**
  47091. * The list of lens flare system added to the scene
  47092. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47093. */
  47094. lensFlareSystems: Array<LensFlareSystem>;
  47095. /**
  47096. * Removes the given lens flare system from this scene.
  47097. * @param toRemove The lens flare system to remove
  47098. * @returns The index of the removed lens flare system
  47099. */
  47100. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47101. /**
  47102. * Adds the given lens flare system to this scene
  47103. * @param newLensFlareSystem The lens flare system to add
  47104. */
  47105. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47106. /**
  47107. * Gets a lens flare system using its name
  47108. * @param name defines the name to look for
  47109. * @returns the lens flare system or null if not found
  47110. */
  47111. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47112. /**
  47113. * Gets a lens flare system using its id
  47114. * @param id defines the id to look for
  47115. * @returns the lens flare system or null if not found
  47116. */
  47117. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47118. }
  47119. /**
  47120. * Defines the lens flare scene component responsible to manage any lens flares
  47121. * in a given scene.
  47122. */
  47123. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47124. /**
  47125. * The component name helpfull to identify the component in the list of scene components.
  47126. */
  47127. readonly name: string;
  47128. /**
  47129. * The scene the component belongs to.
  47130. */
  47131. scene: Scene;
  47132. /**
  47133. * Creates a new instance of the component for the given scene
  47134. * @param scene Defines the scene to register the component in
  47135. */
  47136. constructor(scene: Scene);
  47137. /**
  47138. * Registers the component in a given scene
  47139. */
  47140. register(): void;
  47141. /**
  47142. * Rebuilds the elements related to this component in case of
  47143. * context lost for instance.
  47144. */
  47145. rebuild(): void;
  47146. /**
  47147. * Adds all the element from the container to the scene
  47148. * @param container the container holding the elements
  47149. */
  47150. addFromContainer(container: AbstractScene): void;
  47151. /**
  47152. * Removes all the elements in the container from the scene
  47153. * @param container contains the elements to remove
  47154. * @param dispose if the removed element should be disposed (default: false)
  47155. */
  47156. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47157. /**
  47158. * Serializes the component data to the specified json object
  47159. * @param serializationObject The object to serialize to
  47160. */
  47161. serialize(serializationObject: any): void;
  47162. /**
  47163. * Disposes the component and the associated ressources.
  47164. */
  47165. dispose(): void;
  47166. private _draw;
  47167. }
  47168. }
  47169. declare module BABYLON {
  47170. /**
  47171. * Defines the shadow generator component responsible to manage any shadow generators
  47172. * in a given scene.
  47173. */
  47174. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47175. /**
  47176. * The component name helpfull to identify the component in the list of scene components.
  47177. */
  47178. readonly name: string;
  47179. /**
  47180. * The scene the component belongs to.
  47181. */
  47182. scene: Scene;
  47183. /**
  47184. * Creates a new instance of the component for the given scene
  47185. * @param scene Defines the scene to register the component in
  47186. */
  47187. constructor(scene: Scene);
  47188. /**
  47189. * Registers the component in a given scene
  47190. */
  47191. register(): void;
  47192. /**
  47193. * Rebuilds the elements related to this component in case of
  47194. * context lost for instance.
  47195. */
  47196. rebuild(): void;
  47197. /**
  47198. * Serializes the component data to the specified json object
  47199. * @param serializationObject The object to serialize to
  47200. */
  47201. serialize(serializationObject: any): void;
  47202. /**
  47203. * Adds all the element from the container to the scene
  47204. * @param container the container holding the elements
  47205. */
  47206. addFromContainer(container: AbstractScene): void;
  47207. /**
  47208. * Removes all the elements in the container from the scene
  47209. * @param container contains the elements to remove
  47210. * @param dispose if the removed element should be disposed (default: false)
  47211. */
  47212. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47213. /**
  47214. * Rebuilds the elements related to this component in case of
  47215. * context lost for instance.
  47216. */
  47217. dispose(): void;
  47218. private _gatherRenderTargets;
  47219. }
  47220. }
  47221. declare module BABYLON {
  47222. /**
  47223. * A point light is a light defined by an unique point in world space.
  47224. * The light is emitted in every direction from this point.
  47225. * A good example of a point light is a standard light bulb.
  47226. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47227. */
  47228. export class PointLight extends ShadowLight {
  47229. private _shadowAngle;
  47230. /**
  47231. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47232. * This specifies what angle the shadow will use to be created.
  47233. *
  47234. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47235. */
  47236. /**
  47237. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47238. * This specifies what angle the shadow will use to be created.
  47239. *
  47240. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47241. */
  47242. shadowAngle: number;
  47243. /**
  47244. * Gets the direction if it has been set.
  47245. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47246. */
  47247. /**
  47248. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47249. */
  47250. direction: Vector3;
  47251. /**
  47252. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47253. * A PointLight emits the light in every direction.
  47254. * It can cast shadows.
  47255. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47256. * ```javascript
  47257. * var pointLight = new PointLight("pl", camera.position, scene);
  47258. * ```
  47259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47260. * @param name The light friendly name
  47261. * @param position The position of the point light in the scene
  47262. * @param scene The scene the lights belongs to
  47263. */
  47264. constructor(name: string, position: Vector3, scene: Scene);
  47265. /**
  47266. * Returns the string "PointLight"
  47267. * @returns the class name
  47268. */
  47269. getClassName(): string;
  47270. /**
  47271. * Returns the integer 0.
  47272. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47273. */
  47274. getTypeID(): number;
  47275. /**
  47276. * Specifies wether or not the shadowmap should be a cube texture.
  47277. * @returns true if the shadowmap needs to be a cube texture.
  47278. */
  47279. needCube(): boolean;
  47280. /**
  47281. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47282. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47283. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47284. */
  47285. getShadowDirection(faceIndex?: number): Vector3;
  47286. /**
  47287. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47288. * - fov = PI / 2
  47289. * - aspect ratio : 1.0
  47290. * - z-near and far equal to the active camera minZ and maxZ.
  47291. * Returns the PointLight.
  47292. */
  47293. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47294. protected _buildUniformLayout(): void;
  47295. /**
  47296. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47297. * @param effect The effect to update
  47298. * @param lightIndex The index of the light in the effect to update
  47299. * @returns The point light
  47300. */
  47301. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47302. /**
  47303. * Prepares the list of defines specific to the light type.
  47304. * @param defines the list of defines
  47305. * @param lightIndex defines the index of the light for the effect
  47306. */
  47307. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47308. }
  47309. }
  47310. declare module BABYLON {
  47311. /**
  47312. * Header information of HDR texture files.
  47313. */
  47314. export interface HDRInfo {
  47315. /**
  47316. * The height of the texture in pixels.
  47317. */
  47318. height: number;
  47319. /**
  47320. * The width of the texture in pixels.
  47321. */
  47322. width: number;
  47323. /**
  47324. * The index of the beginning of the data in the binary file.
  47325. */
  47326. dataPosition: number;
  47327. }
  47328. /**
  47329. * This groups tools to convert HDR texture to native colors array.
  47330. */
  47331. export class HDRTools {
  47332. private static Ldexp;
  47333. private static Rgbe2float;
  47334. private static readStringLine;
  47335. /**
  47336. * Reads header information from an RGBE texture stored in a native array.
  47337. * More information on this format are available here:
  47338. * https://en.wikipedia.org/wiki/RGBE_image_format
  47339. *
  47340. * @param uint8array The binary file stored in native array.
  47341. * @return The header information.
  47342. */
  47343. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47344. /**
  47345. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47346. * This RGBE texture needs to store the information as a panorama.
  47347. *
  47348. * More information on this format are available here:
  47349. * https://en.wikipedia.org/wiki/RGBE_image_format
  47350. *
  47351. * @param buffer The binary file stored in an array buffer.
  47352. * @param size The expected size of the extracted cubemap.
  47353. * @return The Cube Map information.
  47354. */
  47355. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47356. /**
  47357. * Returns the pixels data extracted from an RGBE texture.
  47358. * This pixels will be stored left to right up to down in the R G B order in one array.
  47359. *
  47360. * More information on this format are available here:
  47361. * https://en.wikipedia.org/wiki/RGBE_image_format
  47362. *
  47363. * @param uint8array The binary file stored in an array buffer.
  47364. * @param hdrInfo The header information of the file.
  47365. * @return The pixels data in RGB right to left up to down order.
  47366. */
  47367. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47368. private static RGBE_ReadPixels_RLE;
  47369. }
  47370. }
  47371. declare module BABYLON {
  47372. /**
  47373. * This represents a texture coming from an HDR input.
  47374. *
  47375. * The only supported format is currently panorama picture stored in RGBE format.
  47376. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47377. */
  47378. export class HDRCubeTexture extends BaseTexture {
  47379. private static _facesMapping;
  47380. private _generateHarmonics;
  47381. private _noMipmap;
  47382. private _textureMatrix;
  47383. private _size;
  47384. private _onLoad;
  47385. private _onError;
  47386. /**
  47387. * The texture URL.
  47388. */
  47389. url: string;
  47390. /**
  47391. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47392. */
  47393. coordinatesMode: number;
  47394. protected _isBlocking: boolean;
  47395. /**
  47396. * Sets wether or not the texture is blocking during loading.
  47397. */
  47398. /**
  47399. * Gets wether or not the texture is blocking during loading.
  47400. */
  47401. isBlocking: boolean;
  47402. protected _rotationY: number;
  47403. /**
  47404. * Sets texture matrix rotation angle around Y axis in radians.
  47405. */
  47406. /**
  47407. * Gets texture matrix rotation angle around Y axis radians.
  47408. */
  47409. rotationY: number;
  47410. /**
  47411. * Gets or sets the center of the bounding box associated with the cube texture
  47412. * It must define where the camera used to render the texture was set
  47413. */
  47414. boundingBoxPosition: Vector3;
  47415. private _boundingBoxSize;
  47416. /**
  47417. * Gets or sets the size of the bounding box associated with the cube texture
  47418. * When defined, the cubemap will switch to local mode
  47419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47420. * @example https://www.babylonjs-playground.com/#RNASML
  47421. */
  47422. boundingBoxSize: Vector3;
  47423. /**
  47424. * Instantiates an HDRTexture from the following parameters.
  47425. *
  47426. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47427. * @param scene The scene the texture will be used in
  47428. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47429. * @param noMipmap Forces to not generate the mipmap if true
  47430. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47431. * @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)
  47432. * @param reserved Reserved flag for internal use.
  47433. */
  47434. 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>);
  47435. /**
  47436. * Get the current class name of the texture useful for serialization or dynamic coding.
  47437. * @returns "HDRCubeTexture"
  47438. */
  47439. getClassName(): string;
  47440. /**
  47441. * Occurs when the file is raw .hdr file.
  47442. */
  47443. private loadTexture;
  47444. clone(): HDRCubeTexture;
  47445. delayLoad(): void;
  47446. /**
  47447. * Get the texture reflection matrix used to rotate/transform the reflection.
  47448. * @returns the reflection matrix
  47449. */
  47450. getReflectionTextureMatrix(): Matrix;
  47451. /**
  47452. * Set the texture reflection matrix used to rotate/transform the reflection.
  47453. * @param value Define the reflection matrix to set
  47454. */
  47455. setReflectionTextureMatrix(value: Matrix): void;
  47456. /**
  47457. * Parses a JSON representation of an HDR Texture in order to create the texture
  47458. * @param parsedTexture Define the JSON representation
  47459. * @param scene Define the scene the texture should be created in
  47460. * @param rootUrl Define the root url in case we need to load relative dependencies
  47461. * @returns the newly created texture after parsing
  47462. */
  47463. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47464. serialize(): any;
  47465. }
  47466. }
  47467. declare module BABYLON {
  47468. /**
  47469. * Class used to control physics engine
  47470. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47471. */
  47472. export class PhysicsEngine implements IPhysicsEngine {
  47473. private _physicsPlugin;
  47474. /**
  47475. * Global value used to control the smallest number supported by the simulation
  47476. */
  47477. static Epsilon: number;
  47478. private _impostors;
  47479. private _joints;
  47480. /**
  47481. * Gets the gravity vector used by the simulation
  47482. */
  47483. gravity: Vector3;
  47484. /**
  47485. * Factory used to create the default physics plugin.
  47486. * @returns The default physics plugin
  47487. */
  47488. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47489. /**
  47490. * Creates a new Physics Engine
  47491. * @param gravity defines the gravity vector used by the simulation
  47492. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47493. */
  47494. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47495. /**
  47496. * Sets the gravity vector used by the simulation
  47497. * @param gravity defines the gravity vector to use
  47498. */
  47499. setGravity(gravity: Vector3): void;
  47500. /**
  47501. * Set the time step of the physics engine.
  47502. * Default is 1/60.
  47503. * To slow it down, enter 1/600 for example.
  47504. * To speed it up, 1/30
  47505. * @param newTimeStep defines the new timestep to apply to this world.
  47506. */
  47507. setTimeStep(newTimeStep?: number): void;
  47508. /**
  47509. * Get the time step of the physics engine.
  47510. * @returns the current time step
  47511. */
  47512. getTimeStep(): number;
  47513. /**
  47514. * Release all resources
  47515. */
  47516. dispose(): void;
  47517. /**
  47518. * Gets the name of the current physics plugin
  47519. * @returns the name of the plugin
  47520. */
  47521. getPhysicsPluginName(): string;
  47522. /**
  47523. * Adding a new impostor for the impostor tracking.
  47524. * This will be done by the impostor itself.
  47525. * @param impostor the impostor to add
  47526. */
  47527. addImpostor(impostor: PhysicsImpostor): void;
  47528. /**
  47529. * Remove an impostor from the engine.
  47530. * This impostor and its mesh will not longer be updated by the physics engine.
  47531. * @param impostor the impostor to remove
  47532. */
  47533. removeImpostor(impostor: PhysicsImpostor): void;
  47534. /**
  47535. * Add a joint to the physics engine
  47536. * @param mainImpostor defines the main impostor to which the joint is added.
  47537. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47538. * @param joint defines the joint that will connect both impostors.
  47539. */
  47540. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47541. /**
  47542. * Removes a joint from the simulation
  47543. * @param mainImpostor defines the impostor used with the joint
  47544. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47545. * @param joint defines the joint to remove
  47546. */
  47547. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47548. /**
  47549. * Called by the scene. No need to call it.
  47550. * @param delta defines the timespam between frames
  47551. */
  47552. _step(delta: number): void;
  47553. /**
  47554. * Gets the current plugin used to run the simulation
  47555. * @returns current plugin
  47556. */
  47557. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47558. /**
  47559. * Gets the list of physic impostors
  47560. * @returns an array of PhysicsImpostor
  47561. */
  47562. getImpostors(): Array<PhysicsImpostor>;
  47563. /**
  47564. * Gets the impostor for a physics enabled object
  47565. * @param object defines the object impersonated by the impostor
  47566. * @returns the PhysicsImpostor or null if not found
  47567. */
  47568. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47569. /**
  47570. * Gets the impostor for a physics body object
  47571. * @param body defines physics body used by the impostor
  47572. * @returns the PhysicsImpostor or null if not found
  47573. */
  47574. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47575. /**
  47576. * Does a raycast in the physics world
  47577. * @param from when should the ray start?
  47578. * @param to when should the ray end?
  47579. * @returns PhysicsRaycastResult
  47580. */
  47581. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47582. }
  47583. }
  47584. declare module BABYLON {
  47585. /** @hidden */
  47586. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47587. private _useDeltaForWorldStep;
  47588. world: any;
  47589. name: string;
  47590. private _physicsMaterials;
  47591. private _fixedTimeStep;
  47592. private _cannonRaycastResult;
  47593. private _raycastResult;
  47594. BJSCANNON: any;
  47595. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47596. setGravity(gravity: Vector3): void;
  47597. setTimeStep(timeStep: number): void;
  47598. getTimeStep(): number;
  47599. executeStep(delta: number): void;
  47600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47602. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47603. private _processChildMeshes;
  47604. removePhysicsBody(impostor: PhysicsImpostor): void;
  47605. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47606. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47607. private _addMaterial;
  47608. private _checkWithEpsilon;
  47609. private _createShape;
  47610. private _createHeightmap;
  47611. private _minus90X;
  47612. private _plus90X;
  47613. private _tmpPosition;
  47614. private _tmpDeltaPosition;
  47615. private _tmpUnityRotation;
  47616. private _updatePhysicsBodyTransformation;
  47617. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47618. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47619. isSupported(): boolean;
  47620. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47621. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47622. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47623. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47624. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47625. getBodyMass(impostor: PhysicsImpostor): number;
  47626. getBodyFriction(impostor: PhysicsImpostor): number;
  47627. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47628. getBodyRestitution(impostor: PhysicsImpostor): number;
  47629. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47630. sleepBody(impostor: PhysicsImpostor): void;
  47631. wakeUpBody(impostor: PhysicsImpostor): void;
  47632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47633. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47634. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47635. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47636. getRadius(impostor: PhysicsImpostor): number;
  47637. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47638. dispose(): void;
  47639. private _extendNamespace;
  47640. /**
  47641. * Does a raycast in the physics world
  47642. * @param from when should the ray start?
  47643. * @param to when should the ray end?
  47644. * @returns PhysicsRaycastResult
  47645. */
  47646. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47647. }
  47648. }
  47649. declare module BABYLON {
  47650. /** @hidden */
  47651. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47652. world: any;
  47653. name: string;
  47654. BJSOIMO: any;
  47655. private _raycastResult;
  47656. constructor(iterations?: number, oimoInjection?: any);
  47657. setGravity(gravity: Vector3): void;
  47658. setTimeStep(timeStep: number): void;
  47659. getTimeStep(): number;
  47660. private _tmpImpostorsArray;
  47661. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47662. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47663. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47664. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47665. private _tmpPositionVector;
  47666. removePhysicsBody(impostor: PhysicsImpostor): void;
  47667. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47668. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47669. isSupported(): boolean;
  47670. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47671. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47672. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47673. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47674. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47675. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47676. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47677. getBodyMass(impostor: PhysicsImpostor): number;
  47678. getBodyFriction(impostor: PhysicsImpostor): number;
  47679. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47680. getBodyRestitution(impostor: PhysicsImpostor): number;
  47681. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47682. sleepBody(impostor: PhysicsImpostor): void;
  47683. wakeUpBody(impostor: PhysicsImpostor): void;
  47684. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47685. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47686. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47687. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47688. getRadius(impostor: PhysicsImpostor): number;
  47689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47690. dispose(): void;
  47691. /**
  47692. * Does a raycast in the physics world
  47693. * @param from when should the ray start?
  47694. * @param to when should the ray end?
  47695. * @returns PhysicsRaycastResult
  47696. */
  47697. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47698. }
  47699. }
  47700. declare module BABYLON {
  47701. interface AbstractScene {
  47702. /**
  47703. * The list of reflection probes added to the scene
  47704. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47705. */
  47706. reflectionProbes: Array<ReflectionProbe>;
  47707. /**
  47708. * Removes the given reflection probe from this scene.
  47709. * @param toRemove The reflection probe to remove
  47710. * @returns The index of the removed reflection probe
  47711. */
  47712. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47713. /**
  47714. * Adds the given reflection probe to this scene.
  47715. * @param newReflectionProbe The reflection probe to add
  47716. */
  47717. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47718. }
  47719. /**
  47720. * Class used to generate realtime reflection / refraction cube textures
  47721. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47722. */
  47723. export class ReflectionProbe {
  47724. /** defines the name of the probe */
  47725. name: string;
  47726. private _scene;
  47727. private _renderTargetTexture;
  47728. private _projectionMatrix;
  47729. private _viewMatrix;
  47730. private _target;
  47731. private _add;
  47732. private _attachedMesh;
  47733. private _invertYAxis;
  47734. /** Gets or sets probe position (center of the cube map) */
  47735. position: Vector3;
  47736. /**
  47737. * Creates a new reflection probe
  47738. * @param name defines the name of the probe
  47739. * @param size defines the texture resolution (for each face)
  47740. * @param scene defines the hosting scene
  47741. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47742. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47743. */
  47744. constructor(
  47745. /** defines the name of the probe */
  47746. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47747. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47748. samples: number;
  47749. /** Gets or sets the refresh rate to use (on every frame by default) */
  47750. refreshRate: number;
  47751. /**
  47752. * Gets the hosting scene
  47753. * @returns a Scene
  47754. */
  47755. getScene(): Scene;
  47756. /** Gets the internal CubeTexture used to render to */
  47757. readonly cubeTexture: RenderTargetTexture;
  47758. /** Gets the list of meshes to render */
  47759. readonly renderList: Nullable<AbstractMesh[]>;
  47760. /**
  47761. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47762. * @param mesh defines the mesh to attach to
  47763. */
  47764. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47765. /**
  47766. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47767. * @param renderingGroupId The rendering group id corresponding to its index
  47768. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47769. */
  47770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47771. /**
  47772. * Clean all associated resources
  47773. */
  47774. dispose(): void;
  47775. /**
  47776. * Converts the reflection probe information to a readable string for debug purpose.
  47777. * @param fullDetails Supports for multiple levels of logging within scene loading
  47778. * @returns the human readable reflection probe info
  47779. */
  47780. toString(fullDetails?: boolean): string;
  47781. /**
  47782. * Get the class name of the relfection probe.
  47783. * @returns "ReflectionProbe"
  47784. */
  47785. getClassName(): string;
  47786. /**
  47787. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47788. * @returns The JSON representation of the texture
  47789. */
  47790. serialize(): any;
  47791. /**
  47792. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47793. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47794. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47795. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47796. * @returns The parsed reflection probe if successful
  47797. */
  47798. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47799. }
  47800. }
  47801. declare module BABYLON {
  47802. /** @hidden */
  47803. export var _BabylonLoaderRegistered: boolean;
  47804. }
  47805. declare module BABYLON {
  47806. /**
  47807. * The Physically based simple base material of BJS.
  47808. *
  47809. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47810. * It is used as the base class for both the specGloss and metalRough conventions.
  47811. */
  47812. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47813. /**
  47814. * Number of Simultaneous lights allowed on the material.
  47815. */
  47816. maxSimultaneousLights: number;
  47817. /**
  47818. * If sets to true, disables all the lights affecting the material.
  47819. */
  47820. disableLighting: boolean;
  47821. /**
  47822. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47823. */
  47824. environmentTexture: BaseTexture;
  47825. /**
  47826. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47827. */
  47828. invertNormalMapX: boolean;
  47829. /**
  47830. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47831. */
  47832. invertNormalMapY: boolean;
  47833. /**
  47834. * Normal map used in the model.
  47835. */
  47836. normalTexture: BaseTexture;
  47837. /**
  47838. * Emissivie color used to self-illuminate the model.
  47839. */
  47840. emissiveColor: Color3;
  47841. /**
  47842. * Emissivie texture used to self-illuminate the model.
  47843. */
  47844. emissiveTexture: BaseTexture;
  47845. /**
  47846. * Occlusion Channel Strenght.
  47847. */
  47848. occlusionStrength: number;
  47849. /**
  47850. * Occlusion Texture of the material (adding extra occlusion effects).
  47851. */
  47852. occlusionTexture: BaseTexture;
  47853. /**
  47854. * Defines the alpha limits in alpha test mode.
  47855. */
  47856. alphaCutOff: number;
  47857. /**
  47858. * Gets the current double sided mode.
  47859. */
  47860. /**
  47861. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47862. */
  47863. doubleSided: boolean;
  47864. /**
  47865. * Stores the pre-calculated light information of a mesh in a texture.
  47866. */
  47867. lightmapTexture: BaseTexture;
  47868. /**
  47869. * If true, the light map contains occlusion information instead of lighting info.
  47870. */
  47871. useLightmapAsShadowmap: boolean;
  47872. /**
  47873. * Instantiates a new PBRMaterial instance.
  47874. *
  47875. * @param name The material name
  47876. * @param scene The scene the material will be use in.
  47877. */
  47878. constructor(name: string, scene: Scene);
  47879. getClassName(): string;
  47880. }
  47881. }
  47882. declare module BABYLON {
  47883. /**
  47884. * The PBR material of BJS following the metal roughness convention.
  47885. *
  47886. * This fits to the PBR convention in the GLTF definition:
  47887. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47888. */
  47889. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47890. /**
  47891. * The base color has two different interpretations depending on the value of metalness.
  47892. * When the material is a metal, the base color is the specific measured reflectance value
  47893. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47894. * of the material.
  47895. */
  47896. baseColor: Color3;
  47897. /**
  47898. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47899. * well as opacity information in the alpha channel.
  47900. */
  47901. baseTexture: BaseTexture;
  47902. /**
  47903. * Specifies the metallic scalar value of the material.
  47904. * Can also be used to scale the metalness values of the metallic texture.
  47905. */
  47906. metallic: number;
  47907. /**
  47908. * Specifies the roughness scalar value of the material.
  47909. * Can also be used to scale the roughness values of the metallic texture.
  47910. */
  47911. roughness: number;
  47912. /**
  47913. * Texture containing both the metallic value in the B channel and the
  47914. * roughness value in the G channel to keep better precision.
  47915. */
  47916. metallicRoughnessTexture: BaseTexture;
  47917. /**
  47918. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47919. *
  47920. * @param name The material name
  47921. * @param scene The scene the material will be use in.
  47922. */
  47923. constructor(name: string, scene: Scene);
  47924. /**
  47925. * Return the currrent class name of the material.
  47926. */
  47927. getClassName(): string;
  47928. /**
  47929. * Makes a duplicate of the current material.
  47930. * @param name - name to use for the new material.
  47931. */
  47932. clone(name: string): PBRMetallicRoughnessMaterial;
  47933. /**
  47934. * Serialize the material to a parsable JSON object.
  47935. */
  47936. serialize(): any;
  47937. /**
  47938. * Parses a JSON object correponding to the serialize function.
  47939. */
  47940. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47941. }
  47942. }
  47943. declare module BABYLON {
  47944. /**
  47945. * The PBR material of BJS following the specular glossiness convention.
  47946. *
  47947. * This fits to the PBR convention in the GLTF definition:
  47948. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47949. */
  47950. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47951. /**
  47952. * Specifies the diffuse color of the material.
  47953. */
  47954. diffuseColor: Color3;
  47955. /**
  47956. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47957. * channel.
  47958. */
  47959. diffuseTexture: BaseTexture;
  47960. /**
  47961. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47962. */
  47963. specularColor: Color3;
  47964. /**
  47965. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47966. */
  47967. glossiness: number;
  47968. /**
  47969. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47970. */
  47971. specularGlossinessTexture: BaseTexture;
  47972. /**
  47973. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47974. *
  47975. * @param name The material name
  47976. * @param scene The scene the material will be use in.
  47977. */
  47978. constructor(name: string, scene: Scene);
  47979. /**
  47980. * Return the currrent class name of the material.
  47981. */
  47982. getClassName(): string;
  47983. /**
  47984. * Makes a duplicate of the current material.
  47985. * @param name - name to use for the new material.
  47986. */
  47987. clone(name: string): PBRSpecularGlossinessMaterial;
  47988. /**
  47989. * Serialize the material to a parsable JSON object.
  47990. */
  47991. serialize(): any;
  47992. /**
  47993. * Parses a JSON object correponding to the serialize function.
  47994. */
  47995. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47996. }
  47997. }
  47998. declare module BABYLON {
  47999. /**
  48000. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48001. * It can help converting any input color in a desired output one. This can then be used to create effects
  48002. * from sepia, black and white to sixties or futuristic rendering...
  48003. *
  48004. * The only supported format is currently 3dl.
  48005. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48006. */
  48007. export class ColorGradingTexture extends BaseTexture {
  48008. /**
  48009. * The current texture matrix. (will always be identity in color grading texture)
  48010. */
  48011. private _textureMatrix;
  48012. /**
  48013. * The texture URL.
  48014. */
  48015. url: string;
  48016. /**
  48017. * Empty line regex stored for GC.
  48018. */
  48019. private static _noneEmptyLineRegex;
  48020. private _engine;
  48021. /**
  48022. * Instantiates a ColorGradingTexture from the following parameters.
  48023. *
  48024. * @param url The location of the color gradind data (currently only supporting 3dl)
  48025. * @param scene The scene the texture will be used in
  48026. */
  48027. constructor(url: string, scene: Scene);
  48028. /**
  48029. * Returns the texture matrix used in most of the material.
  48030. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48031. */
  48032. getTextureMatrix(): Matrix;
  48033. /**
  48034. * Occurs when the file being loaded is a .3dl LUT file.
  48035. */
  48036. private load3dlTexture;
  48037. /**
  48038. * Starts the loading process of the texture.
  48039. */
  48040. private loadTexture;
  48041. /**
  48042. * Clones the color gradind texture.
  48043. */
  48044. clone(): ColorGradingTexture;
  48045. /**
  48046. * Called during delayed load for textures.
  48047. */
  48048. delayLoad(): void;
  48049. /**
  48050. * Parses a color grading texture serialized by Babylon.
  48051. * @param parsedTexture The texture information being parsedTexture
  48052. * @param scene The scene to load the texture in
  48053. * @param rootUrl The root url of the data assets to load
  48054. * @return A color gradind texture
  48055. */
  48056. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48057. /**
  48058. * Serializes the LUT texture to json format.
  48059. */
  48060. serialize(): any;
  48061. }
  48062. }
  48063. declare module BABYLON {
  48064. /**
  48065. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48066. */
  48067. export class EquiRectangularCubeTexture extends BaseTexture {
  48068. /** The six faces of the cube. */
  48069. private static _FacesMapping;
  48070. private _noMipmap;
  48071. private _onLoad;
  48072. private _onError;
  48073. /** The size of the cubemap. */
  48074. private _size;
  48075. /** The buffer of the image. */
  48076. private _buffer;
  48077. /** The width of the input image. */
  48078. private _width;
  48079. /** The height of the input image. */
  48080. private _height;
  48081. /** The URL to the image. */
  48082. url: string;
  48083. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48084. coordinatesMode: number;
  48085. /**
  48086. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48087. * @param url The location of the image
  48088. * @param scene The scene the texture will be used in
  48089. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48090. * @param noMipmap Forces to not generate the mipmap if true
  48091. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48092. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48093. * @param onLoad — defines a callback called when texture is loaded
  48094. * @param onError — defines a callback called if there is an error
  48095. */
  48096. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48097. /**
  48098. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48099. */
  48100. private loadImage;
  48101. /**
  48102. * Convert the image buffer into a cubemap and create a CubeTexture.
  48103. */
  48104. private loadTexture;
  48105. /**
  48106. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48107. * @param buffer The ArrayBuffer that should be converted.
  48108. * @returns The buffer as Float32Array.
  48109. */
  48110. private getFloat32ArrayFromArrayBuffer;
  48111. /**
  48112. * Get the current class name of the texture useful for serialization or dynamic coding.
  48113. * @returns "EquiRectangularCubeTexture"
  48114. */
  48115. getClassName(): string;
  48116. /**
  48117. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48118. * @returns A clone of the current EquiRectangularCubeTexture.
  48119. */
  48120. clone(): EquiRectangularCubeTexture;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Based on jsTGALoader - Javascript loader for TGA file
  48126. * By Vincent Thibault
  48127. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48128. */
  48129. export class TGATools {
  48130. private static _TYPE_INDEXED;
  48131. private static _TYPE_RGB;
  48132. private static _TYPE_GREY;
  48133. private static _TYPE_RLE_INDEXED;
  48134. private static _TYPE_RLE_RGB;
  48135. private static _TYPE_RLE_GREY;
  48136. private static _ORIGIN_MASK;
  48137. private static _ORIGIN_SHIFT;
  48138. private static _ORIGIN_BL;
  48139. private static _ORIGIN_BR;
  48140. private static _ORIGIN_UL;
  48141. private static _ORIGIN_UR;
  48142. /**
  48143. * Gets the header of a TGA file
  48144. * @param data defines the TGA data
  48145. * @returns the header
  48146. */
  48147. static GetTGAHeader(data: Uint8Array): any;
  48148. /**
  48149. * Uploads TGA content to a Babylon Texture
  48150. * @hidden
  48151. */
  48152. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48153. /** @hidden */
  48154. 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;
  48155. /** @hidden */
  48156. 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;
  48157. /** @hidden */
  48158. 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;
  48159. /** @hidden */
  48160. 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;
  48161. /** @hidden */
  48162. 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;
  48163. /** @hidden */
  48164. 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;
  48165. }
  48166. }
  48167. declare module BABYLON {
  48168. /**
  48169. * Implementation of the TGA Texture Loader.
  48170. * @hidden
  48171. */
  48172. export class _TGATextureLoader implements IInternalTextureLoader {
  48173. /**
  48174. * Defines wether the loader supports cascade loading the different faces.
  48175. */
  48176. readonly supportCascades: boolean;
  48177. /**
  48178. * This returns if the loader support the current file information.
  48179. * @param extension defines the file extension of the file being loaded
  48180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48181. * @param fallback defines the fallback internal texture if any
  48182. * @param isBase64 defines whether the texture is encoded as a base64
  48183. * @param isBuffer defines whether the texture data are stored as a buffer
  48184. * @returns true if the loader can load the specified file
  48185. */
  48186. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48187. /**
  48188. * Transform the url before loading if required.
  48189. * @param rootUrl the url of the texture
  48190. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48191. * @returns the transformed texture
  48192. */
  48193. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48194. /**
  48195. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48196. * @param rootUrl the url of the texture
  48197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48198. * @returns the fallback texture
  48199. */
  48200. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48201. /**
  48202. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48203. * @param data contains the texture data
  48204. * @param texture defines the BabylonJS internal texture
  48205. * @param createPolynomials will be true if polynomials have been requested
  48206. * @param onLoad defines the callback to trigger once the texture is ready
  48207. * @param onError defines the callback to trigger in case of error
  48208. */
  48209. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48210. /**
  48211. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48212. * @param data contains the texture data
  48213. * @param texture defines the BabylonJS internal texture
  48214. * @param callback defines the method to call once ready to upload
  48215. */
  48216. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48217. }
  48218. }
  48219. declare module BABYLON {
  48220. /**
  48221. * 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.
  48222. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48223. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48224. */
  48225. export class CustomProceduralTexture extends ProceduralTexture {
  48226. private _animate;
  48227. private _time;
  48228. private _config;
  48229. private _texturePath;
  48230. /**
  48231. * Instantiates a new Custom Procedural Texture.
  48232. * 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.
  48233. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48234. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48235. * @param name Define the name of the texture
  48236. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48237. * @param size Define the size of the texture to create
  48238. * @param scene Define the scene the texture belongs to
  48239. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48240. * @param generateMipMaps Define if the texture should creates mip maps or not
  48241. */
  48242. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48243. private _loadJson;
  48244. /**
  48245. * Is the texture ready to be used ? (rendered at least once)
  48246. * @returns true if ready, otherwise, false.
  48247. */
  48248. isReady(): boolean;
  48249. /**
  48250. * Render the texture to its associated render target.
  48251. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48252. */
  48253. render(useCameraPostProcess?: boolean): void;
  48254. /**
  48255. * Update the list of dependant textures samplers in the shader.
  48256. */
  48257. updateTextures(): void;
  48258. /**
  48259. * Update the uniform values of the procedural texture in the shader.
  48260. */
  48261. updateShaderUniforms(): void;
  48262. /**
  48263. * Define if the texture animates or not.
  48264. */
  48265. animate: boolean;
  48266. }
  48267. }
  48268. declare module BABYLON {
  48269. /** @hidden */
  48270. export var noisePixelShader: {
  48271. name: string;
  48272. shader: string;
  48273. };
  48274. }
  48275. declare module BABYLON {
  48276. /**
  48277. * Class used to generate noise procedural textures
  48278. */
  48279. export class NoiseProceduralTexture extends ProceduralTexture {
  48280. private _time;
  48281. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48282. brightness: number;
  48283. /** Defines the number of octaves to process */
  48284. octaves: number;
  48285. /** Defines the level of persistence (0.8 by default) */
  48286. persistence: number;
  48287. /** Gets or sets animation speed factor (default is 1) */
  48288. animationSpeedFactor: number;
  48289. /**
  48290. * Creates a new NoiseProceduralTexture
  48291. * @param name defines the name fo the texture
  48292. * @param size defines the size of the texture (default is 256)
  48293. * @param scene defines the hosting scene
  48294. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48295. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48296. */
  48297. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48298. private _updateShaderUniforms;
  48299. protected _getDefines(): string;
  48300. /** Generate the current state of the procedural texture */
  48301. render(useCameraPostProcess?: boolean): void;
  48302. /**
  48303. * Serializes this noise procedural texture
  48304. * @returns a serialized noise procedural texture object
  48305. */
  48306. serialize(): any;
  48307. /**
  48308. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48309. * @param parsedTexture defines parsed texture data
  48310. * @param scene defines the current scene
  48311. * @param rootUrl defines the root URL containing noise procedural texture information
  48312. * @returns a parsed NoiseProceduralTexture
  48313. */
  48314. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48315. }
  48316. }
  48317. declare module BABYLON {
  48318. /**
  48319. * Raw cube texture where the raw buffers are passed in
  48320. */
  48321. export class RawCubeTexture extends CubeTexture {
  48322. /**
  48323. * Creates a cube texture where the raw buffers are passed in.
  48324. * @param scene defines the scene the texture is attached to
  48325. * @param data defines the array of data to use to create each face
  48326. * @param size defines the size of the textures
  48327. * @param format defines the format of the data
  48328. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48329. * @param generateMipMaps defines if the engine should generate the mip levels
  48330. * @param invertY defines if data must be stored with Y axis inverted
  48331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48332. * @param compression defines the compression used (null by default)
  48333. */
  48334. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48335. /**
  48336. * Updates the raw cube texture.
  48337. * @param data defines the data to store
  48338. * @param format defines the data format
  48339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48340. * @param invertY defines if data must be stored with Y axis inverted
  48341. * @param compression defines the compression used (null by default)
  48342. * @param level defines which level of the texture to update
  48343. */
  48344. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48345. /**
  48346. * Updates a raw cube texture with RGBD encoded data.
  48347. * @param data defines the array of data [mipmap][face] to use to create each face
  48348. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48349. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48350. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48351. * @returns a promsie that resolves when the operation is complete
  48352. */
  48353. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48354. /**
  48355. * Clones the raw cube texture.
  48356. * @return a new cube texture
  48357. */
  48358. clone(): CubeTexture;
  48359. /** @hidden */
  48360. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48361. }
  48362. }
  48363. declare module BABYLON {
  48364. /**
  48365. * Class used to store 3D textures containing user data
  48366. */
  48367. export class RawTexture3D extends Texture {
  48368. /** Gets or sets the texture format to use */
  48369. format: number;
  48370. private _engine;
  48371. /**
  48372. * Create a new RawTexture3D
  48373. * @param data defines the data of the texture
  48374. * @param width defines the width of the texture
  48375. * @param height defines the height of the texture
  48376. * @param depth defines the depth of the texture
  48377. * @param format defines the texture format to use
  48378. * @param scene defines the hosting scene
  48379. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48380. * @param invertY defines if texture must be stored with Y axis inverted
  48381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48382. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48383. */
  48384. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48385. /** Gets or sets the texture format to use */
  48386. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48387. /**
  48388. * Update the texture with new data
  48389. * @param data defines the data to store in the texture
  48390. */
  48391. update(data: ArrayBufferView): void;
  48392. }
  48393. }
  48394. declare module BABYLON {
  48395. /**
  48396. * Creates a refraction texture used by refraction channel of the standard material.
  48397. * It is like a mirror but to see through a material.
  48398. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48399. */
  48400. export class RefractionTexture extends RenderTargetTexture {
  48401. /**
  48402. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48403. * 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.
  48404. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48405. */
  48406. refractionPlane: Plane;
  48407. /**
  48408. * Define how deep under the surface we should see.
  48409. */
  48410. depth: number;
  48411. /**
  48412. * Creates a refraction texture used by refraction channel of the standard material.
  48413. * It is like a mirror but to see through a material.
  48414. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48415. * @param name Define the texture name
  48416. * @param size Define the size of the underlying texture
  48417. * @param scene Define the scene the refraction belongs to
  48418. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48419. */
  48420. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48421. /**
  48422. * Clone the refraction texture.
  48423. * @returns the cloned texture
  48424. */
  48425. clone(): RefractionTexture;
  48426. /**
  48427. * Serialize the texture to a JSON representation you could use in Parse later on
  48428. * @returns the serialized JSON representation
  48429. */
  48430. serialize(): any;
  48431. }
  48432. }
  48433. declare module BABYLON {
  48434. /**
  48435. * Configuration for Draco compression
  48436. */
  48437. export interface IDracoCompressionConfiguration {
  48438. /**
  48439. * Configuration for the decoder.
  48440. */
  48441. decoder?: {
  48442. /**
  48443. * The url to the WebAssembly module.
  48444. */
  48445. wasmUrl?: string;
  48446. /**
  48447. * The url to the WebAssembly binary.
  48448. */
  48449. wasmBinaryUrl?: string;
  48450. /**
  48451. * The url to the fallback JavaScript module.
  48452. */
  48453. fallbackUrl?: string;
  48454. };
  48455. }
  48456. /**
  48457. * Draco compression (https://google.github.io/draco/)
  48458. *
  48459. * This class wraps the Draco module.
  48460. *
  48461. * **Encoder**
  48462. *
  48463. * The encoder is not currently implemented.
  48464. *
  48465. * **Decoder**
  48466. *
  48467. * 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.
  48468. *
  48469. * To update the configuration, use the following code:
  48470. * ```javascript
  48471. * DracoCompression.Configuration = {
  48472. * decoder: {
  48473. * wasmUrl: "<url to the WebAssembly library>",
  48474. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48475. * fallbackUrl: "<url to the fallback JavaScript library>",
  48476. * }
  48477. * };
  48478. * ```
  48479. *
  48480. * 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.
  48481. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48482. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48483. *
  48484. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48485. * ```javascript
  48486. * var dracoCompression = new DracoCompression();
  48487. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48488. * [VertexBuffer.PositionKind]: 0
  48489. * });
  48490. * ```
  48491. *
  48492. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48493. */
  48494. export class DracoCompression implements IDisposable {
  48495. private static _DecoderModulePromise;
  48496. /**
  48497. * The configuration. Defaults to the following urls:
  48498. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48499. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48500. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48501. */
  48502. static Configuration: IDracoCompressionConfiguration;
  48503. /**
  48504. * Returns true if the decoder is available.
  48505. */
  48506. static readonly DecoderAvailable: boolean;
  48507. /**
  48508. * Constructor
  48509. */
  48510. constructor();
  48511. /**
  48512. * Stop all async operations and release resources.
  48513. */
  48514. dispose(): void;
  48515. /**
  48516. * Decode Draco compressed mesh data to vertex data.
  48517. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48518. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48519. * @returns A promise that resolves with the decoded vertex data
  48520. */
  48521. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48522. [kind: string]: number;
  48523. }): Promise<VertexData>;
  48524. private static _GetDecoderModule;
  48525. private static _LoadScriptAsync;
  48526. private static _LoadFileAsync;
  48527. }
  48528. }
  48529. declare module BABYLON {
  48530. /**
  48531. * Class for building Constructive Solid Geometry
  48532. */
  48533. export class CSG {
  48534. private polygons;
  48535. /**
  48536. * The world matrix
  48537. */
  48538. matrix: Matrix;
  48539. /**
  48540. * Stores the position
  48541. */
  48542. position: Vector3;
  48543. /**
  48544. * Stores the rotation
  48545. */
  48546. rotation: Vector3;
  48547. /**
  48548. * Stores the rotation quaternion
  48549. */
  48550. rotationQuaternion: Nullable<Quaternion>;
  48551. /**
  48552. * Stores the scaling vector
  48553. */
  48554. scaling: Vector3;
  48555. /**
  48556. * Convert the Mesh to CSG
  48557. * @param mesh The Mesh to convert to CSG
  48558. * @returns A new CSG from the Mesh
  48559. */
  48560. static FromMesh(mesh: Mesh): CSG;
  48561. /**
  48562. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48563. * @param polygons Polygons used to construct a CSG solid
  48564. */
  48565. private static FromPolygons;
  48566. /**
  48567. * Clones, or makes a deep copy, of the CSG
  48568. * @returns A new CSG
  48569. */
  48570. clone(): CSG;
  48571. /**
  48572. * Unions this CSG with another CSG
  48573. * @param csg The CSG to union against this CSG
  48574. * @returns The unioned CSG
  48575. */
  48576. union(csg: CSG): CSG;
  48577. /**
  48578. * Unions this CSG with another CSG in place
  48579. * @param csg The CSG to union against this CSG
  48580. */
  48581. unionInPlace(csg: CSG): void;
  48582. /**
  48583. * Subtracts this CSG with another CSG
  48584. * @param csg The CSG to subtract against this CSG
  48585. * @returns A new CSG
  48586. */
  48587. subtract(csg: CSG): CSG;
  48588. /**
  48589. * Subtracts this CSG with another CSG in place
  48590. * @param csg The CSG to subtact against this CSG
  48591. */
  48592. subtractInPlace(csg: CSG): void;
  48593. /**
  48594. * Intersect this CSG with another CSG
  48595. * @param csg The CSG to intersect against this CSG
  48596. * @returns A new CSG
  48597. */
  48598. intersect(csg: CSG): CSG;
  48599. /**
  48600. * Intersects this CSG with another CSG in place
  48601. * @param csg The CSG to intersect against this CSG
  48602. */
  48603. intersectInPlace(csg: CSG): void;
  48604. /**
  48605. * Return a new CSG solid with solid and empty space switched. This solid is
  48606. * not modified.
  48607. * @returns A new CSG solid with solid and empty space switched
  48608. */
  48609. inverse(): CSG;
  48610. /**
  48611. * Inverses the CSG in place
  48612. */
  48613. inverseInPlace(): void;
  48614. /**
  48615. * This is used to keep meshes transformations so they can be restored
  48616. * when we build back a Babylon Mesh
  48617. * NB : All CSG operations are performed in world coordinates
  48618. * @param csg The CSG to copy the transform attributes from
  48619. * @returns This CSG
  48620. */
  48621. copyTransformAttributes(csg: CSG): CSG;
  48622. /**
  48623. * Build Raw mesh from CSG
  48624. * Coordinates here are in world space
  48625. * @param name The name of the mesh geometry
  48626. * @param scene The Scene
  48627. * @param keepSubMeshes Specifies if the submeshes should be kept
  48628. * @returns A new Mesh
  48629. */
  48630. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48631. /**
  48632. * Build Mesh from CSG taking material and transforms into account
  48633. * @param name The name of the Mesh
  48634. * @param material The material of the Mesh
  48635. * @param scene The Scene
  48636. * @param keepSubMeshes Specifies if submeshes should be kept
  48637. * @returns The new Mesh
  48638. */
  48639. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48640. }
  48641. }
  48642. declare module BABYLON {
  48643. /**
  48644. * Class used to create a trail following a mesh
  48645. */
  48646. export class TrailMesh extends Mesh {
  48647. private _generator;
  48648. private _autoStart;
  48649. private _running;
  48650. private _diameter;
  48651. private _length;
  48652. private _sectionPolygonPointsCount;
  48653. private _sectionVectors;
  48654. private _sectionNormalVectors;
  48655. private _beforeRenderObserver;
  48656. /**
  48657. * @constructor
  48658. * @param name The value used by scene.getMeshByName() to do a lookup.
  48659. * @param generator The mesh to generate a trail.
  48660. * @param scene The scene to add this mesh to.
  48661. * @param diameter Diameter of trailing mesh. Default is 1.
  48662. * @param length Length of trailing mesh. Default is 60.
  48663. * @param autoStart Automatically start trailing mesh. Default true.
  48664. */
  48665. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48666. /**
  48667. * "TrailMesh"
  48668. * @returns "TrailMesh"
  48669. */
  48670. getClassName(): string;
  48671. private _createMesh;
  48672. /**
  48673. * Start trailing mesh.
  48674. */
  48675. start(): void;
  48676. /**
  48677. * Stop trailing mesh.
  48678. */
  48679. stop(): void;
  48680. /**
  48681. * Update trailing mesh geometry.
  48682. */
  48683. update(): void;
  48684. /**
  48685. * Returns a new TrailMesh object.
  48686. * @param name is a string, the name given to the new mesh
  48687. * @param newGenerator use new generator object for cloned trail mesh
  48688. * @returns a new mesh
  48689. */
  48690. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48691. /**
  48692. * Serializes this trail mesh
  48693. * @param serializationObject object to write serialization to
  48694. */
  48695. serialize(serializationObject: any): void;
  48696. /**
  48697. * Parses a serialized trail mesh
  48698. * @param parsedMesh the serialized mesh
  48699. * @param scene the scene to create the trail mesh in
  48700. * @returns the created trail mesh
  48701. */
  48702. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48703. }
  48704. }
  48705. declare module BABYLON {
  48706. /**
  48707. * Class containing static functions to help procedurally build meshes
  48708. */
  48709. export class RibbonBuilder {
  48710. /**
  48711. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48712. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48713. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48714. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48715. * * 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
  48716. * * 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
  48717. * * 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
  48718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48719. * * 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
  48720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48721. * * 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
  48722. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48723. * * 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
  48724. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48726. * @param name defines the name of the mesh
  48727. * @param options defines the options used to create the mesh
  48728. * @param scene defines the hosting scene
  48729. * @returns the ribbon mesh
  48730. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48731. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48732. */
  48733. static CreateRibbon(name: string, options: {
  48734. pathArray: Vector3[][];
  48735. closeArray?: boolean;
  48736. closePath?: boolean;
  48737. offset?: number;
  48738. updatable?: boolean;
  48739. sideOrientation?: number;
  48740. frontUVs?: Vector4;
  48741. backUVs?: Vector4;
  48742. instance?: Mesh;
  48743. invertUV?: boolean;
  48744. uvs?: Vector2[];
  48745. colors?: Color4[];
  48746. }, scene?: Nullable<Scene>): Mesh;
  48747. }
  48748. }
  48749. declare module BABYLON {
  48750. /**
  48751. * Class containing static functions to help procedurally build meshes
  48752. */
  48753. export class TorusKnotBuilder {
  48754. /**
  48755. * Creates a torus knot mesh
  48756. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48757. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48758. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48759. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48761. * * 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
  48762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48763. * @param name defines the name of the mesh
  48764. * @param options defines the options used to create the mesh
  48765. * @param scene defines the hosting scene
  48766. * @returns the torus knot mesh
  48767. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48768. */
  48769. static CreateTorusKnot(name: string, options: {
  48770. radius?: number;
  48771. tube?: number;
  48772. radialSegments?: number;
  48773. tubularSegments?: number;
  48774. p?: number;
  48775. q?: number;
  48776. updatable?: boolean;
  48777. sideOrientation?: number;
  48778. frontUVs?: Vector4;
  48779. backUVs?: Vector4;
  48780. }, scene: any): Mesh;
  48781. }
  48782. }
  48783. declare module BABYLON {
  48784. /**
  48785. * Polygon
  48786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48787. */
  48788. export class Polygon {
  48789. /**
  48790. * Creates a rectangle
  48791. * @param xmin bottom X coord
  48792. * @param ymin bottom Y coord
  48793. * @param xmax top X coord
  48794. * @param ymax top Y coord
  48795. * @returns points that make the resulting rectation
  48796. */
  48797. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48798. /**
  48799. * Creates a circle
  48800. * @param radius radius of circle
  48801. * @param cx scale in x
  48802. * @param cy scale in y
  48803. * @param numberOfSides number of sides that make up the circle
  48804. * @returns points that make the resulting circle
  48805. */
  48806. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48807. /**
  48808. * Creates a polygon from input string
  48809. * @param input Input polygon data
  48810. * @returns the parsed points
  48811. */
  48812. static Parse(input: string): Vector2[];
  48813. /**
  48814. * Starts building a polygon from x and y coordinates
  48815. * @param x x coordinate
  48816. * @param y y coordinate
  48817. * @returns the started path2
  48818. */
  48819. static StartingAt(x: number, y: number): Path2;
  48820. }
  48821. /**
  48822. * Builds a polygon
  48823. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48824. */
  48825. export class PolygonMeshBuilder {
  48826. private _points;
  48827. private _outlinepoints;
  48828. private _holes;
  48829. private _name;
  48830. private _scene;
  48831. private _epoints;
  48832. private _eholes;
  48833. private _addToepoint;
  48834. /**
  48835. * Babylon reference to the earcut plugin.
  48836. */
  48837. bjsEarcut: any;
  48838. /**
  48839. * Creates a PolygonMeshBuilder
  48840. * @param name name of the builder
  48841. * @param contours Path of the polygon
  48842. * @param scene scene to add to when creating the mesh
  48843. * @param earcutInjection can be used to inject your own earcut reference
  48844. */
  48845. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48846. /**
  48847. * Adds a whole within the polygon
  48848. * @param hole Array of points defining the hole
  48849. * @returns this
  48850. */
  48851. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48852. /**
  48853. * Creates the polygon
  48854. * @param updatable If the mesh should be updatable
  48855. * @param depth The depth of the mesh created
  48856. * @returns the created mesh
  48857. */
  48858. build(updatable?: boolean, depth?: number): Mesh;
  48859. /**
  48860. * Creates the polygon
  48861. * @param depth The depth of the mesh created
  48862. * @returns the created VertexData
  48863. */
  48864. buildVertexData(depth?: number): VertexData;
  48865. /**
  48866. * Adds a side to the polygon
  48867. * @param positions points that make the polygon
  48868. * @param normals normals of the polygon
  48869. * @param uvs uvs of the polygon
  48870. * @param indices indices of the polygon
  48871. * @param bounds bounds of the polygon
  48872. * @param points points of the polygon
  48873. * @param depth depth of the polygon
  48874. * @param flip flip of the polygon
  48875. */
  48876. private addSide;
  48877. }
  48878. }
  48879. declare module BABYLON {
  48880. /**
  48881. * Class containing static functions to help procedurally build meshes
  48882. */
  48883. export class PolygonBuilder {
  48884. /**
  48885. * Creates a polygon mesh
  48886. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48887. * * 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
  48888. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48890. * * 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)
  48891. * * Remember you can only change the shape positions, not their number when updating a polygon
  48892. * @param name defines the name of the mesh
  48893. * @param options defines the options used to create the mesh
  48894. * @param scene defines the hosting scene
  48895. * @param earcutInjection can be used to inject your own earcut reference
  48896. * @returns the polygon mesh
  48897. */
  48898. static CreatePolygon(name: string, options: {
  48899. shape: Vector3[];
  48900. holes?: Vector3[][];
  48901. depth?: number;
  48902. faceUV?: Vector4[];
  48903. faceColors?: Color4[];
  48904. updatable?: boolean;
  48905. sideOrientation?: number;
  48906. frontUVs?: Vector4;
  48907. backUVs?: Vector4;
  48908. }, scene: Scene, earcutInjection?: any): Mesh;
  48909. /**
  48910. * Creates an extruded polygon mesh, with depth in the Y direction.
  48911. * * 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)
  48912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48913. * @param name defines the name of the mesh
  48914. * @param options defines the options used to create the mesh
  48915. * @param scene defines the hosting scene
  48916. * @param earcutInjection can be used to inject your own earcut reference
  48917. * @returns the polygon mesh
  48918. */
  48919. static ExtrudePolygon(name: string, options: {
  48920. shape: Vector3[];
  48921. holes?: Vector3[][];
  48922. depth?: number;
  48923. faceUV?: Vector4[];
  48924. faceColors?: Color4[];
  48925. updatable?: boolean;
  48926. sideOrientation?: number;
  48927. frontUVs?: Vector4;
  48928. backUVs?: Vector4;
  48929. }, scene: Scene, earcutInjection?: any): Mesh;
  48930. }
  48931. }
  48932. declare module BABYLON {
  48933. /**
  48934. * Class containing static functions to help procedurally build meshes
  48935. */
  48936. export class ShapeBuilder {
  48937. /**
  48938. * 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.
  48939. * * 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.
  48940. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48941. * * 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.
  48942. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48943. * * 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
  48944. * * 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
  48945. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48947. * * 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
  48948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48950. * @param name defines the name of the mesh
  48951. * @param options defines the options used to create the mesh
  48952. * @param scene defines the hosting scene
  48953. * @returns the extruded shape mesh
  48954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48956. */
  48957. static ExtrudeShape(name: string, options: {
  48958. shape: Vector3[];
  48959. path: Vector3[];
  48960. scale?: number;
  48961. rotation?: number;
  48962. cap?: number;
  48963. updatable?: boolean;
  48964. sideOrientation?: number;
  48965. frontUVs?: Vector4;
  48966. backUVs?: Vector4;
  48967. instance?: Mesh;
  48968. invertUV?: boolean;
  48969. }, scene?: Nullable<Scene>): Mesh;
  48970. /**
  48971. * Creates an custom extruded shape mesh.
  48972. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48973. * * 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.
  48974. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48975. * * 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
  48976. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48977. * * 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
  48978. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48979. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48980. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48981. * * 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
  48982. * * 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
  48983. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48985. * * 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
  48986. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48988. * @param name defines the name of the mesh
  48989. * @param options defines the options used to create the mesh
  48990. * @param scene defines the hosting scene
  48991. * @returns the custom extruded shape mesh
  48992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48995. */
  48996. static ExtrudeShapeCustom(name: string, options: {
  48997. shape: Vector3[];
  48998. path: Vector3[];
  48999. scaleFunction?: any;
  49000. rotationFunction?: any;
  49001. ribbonCloseArray?: boolean;
  49002. ribbonClosePath?: boolean;
  49003. cap?: number;
  49004. updatable?: boolean;
  49005. sideOrientation?: number;
  49006. frontUVs?: Vector4;
  49007. backUVs?: Vector4;
  49008. instance?: Mesh;
  49009. invertUV?: boolean;
  49010. }, scene: Scene): Mesh;
  49011. private static _ExtrudeShapeGeneric;
  49012. }
  49013. }
  49014. declare module BABYLON {
  49015. /**
  49016. * Class containing static functions to help procedurally build meshes
  49017. */
  49018. export class LatheBuilder {
  49019. /**
  49020. * Creates lathe mesh.
  49021. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49022. * * 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
  49023. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49024. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49025. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49026. * * 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
  49027. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49028. * * 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
  49029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49030. * * 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
  49031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49033. * @param name defines the name of the mesh
  49034. * @param options defines the options used to create the mesh
  49035. * @param scene defines the hosting scene
  49036. * @returns the lathe mesh
  49037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49038. */
  49039. static CreateLathe(name: string, options: {
  49040. shape: Vector3[];
  49041. radius?: number;
  49042. tessellation?: number;
  49043. clip?: number;
  49044. arc?: number;
  49045. closed?: boolean;
  49046. updatable?: boolean;
  49047. sideOrientation?: number;
  49048. frontUVs?: Vector4;
  49049. backUVs?: Vector4;
  49050. cap?: number;
  49051. invertUV?: boolean;
  49052. }, scene: Scene): Mesh;
  49053. }
  49054. }
  49055. declare module BABYLON {
  49056. /**
  49057. * Class containing static functions to help procedurally build meshes
  49058. */
  49059. export class TubeBuilder {
  49060. /**
  49061. * Creates a tube mesh.
  49062. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49063. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49064. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49065. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49066. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49067. * * 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)
  49068. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49069. * * 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
  49070. * * 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
  49071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49072. * * 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
  49073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49075. * @param name defines the name of the mesh
  49076. * @param options defines the options used to create the mesh
  49077. * @param scene defines the hosting scene
  49078. * @returns the tube mesh
  49079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49080. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49081. */
  49082. static CreateTube(name: string, options: {
  49083. path: Vector3[];
  49084. radius?: number;
  49085. tessellation?: number;
  49086. radiusFunction?: {
  49087. (i: number, distance: number): number;
  49088. };
  49089. cap?: number;
  49090. arc?: number;
  49091. updatable?: boolean;
  49092. sideOrientation?: number;
  49093. frontUVs?: Vector4;
  49094. backUVs?: Vector4;
  49095. instance?: Mesh;
  49096. invertUV?: boolean;
  49097. }, scene: Scene): Mesh;
  49098. }
  49099. }
  49100. declare module BABYLON {
  49101. /**
  49102. * Class containing static functions to help procedurally build meshes
  49103. */
  49104. export class IcoSphereBuilder {
  49105. /**
  49106. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49107. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49108. * * 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`)
  49109. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49110. * * 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
  49111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49112. * * 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
  49113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49114. * @param name defines the name of the mesh
  49115. * @param options defines the options used to create the mesh
  49116. * @param scene defines the hosting scene
  49117. * @returns the icosahedron mesh
  49118. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49119. */
  49120. static CreateIcoSphere(name: string, options: {
  49121. radius?: number;
  49122. radiusX?: number;
  49123. radiusY?: number;
  49124. radiusZ?: number;
  49125. flat?: boolean;
  49126. subdivisions?: number;
  49127. sideOrientation?: number;
  49128. frontUVs?: Vector4;
  49129. backUVs?: Vector4;
  49130. updatable?: boolean;
  49131. }, scene: Scene): Mesh;
  49132. }
  49133. }
  49134. declare module BABYLON {
  49135. /**
  49136. * Class containing static functions to help procedurally build meshes
  49137. */
  49138. export class DecalBuilder {
  49139. /**
  49140. * Creates a decal mesh.
  49141. * 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
  49142. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49143. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49144. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49145. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49146. * @param name defines the name of the mesh
  49147. * @param sourceMesh defines the mesh where the decal must be applied
  49148. * @param options defines the options used to create the mesh
  49149. * @param scene defines the hosting scene
  49150. * @returns the decal mesh
  49151. * @see https://doc.babylonjs.com/how_to/decals
  49152. */
  49153. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49154. position?: Vector3;
  49155. normal?: Vector3;
  49156. size?: Vector3;
  49157. angle?: number;
  49158. }): Mesh;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. /**
  49163. * Class containing static functions to help procedurally build meshes
  49164. */
  49165. export class MeshBuilder {
  49166. /**
  49167. * Creates a box mesh
  49168. * * The parameter `size` sets the size (float) of each box side (default 1)
  49169. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49170. * * 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)
  49171. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49173. * * 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
  49174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49175. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49176. * @param name defines the name of the mesh
  49177. * @param options defines the options used to create the mesh
  49178. * @param scene defines the hosting scene
  49179. * @returns the box mesh
  49180. */
  49181. static CreateBox(name: string, options: {
  49182. size?: number;
  49183. width?: number;
  49184. height?: number;
  49185. depth?: number;
  49186. faceUV?: Vector4[];
  49187. faceColors?: Color4[];
  49188. sideOrientation?: number;
  49189. frontUVs?: Vector4;
  49190. backUVs?: Vector4;
  49191. updatable?: boolean;
  49192. }, scene?: Nullable<Scene>): Mesh;
  49193. /**
  49194. * Creates a sphere mesh
  49195. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49196. * * 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`)
  49197. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49198. * * 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
  49199. * * 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)
  49200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49201. * * 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
  49202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49203. * @param name defines the name of the mesh
  49204. * @param options defines the options used to create the mesh
  49205. * @param scene defines the hosting scene
  49206. * @returns the sphere mesh
  49207. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49208. */
  49209. static CreateSphere(name: string, options: {
  49210. segments?: number;
  49211. diameter?: number;
  49212. diameterX?: number;
  49213. diameterY?: number;
  49214. diameterZ?: number;
  49215. arc?: number;
  49216. slice?: number;
  49217. sideOrientation?: number;
  49218. frontUVs?: Vector4;
  49219. backUVs?: Vector4;
  49220. updatable?: boolean;
  49221. }, scene: any): Mesh;
  49222. /**
  49223. * Creates a plane polygonal mesh. By default, this is a disc
  49224. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49225. * * 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
  49226. * * 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
  49227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49228. * * 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
  49229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49230. * @param name defines the name of the mesh
  49231. * @param options defines the options used to create the mesh
  49232. * @param scene defines the hosting scene
  49233. * @returns the plane polygonal mesh
  49234. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49235. */
  49236. static CreateDisc(name: string, options: {
  49237. radius?: number;
  49238. tessellation?: number;
  49239. arc?: number;
  49240. updatable?: boolean;
  49241. sideOrientation?: number;
  49242. frontUVs?: Vector4;
  49243. backUVs?: Vector4;
  49244. }, scene?: Nullable<Scene>): Mesh;
  49245. /**
  49246. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49247. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49248. * * 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`)
  49249. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49250. * * 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
  49251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49252. * * 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
  49253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49254. * @param name defines the name of the mesh
  49255. * @param options defines the options used to create the mesh
  49256. * @param scene defines the hosting scene
  49257. * @returns the icosahedron mesh
  49258. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49259. */
  49260. static CreateIcoSphere(name: string, options: {
  49261. radius?: number;
  49262. radiusX?: number;
  49263. radiusY?: number;
  49264. radiusZ?: number;
  49265. flat?: boolean;
  49266. subdivisions?: number;
  49267. sideOrientation?: number;
  49268. frontUVs?: Vector4;
  49269. backUVs?: Vector4;
  49270. updatable?: boolean;
  49271. }, scene: Scene): Mesh;
  49272. /**
  49273. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49274. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49275. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49276. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49277. * * 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
  49278. * * 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
  49279. * * 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
  49280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49281. * * 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
  49282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49283. * * 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
  49284. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49285. * * 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
  49286. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49288. * @param name defines the name of the mesh
  49289. * @param options defines the options used to create the mesh
  49290. * @param scene defines the hosting scene
  49291. * @returns the ribbon mesh
  49292. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49294. */
  49295. static CreateRibbon(name: string, options: {
  49296. pathArray: Vector3[][];
  49297. closeArray?: boolean;
  49298. closePath?: boolean;
  49299. offset?: number;
  49300. updatable?: boolean;
  49301. sideOrientation?: number;
  49302. frontUVs?: Vector4;
  49303. backUVs?: Vector4;
  49304. instance?: Mesh;
  49305. invertUV?: boolean;
  49306. uvs?: Vector2[];
  49307. colors?: Color4[];
  49308. }, scene?: Nullable<Scene>): Mesh;
  49309. /**
  49310. * Creates a cylinder or a cone mesh
  49311. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49312. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49313. * * 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.
  49314. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49315. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49316. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49317. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49318. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49319. * * 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).
  49320. * * 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
  49321. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49322. * * 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
  49323. * * 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.
  49324. * * If `enclose` is false, a ring surface is one element.
  49325. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49326. * * 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
  49327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49328. * * 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
  49329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49330. * @param name defines the name of the mesh
  49331. * @param options defines the options used to create the mesh
  49332. * @param scene defines the hosting scene
  49333. * @returns the cylinder mesh
  49334. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49335. */
  49336. static CreateCylinder(name: string, options: {
  49337. height?: number;
  49338. diameterTop?: number;
  49339. diameterBottom?: number;
  49340. diameter?: number;
  49341. tessellation?: number;
  49342. subdivisions?: number;
  49343. arc?: number;
  49344. faceColors?: Color4[];
  49345. faceUV?: Vector4[];
  49346. updatable?: boolean;
  49347. hasRings?: boolean;
  49348. enclose?: boolean;
  49349. sideOrientation?: number;
  49350. frontUVs?: Vector4;
  49351. backUVs?: Vector4;
  49352. }, scene: any): Mesh;
  49353. /**
  49354. * Creates a torus mesh
  49355. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49356. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49357. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49359. * * 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
  49360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49361. * @param name defines the name of the mesh
  49362. * @param options defines the options used to create the mesh
  49363. * @param scene defines the hosting scene
  49364. * @returns the torus mesh
  49365. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49366. */
  49367. static CreateTorus(name: string, options: {
  49368. diameter?: number;
  49369. thickness?: number;
  49370. tessellation?: number;
  49371. updatable?: boolean;
  49372. sideOrientation?: number;
  49373. frontUVs?: Vector4;
  49374. backUVs?: Vector4;
  49375. }, scene: any): Mesh;
  49376. /**
  49377. * Creates a torus knot mesh
  49378. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49379. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49380. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49381. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49383. * * 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
  49384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49385. * @param name defines the name of the mesh
  49386. * @param options defines the options used to create the mesh
  49387. * @param scene defines the hosting scene
  49388. * @returns the torus knot mesh
  49389. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49390. */
  49391. static CreateTorusKnot(name: string, options: {
  49392. radius?: number;
  49393. tube?: number;
  49394. radialSegments?: number;
  49395. tubularSegments?: number;
  49396. p?: number;
  49397. q?: number;
  49398. updatable?: boolean;
  49399. sideOrientation?: number;
  49400. frontUVs?: Vector4;
  49401. backUVs?: Vector4;
  49402. }, scene: any): Mesh;
  49403. /**
  49404. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49405. * * 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
  49406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49407. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49408. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49409. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49410. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49411. * * 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
  49412. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49415. * @param name defines the name of the new line system
  49416. * @param options defines the options used to create the line system
  49417. * @param scene defines the hosting scene
  49418. * @returns a new line system mesh
  49419. */
  49420. static CreateLineSystem(name: string, options: {
  49421. lines: Vector3[][];
  49422. updatable?: boolean;
  49423. instance?: Nullable<LinesMesh>;
  49424. colors?: Nullable<Color4[][]>;
  49425. useVertexAlpha?: boolean;
  49426. }, scene: Nullable<Scene>): LinesMesh;
  49427. /**
  49428. * Creates a line mesh
  49429. * 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
  49430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49431. * * The parameter `points` is an array successive Vector3
  49432. * * 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
  49433. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49434. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49435. * * When updating an instance, remember that only point positions can change, not the number of points
  49436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49438. * @param name defines the name of the new line system
  49439. * @param options defines the options used to create the line system
  49440. * @param scene defines the hosting scene
  49441. * @returns a new line mesh
  49442. */
  49443. static CreateLines(name: string, options: {
  49444. points: Vector3[];
  49445. updatable?: boolean;
  49446. instance?: Nullable<LinesMesh>;
  49447. colors?: Color4[];
  49448. useVertexAlpha?: boolean;
  49449. }, scene?: Nullable<Scene>): LinesMesh;
  49450. /**
  49451. * Creates a dashed line mesh
  49452. * * 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
  49453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49454. * * The parameter `points` is an array successive Vector3
  49455. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49456. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49457. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49458. * * 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
  49459. * * When updating an instance, remember that only point positions can change, not the number of points
  49460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49461. * @param name defines the name of the mesh
  49462. * @param options defines the options used to create the mesh
  49463. * @param scene defines the hosting scene
  49464. * @returns the dashed line mesh
  49465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49466. */
  49467. static CreateDashedLines(name: string, options: {
  49468. points: Vector3[];
  49469. dashSize?: number;
  49470. gapSize?: number;
  49471. dashNb?: number;
  49472. updatable?: boolean;
  49473. instance?: LinesMesh;
  49474. }, scene?: Nullable<Scene>): LinesMesh;
  49475. /**
  49476. * 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.
  49477. * * 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.
  49478. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49479. * * 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.
  49480. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49481. * * 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
  49482. * * 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
  49483. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49485. * * 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
  49486. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49488. * @param name defines the name of the mesh
  49489. * @param options defines the options used to create the mesh
  49490. * @param scene defines the hosting scene
  49491. * @returns the extruded shape mesh
  49492. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49493. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49494. */
  49495. static ExtrudeShape(name: string, options: {
  49496. shape: Vector3[];
  49497. path: Vector3[];
  49498. scale?: number;
  49499. rotation?: number;
  49500. cap?: number;
  49501. updatable?: boolean;
  49502. sideOrientation?: number;
  49503. frontUVs?: Vector4;
  49504. backUVs?: Vector4;
  49505. instance?: Mesh;
  49506. invertUV?: boolean;
  49507. }, scene?: Nullable<Scene>): Mesh;
  49508. /**
  49509. * Creates an custom extruded shape mesh.
  49510. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49511. * * 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.
  49512. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49513. * * 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
  49514. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49515. * * 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
  49516. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49517. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49518. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49519. * * 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
  49520. * * 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
  49521. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49523. * * 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
  49524. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49526. * @param name defines the name of the mesh
  49527. * @param options defines the options used to create the mesh
  49528. * @param scene defines the hosting scene
  49529. * @returns the custom extruded shape mesh
  49530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49533. */
  49534. static ExtrudeShapeCustom(name: string, options: {
  49535. shape: Vector3[];
  49536. path: Vector3[];
  49537. scaleFunction?: any;
  49538. rotationFunction?: any;
  49539. ribbonCloseArray?: boolean;
  49540. ribbonClosePath?: boolean;
  49541. cap?: number;
  49542. updatable?: boolean;
  49543. sideOrientation?: number;
  49544. frontUVs?: Vector4;
  49545. backUVs?: Vector4;
  49546. instance?: Mesh;
  49547. invertUV?: boolean;
  49548. }, scene: Scene): Mesh;
  49549. /**
  49550. * Creates lathe mesh.
  49551. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49552. * * 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
  49553. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49554. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49555. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49556. * * 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
  49557. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49558. * * 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
  49559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49560. * * 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
  49561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49563. * @param name defines the name of the mesh
  49564. * @param options defines the options used to create the mesh
  49565. * @param scene defines the hosting scene
  49566. * @returns the lathe mesh
  49567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49568. */
  49569. static CreateLathe(name: string, options: {
  49570. shape: Vector3[];
  49571. radius?: number;
  49572. tessellation?: number;
  49573. clip?: number;
  49574. arc?: number;
  49575. closed?: boolean;
  49576. updatable?: boolean;
  49577. sideOrientation?: number;
  49578. frontUVs?: Vector4;
  49579. backUVs?: Vector4;
  49580. cap?: number;
  49581. invertUV?: boolean;
  49582. }, scene: Scene): Mesh;
  49583. /**
  49584. * Creates a plane mesh
  49585. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49586. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49587. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49589. * * 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
  49590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49591. * @param name defines the name of the mesh
  49592. * @param options defines the options used to create the mesh
  49593. * @param scene defines the hosting scene
  49594. * @returns the plane mesh
  49595. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49596. */
  49597. static CreatePlane(name: string, options: {
  49598. size?: number;
  49599. width?: number;
  49600. height?: number;
  49601. sideOrientation?: number;
  49602. frontUVs?: Vector4;
  49603. backUVs?: Vector4;
  49604. updatable?: boolean;
  49605. sourcePlane?: Plane;
  49606. }, scene: Scene): Mesh;
  49607. /**
  49608. * Creates a ground mesh
  49609. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49610. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49612. * @param name defines the name of the mesh
  49613. * @param options defines the options used to create the mesh
  49614. * @param scene defines the hosting scene
  49615. * @returns the ground mesh
  49616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49617. */
  49618. static CreateGround(name: string, options: {
  49619. width?: number;
  49620. height?: number;
  49621. subdivisions?: number;
  49622. subdivisionsX?: number;
  49623. subdivisionsY?: number;
  49624. updatable?: boolean;
  49625. }, scene: any): Mesh;
  49626. /**
  49627. * Creates a tiled ground mesh
  49628. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49629. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49630. * * 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
  49631. * * 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
  49632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49633. * @param name defines the name of the mesh
  49634. * @param options defines the options used to create the mesh
  49635. * @param scene defines the hosting scene
  49636. * @returns the tiled ground mesh
  49637. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49638. */
  49639. static CreateTiledGround(name: string, options: {
  49640. xmin: number;
  49641. zmin: number;
  49642. xmax: number;
  49643. zmax: number;
  49644. subdivisions?: {
  49645. w: number;
  49646. h: number;
  49647. };
  49648. precision?: {
  49649. w: number;
  49650. h: number;
  49651. };
  49652. updatable?: boolean;
  49653. }, scene: Scene): Mesh;
  49654. /**
  49655. * Creates a ground mesh from a height map
  49656. * * The parameter `url` sets the URL of the height map image resource.
  49657. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49658. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49659. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49660. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49661. * * 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.
  49662. * * 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).
  49663. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49665. * @param name defines the name of the mesh
  49666. * @param url defines the url to the height map
  49667. * @param options defines the options used to create the mesh
  49668. * @param scene defines the hosting scene
  49669. * @returns the ground mesh
  49670. * @see https://doc.babylonjs.com/babylon101/height_map
  49671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49672. */
  49673. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49674. width?: number;
  49675. height?: number;
  49676. subdivisions?: number;
  49677. minHeight?: number;
  49678. maxHeight?: number;
  49679. colorFilter?: Color3;
  49680. alphaFilter?: number;
  49681. updatable?: boolean;
  49682. onReady?: (mesh: GroundMesh) => void;
  49683. }, scene: Scene): GroundMesh;
  49684. /**
  49685. * Creates a polygon mesh
  49686. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49687. * * 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
  49688. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49690. * * 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)
  49691. * * Remember you can only change the shape positions, not their number when updating a polygon
  49692. * @param name defines the name of the mesh
  49693. * @param options defines the options used to create the mesh
  49694. * @param scene defines the hosting scene
  49695. * @param earcutInjection can be used to inject your own earcut reference
  49696. * @returns the polygon mesh
  49697. */
  49698. static CreatePolygon(name: string, options: {
  49699. shape: Vector3[];
  49700. holes?: Vector3[][];
  49701. depth?: number;
  49702. faceUV?: Vector4[];
  49703. faceColors?: Color4[];
  49704. updatable?: boolean;
  49705. sideOrientation?: number;
  49706. frontUVs?: Vector4;
  49707. backUVs?: Vector4;
  49708. }, scene: Scene, earcutInjection?: any): Mesh;
  49709. /**
  49710. * Creates an extruded polygon mesh, with depth in the Y direction.
  49711. * * 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)
  49712. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49713. * @param name defines the name of the mesh
  49714. * @param options defines the options used to create the mesh
  49715. * @param scene defines the hosting scene
  49716. * @param earcutInjection can be used to inject your own earcut reference
  49717. * @returns the polygon mesh
  49718. */
  49719. static ExtrudePolygon(name: string, options: {
  49720. shape: Vector3[];
  49721. holes?: Vector3[][];
  49722. depth?: number;
  49723. faceUV?: Vector4[];
  49724. faceColors?: Color4[];
  49725. updatable?: boolean;
  49726. sideOrientation?: number;
  49727. frontUVs?: Vector4;
  49728. backUVs?: Vector4;
  49729. }, scene: Scene, earcutInjection?: any): Mesh;
  49730. /**
  49731. * Creates a tube mesh.
  49732. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49733. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49734. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49735. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49736. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49737. * * 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)
  49738. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49739. * * 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
  49740. * * 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
  49741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49742. * * 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
  49743. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49745. * @param name defines the name of the mesh
  49746. * @param options defines the options used to create the mesh
  49747. * @param scene defines the hosting scene
  49748. * @returns the tube mesh
  49749. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49750. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49751. */
  49752. static CreateTube(name: string, options: {
  49753. path: Vector3[];
  49754. radius?: number;
  49755. tessellation?: number;
  49756. radiusFunction?: {
  49757. (i: number, distance: number): number;
  49758. };
  49759. cap?: number;
  49760. arc?: number;
  49761. updatable?: boolean;
  49762. sideOrientation?: number;
  49763. frontUVs?: Vector4;
  49764. backUVs?: Vector4;
  49765. instance?: Mesh;
  49766. invertUV?: boolean;
  49767. }, scene: Scene): Mesh;
  49768. /**
  49769. * Creates a polyhedron mesh
  49770. * * 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
  49771. * * The parameter `size` (positive float, default 1) sets the polygon size
  49772. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49773. * * 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`
  49774. * * 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
  49775. * * 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)`)
  49776. * * 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
  49777. * * 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
  49778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49779. * * 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
  49780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49781. * @param name defines the name of the mesh
  49782. * @param options defines the options used to create the mesh
  49783. * @param scene defines the hosting scene
  49784. * @returns the polyhedron mesh
  49785. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49786. */
  49787. static CreatePolyhedron(name: string, options: {
  49788. type?: number;
  49789. size?: number;
  49790. sizeX?: number;
  49791. sizeY?: number;
  49792. sizeZ?: number;
  49793. custom?: any;
  49794. faceUV?: Vector4[];
  49795. faceColors?: Color4[];
  49796. flat?: boolean;
  49797. updatable?: boolean;
  49798. sideOrientation?: number;
  49799. frontUVs?: Vector4;
  49800. backUVs?: Vector4;
  49801. }, scene: Scene): Mesh;
  49802. /**
  49803. * Creates a decal mesh.
  49804. * 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
  49805. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49806. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49807. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49808. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49809. * @param name defines the name of the mesh
  49810. * @param sourceMesh defines the mesh where the decal must be applied
  49811. * @param options defines the options used to create the mesh
  49812. * @param scene defines the hosting scene
  49813. * @returns the decal mesh
  49814. * @see https://doc.babylonjs.com/how_to/decals
  49815. */
  49816. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49817. position?: Vector3;
  49818. normal?: Vector3;
  49819. size?: Vector3;
  49820. angle?: number;
  49821. }): Mesh;
  49822. }
  49823. }
  49824. declare module BABYLON {
  49825. /**
  49826. * A simplifier interface for future simplification implementations
  49827. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49828. */
  49829. export interface ISimplifier {
  49830. /**
  49831. * Simplification of a given mesh according to the given settings.
  49832. * Since this requires computation, it is assumed that the function runs async.
  49833. * @param settings The settings of the simplification, including quality and distance
  49834. * @param successCallback A callback that will be called after the mesh was simplified.
  49835. * @param errorCallback in case of an error, this callback will be called. optional.
  49836. */
  49837. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49838. }
  49839. /**
  49840. * Expected simplification settings.
  49841. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49843. */
  49844. export interface ISimplificationSettings {
  49845. /**
  49846. * Gets or sets the expected quality
  49847. */
  49848. quality: number;
  49849. /**
  49850. * Gets or sets the distance when this optimized version should be used
  49851. */
  49852. distance: number;
  49853. /**
  49854. * Gets an already optimized mesh
  49855. */
  49856. optimizeMesh?: boolean;
  49857. }
  49858. /**
  49859. * Class used to specify simplification options
  49860. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49861. */
  49862. export class SimplificationSettings implements ISimplificationSettings {
  49863. /** expected quality */
  49864. quality: number;
  49865. /** distance when this optimized version should be used */
  49866. distance: number;
  49867. /** already optimized mesh */
  49868. optimizeMesh?: boolean | undefined;
  49869. /**
  49870. * Creates a SimplificationSettings
  49871. * @param quality expected quality
  49872. * @param distance distance when this optimized version should be used
  49873. * @param optimizeMesh already optimized mesh
  49874. */
  49875. constructor(
  49876. /** expected quality */
  49877. quality: number,
  49878. /** distance when this optimized version should be used */
  49879. distance: number,
  49880. /** already optimized mesh */
  49881. optimizeMesh?: boolean | undefined);
  49882. }
  49883. /**
  49884. * Interface used to define a simplification task
  49885. */
  49886. export interface ISimplificationTask {
  49887. /**
  49888. * Array of settings
  49889. */
  49890. settings: Array<ISimplificationSettings>;
  49891. /**
  49892. * Simplification type
  49893. */
  49894. simplificationType: SimplificationType;
  49895. /**
  49896. * Mesh to simplify
  49897. */
  49898. mesh: Mesh;
  49899. /**
  49900. * Callback called on success
  49901. */
  49902. successCallback?: () => void;
  49903. /**
  49904. * Defines if parallel processing can be used
  49905. */
  49906. parallelProcessing: boolean;
  49907. }
  49908. /**
  49909. * Queue used to order the simplification tasks
  49910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49911. */
  49912. export class SimplificationQueue {
  49913. private _simplificationArray;
  49914. /**
  49915. * Gets a boolean indicating that the process is still running
  49916. */
  49917. running: boolean;
  49918. /**
  49919. * Creates a new queue
  49920. */
  49921. constructor();
  49922. /**
  49923. * Adds a new simplification task
  49924. * @param task defines a task to add
  49925. */
  49926. addTask(task: ISimplificationTask): void;
  49927. /**
  49928. * Execute next task
  49929. */
  49930. executeNext(): void;
  49931. /**
  49932. * Execute a simplification task
  49933. * @param task defines the task to run
  49934. */
  49935. runSimplification(task: ISimplificationTask): void;
  49936. private getSimplifier;
  49937. }
  49938. /**
  49939. * The implemented types of simplification
  49940. * At the moment only Quadratic Error Decimation is implemented
  49941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49942. */
  49943. export enum SimplificationType {
  49944. /** Quadratic error decimation */
  49945. QUADRATIC = 0
  49946. }
  49947. }
  49948. declare module BABYLON {
  49949. interface Scene {
  49950. /** @hidden (Backing field) */
  49951. _simplificationQueue: SimplificationQueue;
  49952. /**
  49953. * Gets or sets the simplification queue attached to the scene
  49954. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49955. */
  49956. simplificationQueue: SimplificationQueue;
  49957. }
  49958. interface Mesh {
  49959. /**
  49960. * Simplify the mesh according to the given array of settings.
  49961. * Function will return immediately and will simplify async
  49962. * @param settings a collection of simplification settings
  49963. * @param parallelProcessing should all levels calculate parallel or one after the other
  49964. * @param simplificationType the type of simplification to run
  49965. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49966. * @returns the current mesh
  49967. */
  49968. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49969. }
  49970. /**
  49971. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49972. * created in a scene
  49973. */
  49974. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49975. /**
  49976. * The component name helpfull to identify the component in the list of scene components.
  49977. */
  49978. readonly name: string;
  49979. /**
  49980. * The scene the component belongs to.
  49981. */
  49982. scene: Scene;
  49983. /**
  49984. * Creates a new instance of the component for the given scene
  49985. * @param scene Defines the scene to register the component in
  49986. */
  49987. constructor(scene: Scene);
  49988. /**
  49989. * Registers the component in a given scene
  49990. */
  49991. register(): void;
  49992. /**
  49993. * Rebuilds the elements related to this component in case of
  49994. * context lost for instance.
  49995. */
  49996. rebuild(): void;
  49997. /**
  49998. * Disposes the component and the associated ressources
  49999. */
  50000. dispose(): void;
  50001. private _beforeCameraUpdate;
  50002. }
  50003. }
  50004. declare module BABYLON {
  50005. /**
  50006. * Class used to enable access to IndexedDB
  50007. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50008. */
  50009. export class Database implements IOfflineProvider {
  50010. private _callbackManifestChecked;
  50011. private _currentSceneUrl;
  50012. private _db;
  50013. private _enableSceneOffline;
  50014. private _enableTexturesOffline;
  50015. private _manifestVersionFound;
  50016. private _mustUpdateRessources;
  50017. private _hasReachedQuota;
  50018. private _isSupported;
  50019. private _idbFactory;
  50020. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50021. private static IsUASupportingBlobStorage;
  50022. /**
  50023. * Gets a boolean indicating if Database storate is enabled (off by default)
  50024. */
  50025. static IDBStorageEnabled: boolean;
  50026. /**
  50027. * Gets a boolean indicating if scene must be saved in the database
  50028. */
  50029. readonly enableSceneOffline: boolean;
  50030. /**
  50031. * Gets a boolean indicating if textures must be saved in the database
  50032. */
  50033. readonly enableTexturesOffline: boolean;
  50034. /**
  50035. * Creates a new Database
  50036. * @param urlToScene defines the url to load the scene
  50037. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50038. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50039. */
  50040. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50041. private static _ParseURL;
  50042. private static _ReturnFullUrlLocation;
  50043. private _checkManifestFile;
  50044. /**
  50045. * Open the database and make it available
  50046. * @param successCallback defines the callback to call on success
  50047. * @param errorCallback defines the callback to call on error
  50048. */
  50049. open(successCallback: () => void, errorCallback: () => void): void;
  50050. /**
  50051. * Loads an image from the database
  50052. * @param url defines the url to load from
  50053. * @param image defines the target DOM image
  50054. */
  50055. loadImage(url: string, image: HTMLImageElement): void;
  50056. private _loadImageFromDBAsync;
  50057. private _saveImageIntoDBAsync;
  50058. private _checkVersionFromDB;
  50059. private _loadVersionFromDBAsync;
  50060. private _saveVersionIntoDBAsync;
  50061. /**
  50062. * Loads a file from database
  50063. * @param url defines the URL to load from
  50064. * @param sceneLoaded defines a callback to call on success
  50065. * @param progressCallBack defines a callback to call when progress changed
  50066. * @param errorCallback defines a callback to call on error
  50067. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50068. */
  50069. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50070. private _loadFileAsync;
  50071. private _saveFileAsync;
  50072. /**
  50073. * Validates if xhr data is correct
  50074. * @param xhr defines the request to validate
  50075. * @param dataType defines the expected data type
  50076. * @returns true if data is correct
  50077. */
  50078. private static _ValidateXHRData;
  50079. }
  50080. }
  50081. declare module BABYLON {
  50082. /** @hidden */
  50083. export var gpuUpdateParticlesPixelShader: {
  50084. name: string;
  50085. shader: string;
  50086. };
  50087. }
  50088. declare module BABYLON {
  50089. /** @hidden */
  50090. export var gpuUpdateParticlesVertexShader: {
  50091. name: string;
  50092. shader: string;
  50093. };
  50094. }
  50095. declare module BABYLON {
  50096. /** @hidden */
  50097. export var clipPlaneFragmentDeclaration2: {
  50098. name: string;
  50099. shader: string;
  50100. };
  50101. }
  50102. declare module BABYLON {
  50103. /** @hidden */
  50104. export var gpuRenderParticlesPixelShader: {
  50105. name: string;
  50106. shader: string;
  50107. };
  50108. }
  50109. declare module BABYLON {
  50110. /** @hidden */
  50111. export var clipPlaneVertexDeclaration2: {
  50112. name: string;
  50113. shader: string;
  50114. };
  50115. }
  50116. declare module BABYLON {
  50117. /** @hidden */
  50118. export var gpuRenderParticlesVertexShader: {
  50119. name: string;
  50120. shader: string;
  50121. };
  50122. }
  50123. declare module BABYLON {
  50124. /**
  50125. * This represents a GPU particle system in Babylon
  50126. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50127. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50128. */
  50129. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50130. /**
  50131. * The layer mask we are rendering the particles through.
  50132. */
  50133. layerMask: number;
  50134. private _capacity;
  50135. private _activeCount;
  50136. private _currentActiveCount;
  50137. private _accumulatedCount;
  50138. private _renderEffect;
  50139. private _updateEffect;
  50140. private _buffer0;
  50141. private _buffer1;
  50142. private _spriteBuffer;
  50143. private _updateVAO;
  50144. private _renderVAO;
  50145. private _targetIndex;
  50146. private _sourceBuffer;
  50147. private _targetBuffer;
  50148. private _engine;
  50149. private _currentRenderId;
  50150. private _started;
  50151. private _stopped;
  50152. private _timeDelta;
  50153. private _randomTexture;
  50154. private _randomTexture2;
  50155. private _attributesStrideSize;
  50156. private _updateEffectOptions;
  50157. private _randomTextureSize;
  50158. private _actualFrame;
  50159. private readonly _rawTextureWidth;
  50160. /**
  50161. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50162. */
  50163. static readonly IsSupported: boolean;
  50164. /**
  50165. * An event triggered when the system is disposed.
  50166. */
  50167. onDisposeObservable: Observable<GPUParticleSystem>;
  50168. /**
  50169. * Gets the maximum number of particles active at the same time.
  50170. * @returns The max number of active particles.
  50171. */
  50172. getCapacity(): number;
  50173. /**
  50174. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50175. * to override the particles.
  50176. */
  50177. forceDepthWrite: boolean;
  50178. /**
  50179. * Gets or set the number of active particles
  50180. */
  50181. activeParticleCount: number;
  50182. private _preWarmDone;
  50183. /**
  50184. * Is this system ready to be used/rendered
  50185. * @return true if the system is ready
  50186. */
  50187. isReady(): boolean;
  50188. /**
  50189. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50190. * @returns True if it has been started, otherwise false.
  50191. */
  50192. isStarted(): boolean;
  50193. /**
  50194. * Starts the particle system and begins to emit
  50195. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50196. */
  50197. start(delay?: number): void;
  50198. /**
  50199. * Stops the particle system.
  50200. */
  50201. stop(): void;
  50202. /**
  50203. * Remove all active particles
  50204. */
  50205. reset(): void;
  50206. /**
  50207. * Returns the string "GPUParticleSystem"
  50208. * @returns a string containing the class name
  50209. */
  50210. getClassName(): string;
  50211. private _colorGradientsTexture;
  50212. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50213. /**
  50214. * Adds a new color gradient
  50215. * @param gradient defines the gradient to use (between 0 and 1)
  50216. * @param color1 defines the color to affect to the specified gradient
  50217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50218. * @returns the current particle system
  50219. */
  50220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50221. /**
  50222. * Remove a specific color gradient
  50223. * @param gradient defines the gradient to remove
  50224. * @returns the current particle system
  50225. */
  50226. removeColorGradient(gradient: number): GPUParticleSystem;
  50227. private _angularSpeedGradientsTexture;
  50228. private _sizeGradientsTexture;
  50229. private _velocityGradientsTexture;
  50230. private _limitVelocityGradientsTexture;
  50231. private _dragGradientsTexture;
  50232. private _addFactorGradient;
  50233. /**
  50234. * Adds a new size gradient
  50235. * @param gradient defines the gradient to use (between 0 and 1)
  50236. * @param factor defines the size factor to affect to the specified gradient
  50237. * @returns the current particle system
  50238. */
  50239. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50240. /**
  50241. * Remove a specific size gradient
  50242. * @param gradient defines the gradient to remove
  50243. * @returns the current particle system
  50244. */
  50245. removeSizeGradient(gradient: number): GPUParticleSystem;
  50246. /**
  50247. * Adds a new angular speed gradient
  50248. * @param gradient defines the gradient to use (between 0 and 1)
  50249. * @param factor defines the angular speed to affect to the specified gradient
  50250. * @returns the current particle system
  50251. */
  50252. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50253. /**
  50254. * Remove a specific angular speed gradient
  50255. * @param gradient defines the gradient to remove
  50256. * @returns the current particle system
  50257. */
  50258. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50259. /**
  50260. * Adds a new velocity gradient
  50261. * @param gradient defines the gradient to use (between 0 and 1)
  50262. * @param factor defines the velocity to affect to the specified gradient
  50263. * @returns the current particle system
  50264. */
  50265. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50266. /**
  50267. * Remove a specific velocity gradient
  50268. * @param gradient defines the gradient to remove
  50269. * @returns the current particle system
  50270. */
  50271. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50272. /**
  50273. * Adds a new limit velocity gradient
  50274. * @param gradient defines the gradient to use (between 0 and 1)
  50275. * @param factor defines the limit velocity value to affect to the specified gradient
  50276. * @returns the current particle system
  50277. */
  50278. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50279. /**
  50280. * Remove a specific limit velocity gradient
  50281. * @param gradient defines the gradient to remove
  50282. * @returns the current particle system
  50283. */
  50284. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50285. /**
  50286. * Adds a new drag gradient
  50287. * @param gradient defines the gradient to use (between 0 and 1)
  50288. * @param factor defines the drag value to affect to the specified gradient
  50289. * @returns the current particle system
  50290. */
  50291. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50292. /**
  50293. * Remove a specific drag gradient
  50294. * @param gradient defines the gradient to remove
  50295. * @returns the current particle system
  50296. */
  50297. removeDragGradient(gradient: number): GPUParticleSystem;
  50298. /**
  50299. * Not supported by GPUParticleSystem
  50300. * @param gradient defines the gradient to use (between 0 and 1)
  50301. * @param factor defines the emit rate value to affect to the specified gradient
  50302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50303. * @returns the current particle system
  50304. */
  50305. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50306. /**
  50307. * Not supported by GPUParticleSystem
  50308. * @param gradient defines the gradient to remove
  50309. * @returns the current particle system
  50310. */
  50311. removeEmitRateGradient(gradient: number): IParticleSystem;
  50312. /**
  50313. * Not supported by GPUParticleSystem
  50314. * @param gradient defines the gradient to use (between 0 and 1)
  50315. * @param factor defines the start size value to affect to the specified gradient
  50316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50317. * @returns the current particle system
  50318. */
  50319. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50320. /**
  50321. * Not supported by GPUParticleSystem
  50322. * @param gradient defines the gradient to remove
  50323. * @returns the current particle system
  50324. */
  50325. removeStartSizeGradient(gradient: number): IParticleSystem;
  50326. /**
  50327. * Not supported by GPUParticleSystem
  50328. * @param gradient defines the gradient to use (between 0 and 1)
  50329. * @param min defines the color remap minimal range
  50330. * @param max defines the color remap maximal range
  50331. * @returns the current particle system
  50332. */
  50333. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50334. /**
  50335. * Not supported by GPUParticleSystem
  50336. * @param gradient defines the gradient to remove
  50337. * @returns the current particle system
  50338. */
  50339. removeColorRemapGradient(): IParticleSystem;
  50340. /**
  50341. * Not supported by GPUParticleSystem
  50342. * @param gradient defines the gradient to use (between 0 and 1)
  50343. * @param min defines the alpha remap minimal range
  50344. * @param max defines the alpha remap maximal range
  50345. * @returns the current particle system
  50346. */
  50347. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50348. /**
  50349. * Not supported by GPUParticleSystem
  50350. * @param gradient defines the gradient to remove
  50351. * @returns the current particle system
  50352. */
  50353. removeAlphaRemapGradient(): IParticleSystem;
  50354. /**
  50355. * Not supported by GPUParticleSystem
  50356. * @param gradient defines the gradient to use (between 0 and 1)
  50357. * @param color defines the color to affect to the specified gradient
  50358. * @returns the current particle system
  50359. */
  50360. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50361. /**
  50362. * Not supported by GPUParticleSystem
  50363. * @param gradient defines the gradient to remove
  50364. * @returns the current particle system
  50365. */
  50366. removeRampGradient(): IParticleSystem;
  50367. /**
  50368. * Not supported by GPUParticleSystem
  50369. * @returns the list of ramp gradients
  50370. */
  50371. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50372. /**
  50373. * Not supported by GPUParticleSystem
  50374. * Gets or sets a boolean indicating that ramp gradients must be used
  50375. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50376. */
  50377. useRampGradients: boolean;
  50378. /**
  50379. * Not supported by GPUParticleSystem
  50380. * @param gradient defines the gradient to use (between 0 and 1)
  50381. * @param factor defines the life time factor to affect to the specified gradient
  50382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50383. * @returns the current particle system
  50384. */
  50385. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50386. /**
  50387. * Not supported by GPUParticleSystem
  50388. * @param gradient defines the gradient to remove
  50389. * @returns the current particle system
  50390. */
  50391. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50392. /**
  50393. * Instantiates a GPU particle system.
  50394. * 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.
  50395. * @param name The name of the particle system
  50396. * @param options The options used to create the system
  50397. * @param scene The scene the particle system belongs to
  50398. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50399. */
  50400. constructor(name: string, options: Partial<{
  50401. capacity: number;
  50402. randomTextureSize: number;
  50403. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50404. protected _reset(): void;
  50405. private _createUpdateVAO;
  50406. private _createRenderVAO;
  50407. private _initialize;
  50408. /** @hidden */
  50409. _recreateUpdateEffect(): void;
  50410. /** @hidden */
  50411. _recreateRenderEffect(): void;
  50412. /**
  50413. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50414. * @param preWarm defines if we are in the pre-warmimg phase
  50415. */
  50416. animate(preWarm?: boolean): void;
  50417. private _createFactorGradientTexture;
  50418. private _createSizeGradientTexture;
  50419. private _createAngularSpeedGradientTexture;
  50420. private _createVelocityGradientTexture;
  50421. private _createLimitVelocityGradientTexture;
  50422. private _createDragGradientTexture;
  50423. private _createColorGradientTexture;
  50424. /**
  50425. * Renders the particle system in its current state
  50426. * @param preWarm defines if the system should only update the particles but not render them
  50427. * @returns the current number of particles
  50428. */
  50429. render(preWarm?: boolean): number;
  50430. /**
  50431. * Rebuilds the particle system
  50432. */
  50433. rebuild(): void;
  50434. private _releaseBuffers;
  50435. private _releaseVAOs;
  50436. /**
  50437. * Disposes the particle system and free the associated resources
  50438. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50439. */
  50440. dispose(disposeTexture?: boolean): void;
  50441. /**
  50442. * Clones the particle system.
  50443. * @param name The name of the cloned object
  50444. * @param newEmitter The new emitter to use
  50445. * @returns the cloned particle system
  50446. */
  50447. clone(name: string, newEmitter: any): GPUParticleSystem;
  50448. /**
  50449. * Serializes the particle system to a JSON object.
  50450. * @returns the JSON object
  50451. */
  50452. serialize(): any;
  50453. /**
  50454. * Parses a JSON object to create a GPU particle system.
  50455. * @param parsedParticleSystem The JSON object to parse
  50456. * @param scene The scene to create the particle system in
  50457. * @param rootUrl The root url to use to load external dependencies like texture
  50458. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50459. * @returns the parsed GPU particle system
  50460. */
  50461. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50462. }
  50463. }
  50464. declare module BABYLON {
  50465. /**
  50466. * Represents a set of particle systems working together to create a specific effect
  50467. */
  50468. export class ParticleSystemSet implements IDisposable {
  50469. private _emitterCreationOptions;
  50470. private _emitterNode;
  50471. /**
  50472. * Gets the particle system list
  50473. */
  50474. systems: IParticleSystem[];
  50475. /**
  50476. * Gets the emitter node used with this set
  50477. */
  50478. readonly emitterNode: Nullable<TransformNode>;
  50479. /**
  50480. * Creates a new emitter mesh as a sphere
  50481. * @param options defines the options used to create the sphere
  50482. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50483. * @param scene defines the hosting scene
  50484. */
  50485. setEmitterAsSphere(options: {
  50486. diameter: number;
  50487. segments: number;
  50488. color: Color3;
  50489. }, renderingGroupId: number, scene: Scene): void;
  50490. /**
  50491. * Starts all particle systems of the set
  50492. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50493. */
  50494. start(emitter?: AbstractMesh): void;
  50495. /**
  50496. * Release all associated resources
  50497. */
  50498. dispose(): void;
  50499. /**
  50500. * Serialize the set into a JSON compatible object
  50501. * @returns a JSON compatible representation of the set
  50502. */
  50503. serialize(): any;
  50504. /**
  50505. * Parse a new ParticleSystemSet from a serialized source
  50506. * @param data defines a JSON compatible representation of the set
  50507. * @param scene defines the hosting scene
  50508. * @param gpu defines if we want GPU particles or CPU particles
  50509. * @returns a new ParticleSystemSet
  50510. */
  50511. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50512. }
  50513. }
  50514. declare module BABYLON {
  50515. /**
  50516. * This class is made for on one-liner static method to help creating particle system set.
  50517. */
  50518. export class ParticleHelper {
  50519. /**
  50520. * Gets or sets base Assets URL
  50521. */
  50522. static BaseAssetsUrl: string;
  50523. /**
  50524. * Create a default particle system that you can tweak
  50525. * @param emitter defines the emitter to use
  50526. * @param capacity defines the system capacity (default is 500 particles)
  50527. * @param scene defines the hosting scene
  50528. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50529. * @returns the new Particle system
  50530. */
  50531. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50532. /**
  50533. * This is the main static method (one-liner) of this helper to create different particle systems
  50534. * @param type This string represents the type to the particle system to create
  50535. * @param scene The scene where the particle system should live
  50536. * @param gpu If the system will use gpu
  50537. * @returns the ParticleSystemSet created
  50538. */
  50539. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50540. /**
  50541. * Static function used to export a particle system to a ParticleSystemSet variable.
  50542. * Please note that the emitter shape is not exported
  50543. * @param systems defines the particle systems to export
  50544. * @returns the created particle system set
  50545. */
  50546. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50547. }
  50548. }
  50549. declare module BABYLON {
  50550. interface Engine {
  50551. /**
  50552. * Create an effect to use with particle systems.
  50553. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50554. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50555. * @param uniformsNames defines a list of attribute names
  50556. * @param samplers defines an array of string used to represent textures
  50557. * @param defines defines the string containing the defines to use to compile the shaders
  50558. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50559. * @param onCompiled defines a function to call when the effect creation is successful
  50560. * @param onError defines a function to call when the effect creation has failed
  50561. * @returns the new Effect
  50562. */
  50563. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50564. }
  50565. interface Mesh {
  50566. /**
  50567. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50568. * @returns an array of IParticleSystem
  50569. */
  50570. getEmittedParticleSystems(): IParticleSystem[];
  50571. /**
  50572. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50573. * @returns an array of IParticleSystem
  50574. */
  50575. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50576. }
  50577. /**
  50578. * @hidden
  50579. */
  50580. export var _IDoNeedToBeInTheBuild: number;
  50581. }
  50582. declare module BABYLON {
  50583. interface Scene {
  50584. /** @hidden (Backing field) */
  50585. _physicsEngine: Nullable<IPhysicsEngine>;
  50586. /**
  50587. * Gets the current physics engine
  50588. * @returns a IPhysicsEngine or null if none attached
  50589. */
  50590. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50591. /**
  50592. * Enables physics to the current scene
  50593. * @param gravity defines the scene's gravity for the physics engine
  50594. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50595. * @return a boolean indicating if the physics engine was initialized
  50596. */
  50597. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50598. /**
  50599. * Disables and disposes the physics engine associated with the scene
  50600. */
  50601. disablePhysicsEngine(): void;
  50602. /**
  50603. * Gets a boolean indicating if there is an active physics engine
  50604. * @returns a boolean indicating if there is an active physics engine
  50605. */
  50606. isPhysicsEnabled(): boolean;
  50607. /**
  50608. * Deletes a physics compound impostor
  50609. * @param compound defines the compound to delete
  50610. */
  50611. deleteCompoundImpostor(compound: any): void;
  50612. /**
  50613. * An event triggered when physic simulation is about to be run
  50614. */
  50615. onBeforePhysicsObservable: Observable<Scene>;
  50616. /**
  50617. * An event triggered when physic simulation has been done
  50618. */
  50619. onAfterPhysicsObservable: Observable<Scene>;
  50620. }
  50621. interface AbstractMesh {
  50622. /** @hidden */
  50623. _physicsImpostor: Nullable<PhysicsImpostor>;
  50624. /**
  50625. * Gets or sets impostor used for physic simulation
  50626. * @see http://doc.babylonjs.com/features/physics_engine
  50627. */
  50628. physicsImpostor: Nullable<PhysicsImpostor>;
  50629. /**
  50630. * Gets the current physics impostor
  50631. * @see http://doc.babylonjs.com/features/physics_engine
  50632. * @returns a physics impostor or null
  50633. */
  50634. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50635. /** Apply a physic impulse to the mesh
  50636. * @param force defines the force to apply
  50637. * @param contactPoint defines where to apply the force
  50638. * @returns the current mesh
  50639. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50640. */
  50641. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50642. /**
  50643. * Creates a physic joint between two meshes
  50644. * @param otherMesh defines the other mesh to use
  50645. * @param pivot1 defines the pivot to use on this mesh
  50646. * @param pivot2 defines the pivot to use on the other mesh
  50647. * @param options defines additional options (can be plugin dependent)
  50648. * @returns the current mesh
  50649. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50650. */
  50651. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50652. /** @hidden */
  50653. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50654. }
  50655. /**
  50656. * Defines the physics engine scene component responsible to manage a physics engine
  50657. */
  50658. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50659. /**
  50660. * The component name helpful to identify the component in the list of scene components.
  50661. */
  50662. readonly name: string;
  50663. /**
  50664. * The scene the component belongs to.
  50665. */
  50666. scene: Scene;
  50667. /**
  50668. * Creates a new instance of the component for the given scene
  50669. * @param scene Defines the scene to register the component in
  50670. */
  50671. constructor(scene: Scene);
  50672. /**
  50673. * Registers the component in a given scene
  50674. */
  50675. register(): void;
  50676. /**
  50677. * Rebuilds the elements related to this component in case of
  50678. * context lost for instance.
  50679. */
  50680. rebuild(): void;
  50681. /**
  50682. * Disposes the component and the associated ressources
  50683. */
  50684. dispose(): void;
  50685. }
  50686. }
  50687. declare module BABYLON {
  50688. /**
  50689. * A helper for physics simulations
  50690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50691. */
  50692. export class PhysicsHelper {
  50693. private _scene;
  50694. private _physicsEngine;
  50695. /**
  50696. * Initializes the Physics helper
  50697. * @param scene Babylon.js scene
  50698. */
  50699. constructor(scene: Scene);
  50700. /**
  50701. * Applies a radial explosion impulse
  50702. * @param origin the origin of the explosion
  50703. * @param radiusOrEventOptions the radius or the options of radial explosion
  50704. * @param strength the explosion strength
  50705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50706. * @returns A physics radial explosion event, or null
  50707. */
  50708. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50709. /**
  50710. * Applies a radial explosion force
  50711. * @param origin the origin of the explosion
  50712. * @param radiusOrEventOptions the radius or the options of radial explosion
  50713. * @param strength the explosion strength
  50714. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50715. * @returns A physics radial explosion event, or null
  50716. */
  50717. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50718. /**
  50719. * Creates a gravitational field
  50720. * @param origin the origin of the explosion
  50721. * @param radiusOrEventOptions the radius or the options of radial explosion
  50722. * @param strength the explosion strength
  50723. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50724. * @returns A physics gravitational field event, or null
  50725. */
  50726. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50727. /**
  50728. * Creates a physics updraft event
  50729. * @param origin the origin of the updraft
  50730. * @param radiusOrEventOptions the radius or the options of the updraft
  50731. * @param strength the strength of the updraft
  50732. * @param height the height of the updraft
  50733. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50734. * @returns A physics updraft event, or null
  50735. */
  50736. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50737. /**
  50738. * Creates a physics vortex event
  50739. * @param origin the of the vortex
  50740. * @param radiusOrEventOptions the radius or the options of the vortex
  50741. * @param strength the strength of the vortex
  50742. * @param height the height of the vortex
  50743. * @returns a Physics vortex event, or null
  50744. * A physics vortex event or null
  50745. */
  50746. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50747. }
  50748. /**
  50749. * Represents a physics radial explosion event
  50750. */
  50751. class PhysicsRadialExplosionEvent {
  50752. private _scene;
  50753. private _options;
  50754. private _sphere;
  50755. private _dataFetched;
  50756. /**
  50757. * Initializes a radial explosioin event
  50758. * @param _scene BabylonJS scene
  50759. * @param _options The options for the vortex event
  50760. */
  50761. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50762. /**
  50763. * Returns the data related to the radial explosion event (sphere).
  50764. * @returns The radial explosion event data
  50765. */
  50766. getData(): PhysicsRadialExplosionEventData;
  50767. /**
  50768. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50769. * @param impostor A physics imposter
  50770. * @param origin the origin of the explosion
  50771. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50772. */
  50773. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  50774. /**
  50775. * Disposes the sphere.
  50776. * @param force Specifies if the sphere should be disposed by force
  50777. */
  50778. dispose(force?: boolean): void;
  50779. /*** Helpers ***/
  50780. private _prepareSphere;
  50781. private _intersectsWithSphere;
  50782. }
  50783. /**
  50784. * Represents a gravitational field event
  50785. */
  50786. class PhysicsGravitationalFieldEvent {
  50787. private _physicsHelper;
  50788. private _scene;
  50789. private _origin;
  50790. private _options;
  50791. private _tickCallback;
  50792. private _sphere;
  50793. private _dataFetched;
  50794. /**
  50795. * Initializes the physics gravitational field event
  50796. * @param _physicsHelper A physics helper
  50797. * @param _scene BabylonJS scene
  50798. * @param _origin The origin position of the gravitational field event
  50799. * @param _options The options for the vortex event
  50800. */
  50801. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50802. /**
  50803. * Returns the data related to the gravitational field event (sphere).
  50804. * @returns A gravitational field event
  50805. */
  50806. getData(): PhysicsGravitationalFieldEventData;
  50807. /**
  50808. * Enables the gravitational field.
  50809. */
  50810. enable(): void;
  50811. /**
  50812. * Disables the gravitational field.
  50813. */
  50814. disable(): void;
  50815. /**
  50816. * Disposes the sphere.
  50817. * @param force The force to dispose from the gravitational field event
  50818. */
  50819. dispose(force?: boolean): void;
  50820. private _tick;
  50821. }
  50822. /**
  50823. * Represents a physics updraft event
  50824. */
  50825. class PhysicsUpdraftEvent {
  50826. private _scene;
  50827. private _origin;
  50828. private _options;
  50829. private _physicsEngine;
  50830. private _originTop;
  50831. private _originDirection;
  50832. private _tickCallback;
  50833. private _cylinder;
  50834. private _cylinderPosition;
  50835. private _dataFetched;
  50836. /**
  50837. * Initializes the physics updraft event
  50838. * @param _scene BabylonJS scene
  50839. * @param _origin The origin position of the updraft
  50840. * @param _options The options for the updraft event
  50841. */
  50842. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50843. /**
  50844. * Returns the data related to the updraft event (cylinder).
  50845. * @returns A physics updraft event
  50846. */
  50847. getData(): PhysicsUpdraftEventData;
  50848. /**
  50849. * Enables the updraft.
  50850. */
  50851. enable(): void;
  50852. /**
  50853. * Disables the updraft.
  50854. */
  50855. disable(): void;
  50856. /**
  50857. * Disposes the cylinder.
  50858. * @param force Specifies if the updraft should be disposed by force
  50859. */
  50860. dispose(force?: boolean): void;
  50861. private getImpostorForceAndContactPoint;
  50862. private _tick;
  50863. /*** Helpers ***/
  50864. private _prepareCylinder;
  50865. private _intersectsWithCylinder;
  50866. }
  50867. /**
  50868. * Represents a physics vortex event
  50869. */
  50870. class PhysicsVortexEvent {
  50871. private _scene;
  50872. private _origin;
  50873. private _options;
  50874. private _physicsEngine;
  50875. private _originTop;
  50876. private _tickCallback;
  50877. private _cylinder;
  50878. private _cylinderPosition;
  50879. private _dataFetched;
  50880. /**
  50881. * Initializes the physics vortex event
  50882. * @param _scene The BabylonJS scene
  50883. * @param _origin The origin position of the vortex
  50884. * @param _options The options for the vortex event
  50885. */
  50886. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50887. /**
  50888. * Returns the data related to the vortex event (cylinder).
  50889. * @returns The physics vortex event data
  50890. */
  50891. getData(): PhysicsVortexEventData;
  50892. /**
  50893. * Enables the vortex.
  50894. */
  50895. enable(): void;
  50896. /**
  50897. * Disables the cortex.
  50898. */
  50899. disable(): void;
  50900. /**
  50901. * Disposes the sphere.
  50902. * @param force
  50903. */
  50904. dispose(force?: boolean): void;
  50905. private getImpostorForceAndContactPoint;
  50906. private _tick;
  50907. /*** Helpers ***/
  50908. private _prepareCylinder;
  50909. private _intersectsWithCylinder;
  50910. }
  50911. /**
  50912. * Options fot the radial explosion event
  50913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50914. */
  50915. export class PhysicsRadialExplosionEventOptions {
  50916. /**
  50917. * The radius of the sphere for the radial explosion.
  50918. */
  50919. radius: number;
  50920. /**
  50921. * The strenth of the explosion.
  50922. */
  50923. strength: number;
  50924. /**
  50925. * The strenght of the force in correspondence to the distance of the affected object
  50926. */
  50927. falloff: PhysicsRadialImpulseFalloff;
  50928. /**
  50929. * Sphere options for the radial explosion.
  50930. */
  50931. sphere: {
  50932. segments: number;
  50933. diameter: number;
  50934. };
  50935. }
  50936. /**
  50937. * Options fot the updraft event
  50938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50939. */
  50940. export class PhysicsUpdraftEventOptions {
  50941. /**
  50942. * The radius of the cylinder for the vortex
  50943. */
  50944. radius: number;
  50945. /**
  50946. * The strenth of the updraft.
  50947. */
  50948. strength: number;
  50949. /**
  50950. * The height of the cylinder for the updraft.
  50951. */
  50952. height: number;
  50953. /**
  50954. * The mode for the the updraft.
  50955. */
  50956. updraftMode: PhysicsUpdraftMode;
  50957. }
  50958. /**
  50959. * Options fot the vortex event
  50960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50961. */
  50962. export class PhysicsVortexEventOptions {
  50963. /**
  50964. * The radius of the cylinder for the vortex
  50965. */
  50966. radius: number;
  50967. /**
  50968. * The strenth of the vortex.
  50969. */
  50970. strength: number;
  50971. /**
  50972. * The height of the cylinder for the vortex.
  50973. */
  50974. height: number;
  50975. /**
  50976. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  50977. */
  50978. centripetalForceThreshold: number;
  50979. /**
  50980. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  50981. */
  50982. centripetalForceMultiplier: number;
  50983. /**
  50984. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  50985. */
  50986. centrifugalForceMultiplier: number;
  50987. /**
  50988. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  50989. */
  50990. updraftForceMultiplier: number;
  50991. }
  50992. /**
  50993. * The strenght of the force in correspondence to the distance of the affected object
  50994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50995. */
  50996. export enum PhysicsRadialImpulseFalloff {
  50997. /** Defines that impulse is constant in strength across it's whole radius */
  50998. Constant = 0,
  50999. /** Defines that impulse gets weaker if it's further from the origin */
  51000. Linear = 1
  51001. }
  51002. /**
  51003. * The strength of the force in correspondence to the distance of the affected object
  51004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51005. */
  51006. export enum PhysicsUpdraftMode {
  51007. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51008. Center = 0,
  51009. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51010. Perpendicular = 1
  51011. }
  51012. /**
  51013. * Interface for a physics force and contact point
  51014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51015. */
  51016. export interface PhysicsForceAndContactPoint {
  51017. /**
  51018. * The force applied at the contact point
  51019. */
  51020. force: Vector3;
  51021. /**
  51022. * The contact point
  51023. */
  51024. contactPoint: Vector3;
  51025. }
  51026. /**
  51027. * Interface for radial explosion event data
  51028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51029. */
  51030. export interface PhysicsRadialExplosionEventData {
  51031. /**
  51032. * A sphere used for the radial explosion event
  51033. */
  51034. sphere: Mesh;
  51035. }
  51036. /**
  51037. * Interface for gravitational field event data
  51038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51039. */
  51040. export interface PhysicsGravitationalFieldEventData {
  51041. /**
  51042. * A sphere mesh used for the gravitational field event
  51043. */
  51044. sphere: Mesh;
  51045. }
  51046. /**
  51047. * Interface for updraft event data
  51048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51049. */
  51050. export interface PhysicsUpdraftEventData {
  51051. /**
  51052. * A cylinder used for the updraft event
  51053. */
  51054. cylinder: Mesh;
  51055. }
  51056. /**
  51057. * Interface for vortex event data
  51058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51059. */
  51060. export interface PhysicsVortexEventData {
  51061. /**
  51062. * A cylinder used for the vortex event
  51063. */
  51064. cylinder: Mesh;
  51065. }
  51066. }
  51067. declare module BABYLON {
  51068. /**
  51069. * AmmoJS Physics plugin
  51070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51071. * @see https://github.com/kripken/ammo.js/
  51072. */
  51073. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51074. private _useDeltaForWorldStep;
  51075. /**
  51076. * Reference to the Ammo library
  51077. */
  51078. bjsAMMO: any;
  51079. /**
  51080. * Created ammoJS world which physics bodies are added to
  51081. */
  51082. world: any;
  51083. /**
  51084. * Name of the plugin
  51085. */
  51086. name: string;
  51087. private _timeStep;
  51088. private _fixedTimeStep;
  51089. private _maxSteps;
  51090. private _tmpQuaternion;
  51091. private _tmpAmmoTransform;
  51092. private _tmpAmmoQuaternion;
  51093. private _tmpAmmoConcreteContactResultCallback;
  51094. private _collisionConfiguration;
  51095. private _dispatcher;
  51096. private _overlappingPairCache;
  51097. private _solver;
  51098. private _softBodySolver;
  51099. private _tmpAmmoVectorA;
  51100. private _tmpAmmoVectorB;
  51101. private _tmpAmmoVectorC;
  51102. private _tmpAmmoVectorD;
  51103. private _tmpContactCallbackResult;
  51104. private _tmpAmmoVectorRCA;
  51105. private _tmpAmmoVectorRCB;
  51106. private _raycastResult;
  51107. private static readonly DISABLE_COLLISION_FLAG;
  51108. private static readonly KINEMATIC_FLAG;
  51109. private static readonly DISABLE_DEACTIVATION_FLAG;
  51110. /**
  51111. * Initializes the ammoJS plugin
  51112. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51113. * @param ammoInjection can be used to inject your own ammo reference
  51114. */
  51115. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51116. /**
  51117. * Sets the gravity of the physics world (m/(s^2))
  51118. * @param gravity Gravity to set
  51119. */
  51120. setGravity(gravity: Vector3): void;
  51121. /**
  51122. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51123. * @param timeStep timestep to use in seconds
  51124. */
  51125. setTimeStep(timeStep: number): void;
  51126. /**
  51127. * 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)
  51128. * @param fixedTimeStep fixedTimeStep to use in seconds
  51129. */
  51130. setFixedTimeStep(fixedTimeStep: number): void;
  51131. /**
  51132. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51133. * @param maxSteps the maximum number of steps by the physics engine per frame
  51134. */
  51135. setMaxSteps(maxSteps: number): void;
  51136. /**
  51137. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51138. * @returns the current timestep in seconds
  51139. */
  51140. getTimeStep(): number;
  51141. private _isImpostorInContact;
  51142. private _isImpostorPairInContact;
  51143. private _stepSimulation;
  51144. /**
  51145. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51146. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51147. * After the step the babylon meshes are set to the position of the physics imposters
  51148. * @param delta amount of time to step forward
  51149. * @param impostors array of imposters to update before/after the step
  51150. */
  51151. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51152. /**
  51153. * Update babylon mesh to match physics world object
  51154. * @param impostor imposter to match
  51155. */
  51156. private _afterSoftStep;
  51157. /**
  51158. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51159. * @param impostor imposter to match
  51160. */
  51161. private _ropeStep;
  51162. /**
  51163. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51164. * @param impostor imposter to match
  51165. */
  51166. private _softbodyOrClothStep;
  51167. private _tmpVector;
  51168. private _tmpMatrix;
  51169. /**
  51170. * Applies an impulse on the imposter
  51171. * @param impostor imposter to apply impulse to
  51172. * @param force amount of force to be applied to the imposter
  51173. * @param contactPoint the location to apply the impulse on the imposter
  51174. */
  51175. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51176. /**
  51177. * Applies a force on the imposter
  51178. * @param impostor imposter to apply force
  51179. * @param force amount of force to be applied to the imposter
  51180. * @param contactPoint the location to apply the force on the imposter
  51181. */
  51182. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51183. /**
  51184. * Creates a physics body using the plugin
  51185. * @param impostor the imposter to create the physics body on
  51186. */
  51187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51188. /**
  51189. * Removes the physics body from the imposter and disposes of the body's memory
  51190. * @param impostor imposter to remove the physics body from
  51191. */
  51192. removePhysicsBody(impostor: PhysicsImpostor): void;
  51193. /**
  51194. * Generates a joint
  51195. * @param impostorJoint the imposter joint to create the joint with
  51196. */
  51197. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51198. /**
  51199. * Removes a joint
  51200. * @param impostorJoint the imposter joint to remove the joint from
  51201. */
  51202. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51203. private _addMeshVerts;
  51204. /**
  51205. * Initialise the soft body vertices to match its object's (mesh) vertices
  51206. * Softbody vertices (nodes) are in world space and to match this
  51207. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51208. * @param impostor to create the softbody for
  51209. */
  51210. private _softVertexData;
  51211. /**
  51212. * Create an impostor's soft body
  51213. * @param impostor to create the softbody for
  51214. */
  51215. private _createSoftbody;
  51216. /**
  51217. * Create cloth for an impostor
  51218. * @param impostor to create the softbody for
  51219. */
  51220. private _createCloth;
  51221. /**
  51222. * Create rope for an impostor
  51223. * @param impostor to create the softbody for
  51224. */
  51225. private _createRope;
  51226. private _addHullVerts;
  51227. private _createShape;
  51228. /**
  51229. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51230. * @param impostor imposter containing the physics body and babylon object
  51231. */
  51232. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51233. /**
  51234. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51235. * @param impostor imposter containing the physics body and babylon object
  51236. * @param newPosition new position
  51237. * @param newRotation new rotation
  51238. */
  51239. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51240. /**
  51241. * If this plugin is supported
  51242. * @returns true if its supported
  51243. */
  51244. isSupported(): boolean;
  51245. /**
  51246. * Sets the linear velocity of the physics body
  51247. * @param impostor imposter to set the velocity on
  51248. * @param velocity velocity to set
  51249. */
  51250. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51251. /**
  51252. * Sets the angular velocity of the physics body
  51253. * @param impostor imposter to set the velocity on
  51254. * @param velocity velocity to set
  51255. */
  51256. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51257. /**
  51258. * gets the linear velocity
  51259. * @param impostor imposter to get linear velocity from
  51260. * @returns linear velocity
  51261. */
  51262. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51263. /**
  51264. * gets the angular velocity
  51265. * @param impostor imposter to get angular velocity from
  51266. * @returns angular velocity
  51267. */
  51268. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51269. /**
  51270. * Sets the mass of physics body
  51271. * @param impostor imposter to set the mass on
  51272. * @param mass mass to set
  51273. */
  51274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51275. /**
  51276. * Gets the mass of the physics body
  51277. * @param impostor imposter to get the mass from
  51278. * @returns mass
  51279. */
  51280. getBodyMass(impostor: PhysicsImpostor): number;
  51281. /**
  51282. * Gets friction of the impostor
  51283. * @param impostor impostor to get friction from
  51284. * @returns friction value
  51285. */
  51286. getBodyFriction(impostor: PhysicsImpostor): number;
  51287. /**
  51288. * Sets friction of the impostor
  51289. * @param impostor impostor to set friction on
  51290. * @param friction friction value
  51291. */
  51292. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51293. /**
  51294. * Gets restitution of the impostor
  51295. * @param impostor impostor to get restitution from
  51296. * @returns restitution value
  51297. */
  51298. getBodyRestitution(impostor: PhysicsImpostor): number;
  51299. /**
  51300. * Sets resitution of the impostor
  51301. * @param impostor impostor to set resitution on
  51302. * @param restitution resitution value
  51303. */
  51304. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51305. /**
  51306. * Gets pressure inside the impostor
  51307. * @param impostor impostor to get pressure from
  51308. * @returns pressure value
  51309. */
  51310. getBodyPressure(impostor: PhysicsImpostor): number;
  51311. /**
  51312. * Sets pressure inside a soft body impostor
  51313. * Cloth and rope must remain 0 pressure
  51314. * @param impostor impostor to set pressure on
  51315. * @param pressure pressure value
  51316. */
  51317. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51318. /**
  51319. * Gets stiffness of the impostor
  51320. * @param impostor impostor to get stiffness from
  51321. * @returns pressure value
  51322. */
  51323. getBodyStiffness(impostor: PhysicsImpostor): number;
  51324. /**
  51325. * Sets stiffness of the impostor
  51326. * @param impostor impostor to set stiffness on
  51327. * @param stiffness stiffness value from 0 to 1
  51328. */
  51329. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51330. /**
  51331. * Gets velocityIterations of the impostor
  51332. * @param impostor impostor to get velocity iterations from
  51333. * @returns velocityIterations value
  51334. */
  51335. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51336. /**
  51337. * Sets velocityIterations of the impostor
  51338. * @param impostor impostor to set velocity iterations on
  51339. * @param velocityIterations velocityIterations value
  51340. */
  51341. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51342. /**
  51343. * Gets positionIterations of the impostor
  51344. * @param impostor impostor to get position iterations from
  51345. * @returns positionIterations value
  51346. */
  51347. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51348. /**
  51349. * Sets positionIterations of the impostor
  51350. * @param impostor impostor to set position on
  51351. * @param positionIterations positionIterations value
  51352. */
  51353. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51354. /**
  51355. * Append an anchor to a cloth object
  51356. * @param impostor is the cloth impostor to add anchor to
  51357. * @param otherImpostor is the rigid impostor to anchor to
  51358. * @param width ratio across width from 0 to 1
  51359. * @param height ratio up height from 0 to 1
  51360. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51362. */
  51363. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51364. /**
  51365. * Append an hook to a rope object
  51366. * @param impostor is the rope impostor to add hook to
  51367. * @param otherImpostor is the rigid impostor to hook to
  51368. * @param length ratio along the rope from 0 to 1
  51369. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51370. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51371. */
  51372. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51373. /**
  51374. * Sleeps the physics body and stops it from being active
  51375. * @param impostor impostor to sleep
  51376. */
  51377. sleepBody(impostor: PhysicsImpostor): void;
  51378. /**
  51379. * Activates the physics body
  51380. * @param impostor impostor to activate
  51381. */
  51382. wakeUpBody(impostor: PhysicsImpostor): void;
  51383. /**
  51384. * Updates the distance parameters of the joint
  51385. * @param joint joint to update
  51386. * @param maxDistance maximum distance of the joint
  51387. * @param minDistance minimum distance of the joint
  51388. */
  51389. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51390. /**
  51391. * Sets a motor on the joint
  51392. * @param joint joint to set motor on
  51393. * @param speed speed of the motor
  51394. * @param maxForce maximum force of the motor
  51395. * @param motorIndex index of the motor
  51396. */
  51397. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51398. /**
  51399. * Sets the motors limit
  51400. * @param joint joint to set limit on
  51401. * @param upperLimit upper limit
  51402. * @param lowerLimit lower limit
  51403. */
  51404. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51405. /**
  51406. * Syncs the position and rotation of a mesh with the impostor
  51407. * @param mesh mesh to sync
  51408. * @param impostor impostor to update the mesh with
  51409. */
  51410. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51411. /**
  51412. * Gets the radius of the impostor
  51413. * @param impostor impostor to get radius from
  51414. * @returns the radius
  51415. */
  51416. getRadius(impostor: PhysicsImpostor): number;
  51417. /**
  51418. * Gets the box size of the impostor
  51419. * @param impostor impostor to get box size from
  51420. * @param result the resulting box size
  51421. */
  51422. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51423. /**
  51424. * Disposes of the impostor
  51425. */
  51426. dispose(): void;
  51427. /**
  51428. * Does a raycast in the physics world
  51429. * @param from when should the ray start?
  51430. * @param to when should the ray end?
  51431. * @returns PhysicsRaycastResult
  51432. */
  51433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51434. }
  51435. }
  51436. declare module BABYLON {
  51437. /** @hidden */
  51438. export var blackAndWhitePixelShader: {
  51439. name: string;
  51440. shader: string;
  51441. };
  51442. }
  51443. declare module BABYLON {
  51444. /**
  51445. * Post process used to render in black and white
  51446. */
  51447. export class BlackAndWhitePostProcess extends PostProcess {
  51448. /**
  51449. * Linear about to convert he result to black and white (default: 1)
  51450. */
  51451. degree: number;
  51452. /**
  51453. * Creates a black and white post process
  51454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51455. * @param name The name of the effect.
  51456. * @param options The required width/height ratio to downsize to before computing the render pass.
  51457. * @param camera The camera to apply the render pass to.
  51458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51459. * @param engine The engine which the post process will be applied. (default: current engine)
  51460. * @param reusable If the post process can be reused on the same frame. (default: false)
  51461. */
  51462. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51463. }
  51464. }
  51465. declare module BABYLON {
  51466. /**
  51467. * This represents a set of one or more post processes in Babylon.
  51468. * A post process can be used to apply a shader to a texture after it is rendered.
  51469. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51470. */
  51471. export class PostProcessRenderEffect {
  51472. private _postProcesses;
  51473. private _getPostProcesses;
  51474. private _singleInstance;
  51475. private _cameras;
  51476. private _indicesForCamera;
  51477. /**
  51478. * Name of the effect
  51479. * @hidden
  51480. */
  51481. _name: string;
  51482. /**
  51483. * Instantiates a post process render effect.
  51484. * A post process can be used to apply a shader to a texture after it is rendered.
  51485. * @param engine The engine the effect is tied to
  51486. * @param name The name of the effect
  51487. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51488. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51489. */
  51490. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51491. /**
  51492. * Checks if all the post processes in the effect are supported.
  51493. */
  51494. readonly isSupported: boolean;
  51495. /**
  51496. * Updates the current state of the effect
  51497. * @hidden
  51498. */
  51499. _update(): void;
  51500. /**
  51501. * Attaches the effect on cameras
  51502. * @param cameras The camera to attach to.
  51503. * @hidden
  51504. */
  51505. _attachCameras(cameras: Camera): void;
  51506. /**
  51507. * Attaches the effect on cameras
  51508. * @param cameras The camera to attach to.
  51509. * @hidden
  51510. */
  51511. _attachCameras(cameras: Camera[]): void;
  51512. /**
  51513. * Detatches the effect on cameras
  51514. * @param cameras The camera to detatch from.
  51515. * @hidden
  51516. */
  51517. _detachCameras(cameras: Camera): void;
  51518. /**
  51519. * Detatches the effect on cameras
  51520. * @param cameras The camera to detatch from.
  51521. * @hidden
  51522. */
  51523. _detachCameras(cameras: Camera[]): void;
  51524. /**
  51525. * Enables the effect on given cameras
  51526. * @param cameras The camera to enable.
  51527. * @hidden
  51528. */
  51529. _enable(cameras: Camera): void;
  51530. /**
  51531. * Enables the effect on given cameras
  51532. * @param cameras The camera to enable.
  51533. * @hidden
  51534. */
  51535. _enable(cameras: Nullable<Camera[]>): void;
  51536. /**
  51537. * Disables the effect on the given cameras
  51538. * @param cameras The camera to disable.
  51539. * @hidden
  51540. */
  51541. _disable(cameras: Camera): void;
  51542. /**
  51543. * Disables the effect on the given cameras
  51544. * @param cameras The camera to disable.
  51545. * @hidden
  51546. */
  51547. _disable(cameras: Nullable<Camera[]>): void;
  51548. /**
  51549. * Gets a list of the post processes contained in the effect.
  51550. * @param camera The camera to get the post processes on.
  51551. * @returns The list of the post processes in the effect.
  51552. */
  51553. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51554. }
  51555. }
  51556. declare module BABYLON {
  51557. /** @hidden */
  51558. export var extractHighlightsPixelShader: {
  51559. name: string;
  51560. shader: string;
  51561. };
  51562. }
  51563. declare module BABYLON {
  51564. /**
  51565. * 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.
  51566. */
  51567. export class ExtractHighlightsPostProcess extends PostProcess {
  51568. /**
  51569. * The luminance threshold, pixels below this value will be set to black.
  51570. */
  51571. threshold: number;
  51572. /** @hidden */
  51573. _exposure: number;
  51574. /**
  51575. * Post process which has the input texture to be used when performing highlight extraction
  51576. * @hidden
  51577. */
  51578. _inputPostProcess: Nullable<PostProcess>;
  51579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51580. }
  51581. }
  51582. declare module BABYLON {
  51583. /** @hidden */
  51584. export var bloomMergePixelShader: {
  51585. name: string;
  51586. shader: string;
  51587. };
  51588. }
  51589. declare module BABYLON {
  51590. /**
  51591. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51592. */
  51593. export class BloomMergePostProcess extends PostProcess {
  51594. /** Weight of the bloom to be added to the original input. */
  51595. weight: number;
  51596. /**
  51597. * Creates a new instance of @see BloomMergePostProcess
  51598. * @param name The name of the effect.
  51599. * @param originalFromInput Post process which's input will be used for the merge.
  51600. * @param blurred Blurred highlights post process which's output will be used.
  51601. * @param weight Weight of the bloom to be added to the original input.
  51602. * @param options The required width/height ratio to downsize to before computing the render pass.
  51603. * @param camera The camera to apply the render pass to.
  51604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51605. * @param engine The engine which the post process will be applied. (default: current engine)
  51606. * @param reusable If the post process can be reused on the same frame. (default: false)
  51607. * @param textureType Type of textures used when performing the post process. (default: 0)
  51608. * @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)
  51609. */
  51610. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51611. /** Weight of the bloom to be added to the original input. */
  51612. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51613. }
  51614. }
  51615. declare module BABYLON {
  51616. /**
  51617. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51618. */
  51619. export class BloomEffect extends PostProcessRenderEffect {
  51620. private bloomScale;
  51621. /**
  51622. * @hidden Internal
  51623. */
  51624. _effects: Array<PostProcess>;
  51625. /**
  51626. * @hidden Internal
  51627. */
  51628. _downscale: ExtractHighlightsPostProcess;
  51629. private _blurX;
  51630. private _blurY;
  51631. private _merge;
  51632. /**
  51633. * The luminance threshold to find bright areas of the image to bloom.
  51634. */
  51635. threshold: number;
  51636. /**
  51637. * The strength of the bloom.
  51638. */
  51639. weight: number;
  51640. /**
  51641. * Specifies the size of the bloom blur kernel, relative to the final output size
  51642. */
  51643. kernel: number;
  51644. /**
  51645. * Creates a new instance of @see BloomEffect
  51646. * @param scene The scene the effect belongs to.
  51647. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51648. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51649. * @param bloomWeight The the strength of bloom.
  51650. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51651. * @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)
  51652. */
  51653. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51654. /**
  51655. * Disposes each of the internal effects for a given camera.
  51656. * @param camera The camera to dispose the effect on.
  51657. */
  51658. disposeEffects(camera: Camera): void;
  51659. /**
  51660. * @hidden Internal
  51661. */
  51662. _updateEffects(): void;
  51663. /**
  51664. * Internal
  51665. * @returns if all the contained post processes are ready.
  51666. * @hidden
  51667. */
  51668. _isReady(): boolean;
  51669. }
  51670. }
  51671. declare module BABYLON {
  51672. /** @hidden */
  51673. export var chromaticAberrationPixelShader: {
  51674. name: string;
  51675. shader: string;
  51676. };
  51677. }
  51678. declare module BABYLON {
  51679. /**
  51680. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51681. */
  51682. export class ChromaticAberrationPostProcess extends PostProcess {
  51683. /**
  51684. * The amount of seperation of rgb channels (default: 30)
  51685. */
  51686. aberrationAmount: number;
  51687. /**
  51688. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51689. */
  51690. radialIntensity: number;
  51691. /**
  51692. * 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))
  51693. */
  51694. direction: Vector2;
  51695. /**
  51696. * 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))
  51697. */
  51698. centerPosition: Vector2;
  51699. /**
  51700. * Creates a new instance ChromaticAberrationPostProcess
  51701. * @param name The name of the effect.
  51702. * @param screenWidth The width of the screen to apply the effect on.
  51703. * @param screenHeight The height of the screen to apply the effect on.
  51704. * @param options The required width/height ratio to downsize to before computing the render pass.
  51705. * @param camera The camera to apply the render pass to.
  51706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51707. * @param engine The engine which the post process will be applied. (default: current engine)
  51708. * @param reusable If the post process can be reused on the same frame. (default: false)
  51709. * @param textureType Type of textures used when performing the post process. (default: 0)
  51710. * @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)
  51711. */
  51712. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51713. }
  51714. }
  51715. declare module BABYLON {
  51716. /** @hidden */
  51717. export var circleOfConfusionPixelShader: {
  51718. name: string;
  51719. shader: string;
  51720. };
  51721. }
  51722. declare module BABYLON {
  51723. /**
  51724. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51725. */
  51726. export class CircleOfConfusionPostProcess extends PostProcess {
  51727. /**
  51728. * 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.
  51729. */
  51730. lensSize: number;
  51731. /**
  51732. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51733. */
  51734. fStop: number;
  51735. /**
  51736. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51737. */
  51738. focusDistance: number;
  51739. /**
  51740. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51741. */
  51742. focalLength: number;
  51743. private _depthTexture;
  51744. /**
  51745. * Creates a new instance CircleOfConfusionPostProcess
  51746. * @param name The name of the effect.
  51747. * @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.
  51748. * @param options The required width/height ratio to downsize to before computing the render pass.
  51749. * @param camera The camera to apply the render pass to.
  51750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51751. * @param engine The engine which the post process will be applied. (default: current engine)
  51752. * @param reusable If the post process can be reused on the same frame. (default: false)
  51753. * @param textureType Type of textures used when performing the post process. (default: 0)
  51754. * @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)
  51755. */
  51756. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51757. /**
  51758. * 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.
  51759. */
  51760. depthTexture: RenderTargetTexture;
  51761. }
  51762. }
  51763. declare module BABYLON {
  51764. /** @hidden */
  51765. export var colorCorrectionPixelShader: {
  51766. name: string;
  51767. shader: string;
  51768. };
  51769. }
  51770. declare module BABYLON {
  51771. /**
  51772. *
  51773. * This post-process allows the modification of rendered colors by using
  51774. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51775. *
  51776. * The object needs to be provided an url to a texture containing the color
  51777. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51778. * Use an image editing software to tweak the LUT to match your needs.
  51779. *
  51780. * For an example of a color LUT, see here:
  51781. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51782. * For explanations on color grading, see here:
  51783. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51784. *
  51785. */
  51786. export class ColorCorrectionPostProcess extends PostProcess {
  51787. private _colorTableTexture;
  51788. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51789. }
  51790. }
  51791. declare module BABYLON {
  51792. /** @hidden */
  51793. export var convolutionPixelShader: {
  51794. name: string;
  51795. shader: string;
  51796. };
  51797. }
  51798. declare module BABYLON {
  51799. /**
  51800. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51801. * input texture to perform effects such as edge detection or sharpening
  51802. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51803. */
  51804. export class ConvolutionPostProcess extends PostProcess {
  51805. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51806. kernel: number[];
  51807. /**
  51808. * Creates a new instance ConvolutionPostProcess
  51809. * @param name The name of the effect.
  51810. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51811. * @param options The required width/height ratio to downsize to before computing the render pass.
  51812. * @param camera The camera to apply the render pass to.
  51813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51814. * @param engine The engine which the post process will be applied. (default: current engine)
  51815. * @param reusable If the post process can be reused on the same frame. (default: false)
  51816. * @param textureType Type of textures used when performing the post process. (default: 0)
  51817. */
  51818. constructor(name: string,
  51819. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51820. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51821. /**
  51822. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51823. */
  51824. static EdgeDetect0Kernel: number[];
  51825. /**
  51826. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51827. */
  51828. static EdgeDetect1Kernel: number[];
  51829. /**
  51830. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51831. */
  51832. static EdgeDetect2Kernel: number[];
  51833. /**
  51834. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51835. */
  51836. static SharpenKernel: number[];
  51837. /**
  51838. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51839. */
  51840. static EmbossKernel: number[];
  51841. /**
  51842. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51843. */
  51844. static GaussianKernel: number[];
  51845. }
  51846. }
  51847. declare module BABYLON {
  51848. /**
  51849. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51850. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51851. * based on samples that have a large difference in distance than the center pixel.
  51852. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51853. */
  51854. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51855. direction: Vector2;
  51856. /**
  51857. * Creates a new instance CircleOfConfusionPostProcess
  51858. * @param name The name of the effect.
  51859. * @param scene The scene the effect belongs to.
  51860. * @param direction The direction the blur should be applied.
  51861. * @param kernel The size of the kernel used to blur.
  51862. * @param options The required width/height ratio to downsize to before computing the render pass.
  51863. * @param camera The camera to apply the render pass to.
  51864. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51865. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51867. * @param engine The engine which the post process will be applied. (default: current engine)
  51868. * @param reusable If the post process can be reused on the same frame. (default: false)
  51869. * @param textureType Type of textures used when performing the post process. (default: 0)
  51870. * @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)
  51871. */
  51872. 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);
  51873. }
  51874. }
  51875. declare module BABYLON {
  51876. /** @hidden */
  51877. export var depthOfFieldMergePixelShader: {
  51878. name: string;
  51879. shader: string;
  51880. };
  51881. }
  51882. declare module BABYLON {
  51883. /**
  51884. * Options to be set when merging outputs from the default pipeline.
  51885. */
  51886. export class DepthOfFieldMergePostProcessOptions {
  51887. /**
  51888. * The original image to merge on top of
  51889. */
  51890. originalFromInput: PostProcess;
  51891. /**
  51892. * Parameters to perform the merge of the depth of field effect
  51893. */
  51894. depthOfField?: {
  51895. circleOfConfusion: PostProcess;
  51896. blurSteps: Array<PostProcess>;
  51897. };
  51898. /**
  51899. * Parameters to perform the merge of bloom effect
  51900. */
  51901. bloom?: {
  51902. blurred: PostProcess;
  51903. weight: number;
  51904. };
  51905. }
  51906. /**
  51907. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51908. */
  51909. export class DepthOfFieldMergePostProcess extends PostProcess {
  51910. private blurSteps;
  51911. /**
  51912. * Creates a new instance of DepthOfFieldMergePostProcess
  51913. * @param name The name of the effect.
  51914. * @param originalFromInput Post process which's input will be used for the merge.
  51915. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51916. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51917. * @param options The required width/height ratio to downsize to before computing the render pass.
  51918. * @param camera The camera to apply the render pass to.
  51919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51920. * @param engine The engine which the post process will be applied. (default: current engine)
  51921. * @param reusable If the post process can be reused on the same frame. (default: false)
  51922. * @param textureType Type of textures used when performing the post process. (default: 0)
  51923. * @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)
  51924. */
  51925. 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);
  51926. /**
  51927. * Updates the effect with the current post process compile time values and recompiles the shader.
  51928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51931. * @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
  51932. * @param onCompiled Called when the shader has been compiled.
  51933. * @param onError Called if there is an error when compiling a shader.
  51934. */
  51935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51936. }
  51937. }
  51938. declare module BABYLON {
  51939. /**
  51940. * Specifies the level of max blur that should be applied when using the depth of field effect
  51941. */
  51942. export enum DepthOfFieldEffectBlurLevel {
  51943. /**
  51944. * Subtle blur
  51945. */
  51946. Low = 0,
  51947. /**
  51948. * Medium blur
  51949. */
  51950. Medium = 1,
  51951. /**
  51952. * Large blur
  51953. */
  51954. High = 2
  51955. }
  51956. /**
  51957. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51958. */
  51959. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51960. private _circleOfConfusion;
  51961. /**
  51962. * @hidden Internal, blurs from high to low
  51963. */
  51964. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51965. private _depthOfFieldBlurY;
  51966. private _dofMerge;
  51967. /**
  51968. * @hidden Internal post processes in depth of field effect
  51969. */
  51970. _effects: Array<PostProcess>;
  51971. /**
  51972. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51973. */
  51974. focalLength: number;
  51975. /**
  51976. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51977. */
  51978. fStop: number;
  51979. /**
  51980. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51981. */
  51982. focusDistance: number;
  51983. /**
  51984. * 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.
  51985. */
  51986. lensSize: number;
  51987. /**
  51988. * Creates a new instance DepthOfFieldEffect
  51989. * @param scene The scene the effect belongs to.
  51990. * @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.
  51991. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51992. * @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)
  51993. */
  51994. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51995. /**
  51996. * 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.
  51997. */
  51998. depthTexture: RenderTargetTexture;
  51999. /**
  52000. * Disposes each of the internal effects for a given camera.
  52001. * @param camera The camera to dispose the effect on.
  52002. */
  52003. disposeEffects(camera: Camera): void;
  52004. /**
  52005. * @hidden Internal
  52006. */
  52007. _updateEffects(): void;
  52008. /**
  52009. * Internal
  52010. * @returns if all the contained post processes are ready.
  52011. * @hidden
  52012. */
  52013. _isReady(): boolean;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /** @hidden */
  52018. export var displayPassPixelShader: {
  52019. name: string;
  52020. shader: string;
  52021. };
  52022. }
  52023. declare module BABYLON {
  52024. /**
  52025. * DisplayPassPostProcess which produces an output the same as it's input
  52026. */
  52027. export class DisplayPassPostProcess extends PostProcess {
  52028. /**
  52029. * Creates the DisplayPassPostProcess
  52030. * @param name The name of the effect.
  52031. * @param options The required width/height ratio to downsize to before computing the render pass.
  52032. * @param camera The camera to apply the render pass to.
  52033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52034. * @param engine The engine which the post process will be applied. (default: current engine)
  52035. * @param reusable If the post process can be reused on the same frame. (default: false)
  52036. */
  52037. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52038. }
  52039. }
  52040. declare module BABYLON {
  52041. /** @hidden */
  52042. export var filterPixelShader: {
  52043. name: string;
  52044. shader: string;
  52045. };
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * Applies a kernel filter to the image
  52050. */
  52051. export class FilterPostProcess extends PostProcess {
  52052. /** The matrix to be applied to the image */
  52053. kernelMatrix: Matrix;
  52054. /**
  52055. *
  52056. * @param name The name of the effect.
  52057. * @param kernelMatrix The matrix to be applied to the image
  52058. * @param options The required width/height ratio to downsize to before computing the render pass.
  52059. * @param camera The camera to apply the render pass to.
  52060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52061. * @param engine The engine which the post process will be applied. (default: current engine)
  52062. * @param reusable If the post process can be reused on the same frame. (default: false)
  52063. */
  52064. constructor(name: string,
  52065. /** The matrix to be applied to the image */
  52066. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52067. }
  52068. }
  52069. declare module BABYLON {
  52070. /** @hidden */
  52071. export var fxaaPixelShader: {
  52072. name: string;
  52073. shader: string;
  52074. };
  52075. }
  52076. declare module BABYLON {
  52077. /** @hidden */
  52078. export var fxaaVertexShader: {
  52079. name: string;
  52080. shader: string;
  52081. };
  52082. }
  52083. declare module BABYLON {
  52084. /**
  52085. * Fxaa post process
  52086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52087. */
  52088. export class FxaaPostProcess extends PostProcess {
  52089. /** @hidden */
  52090. texelWidth: number;
  52091. /** @hidden */
  52092. texelHeight: number;
  52093. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52094. private _getDefines;
  52095. }
  52096. }
  52097. declare module BABYLON {
  52098. /** @hidden */
  52099. export var grainPixelShader: {
  52100. name: string;
  52101. shader: string;
  52102. };
  52103. }
  52104. declare module BABYLON {
  52105. /**
  52106. * The GrainPostProcess adds noise to the image at mid luminance levels
  52107. */
  52108. export class GrainPostProcess extends PostProcess {
  52109. /**
  52110. * The intensity of the grain added (default: 30)
  52111. */
  52112. intensity: number;
  52113. /**
  52114. * If the grain should be randomized on every frame
  52115. */
  52116. animated: boolean;
  52117. /**
  52118. * Creates a new instance of @see GrainPostProcess
  52119. * @param name The name of the effect.
  52120. * @param options The required width/height ratio to downsize to before computing the render pass.
  52121. * @param camera The camera to apply the render pass to.
  52122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52123. * @param engine The engine which the post process will be applied. (default: current engine)
  52124. * @param reusable If the post process can be reused on the same frame. (default: false)
  52125. * @param textureType Type of textures used when performing the post process. (default: 0)
  52126. * @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)
  52127. */
  52128. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /** @hidden */
  52133. export var highlightsPixelShader: {
  52134. name: string;
  52135. shader: string;
  52136. };
  52137. }
  52138. declare module BABYLON {
  52139. /**
  52140. * Extracts highlights from the image
  52141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52142. */
  52143. export class HighlightsPostProcess extends PostProcess {
  52144. /**
  52145. * Extracts highlights from the image
  52146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52147. * @param name The name of the effect.
  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 texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52154. */
  52155. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52156. }
  52157. }
  52158. declare module BABYLON {
  52159. /** @hidden */
  52160. export var mrtFragmentDeclaration: {
  52161. name: string;
  52162. shader: string;
  52163. };
  52164. }
  52165. declare module BABYLON {
  52166. /** @hidden */
  52167. export var geometryPixelShader: {
  52168. name: string;
  52169. shader: string;
  52170. };
  52171. }
  52172. declare module BABYLON {
  52173. /** @hidden */
  52174. export var geometryVertexShader: {
  52175. name: string;
  52176. shader: string;
  52177. };
  52178. }
  52179. declare module BABYLON {
  52180. /**
  52181. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52182. */
  52183. export class GeometryBufferRenderer {
  52184. /**
  52185. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52186. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52187. */
  52188. static readonly POSITION_TEXTURE_TYPE: number;
  52189. /**
  52190. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52191. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52192. */
  52193. static readonly VELOCITY_TEXTURE_TYPE: number;
  52194. /**
  52195. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52196. * in order to compute objects velocities when enableVelocity is set to "true"
  52197. * @hidden
  52198. */
  52199. _previousTransformationMatrices: {
  52200. [index: number]: Matrix;
  52201. };
  52202. private _scene;
  52203. private _multiRenderTarget;
  52204. private _ratio;
  52205. private _enablePosition;
  52206. private _enableVelocity;
  52207. private _positionIndex;
  52208. private _velocityIndex;
  52209. protected _effect: Effect;
  52210. protected _cachedDefines: string;
  52211. /**
  52212. * Set the render list (meshes to be rendered) used in the G buffer.
  52213. */
  52214. renderList: Mesh[];
  52215. /**
  52216. * Gets wether or not G buffer are supported by the running hardware.
  52217. * This requires draw buffer supports
  52218. */
  52219. readonly isSupported: boolean;
  52220. /**
  52221. * Returns the index of the given texture type in the G-Buffer textures array
  52222. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52223. * @returns the index of the given texture type in the G-Buffer textures array
  52224. */
  52225. getTextureIndex(textureType: number): number;
  52226. /**
  52227. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52228. */
  52229. /**
  52230. * Sets whether or not objects positions are enabled for the G buffer.
  52231. */
  52232. enablePosition: boolean;
  52233. /**
  52234. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52235. */
  52236. /**
  52237. * Sets wether or not objects velocities are enabled for the G buffer.
  52238. */
  52239. enableVelocity: boolean;
  52240. /**
  52241. * Gets the scene associated with the buffer.
  52242. */
  52243. readonly scene: Scene;
  52244. /**
  52245. * Gets the ratio used by the buffer during its creation.
  52246. * How big is the buffer related to the main canvas.
  52247. */
  52248. readonly ratio: number;
  52249. /** @hidden */
  52250. static _SceneComponentInitialization: (scene: Scene) => void;
  52251. /**
  52252. * Creates a new G Buffer for the scene
  52253. * @param scene The scene the buffer belongs to
  52254. * @param ratio How big is the buffer related to the main canvas.
  52255. */
  52256. constructor(scene: Scene, ratio?: number);
  52257. /**
  52258. * Checks wether everything is ready to render a submesh to the G buffer.
  52259. * @param subMesh the submesh to check readiness for
  52260. * @param useInstances is the mesh drawn using instance or not
  52261. * @returns true if ready otherwise false
  52262. */
  52263. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52264. /**
  52265. * Gets the current underlying G Buffer.
  52266. * @returns the buffer
  52267. */
  52268. getGBuffer(): MultiRenderTarget;
  52269. /**
  52270. * Gets the number of samples used to render the buffer (anti aliasing).
  52271. */
  52272. /**
  52273. * Sets the number of samples used to render the buffer (anti aliasing).
  52274. */
  52275. samples: number;
  52276. /**
  52277. * Disposes the renderer and frees up associated resources.
  52278. */
  52279. dispose(): void;
  52280. protected _createRenderTargets(): void;
  52281. }
  52282. }
  52283. declare module BABYLON {
  52284. interface Scene {
  52285. /** @hidden (Backing field) */
  52286. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52287. /**
  52288. * Gets or Sets the current geometry buffer associated to the scene.
  52289. */
  52290. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52291. /**
  52292. * Enables a GeometryBufferRender and associates it with the scene
  52293. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52294. * @returns the GeometryBufferRenderer
  52295. */
  52296. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52297. /**
  52298. * Disables the GeometryBufferRender associated with the scene
  52299. */
  52300. disableGeometryBufferRenderer(): void;
  52301. }
  52302. /**
  52303. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52304. * in several rendering techniques.
  52305. */
  52306. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52307. /**
  52308. * The component name helpful to identify the component in the list of scene components.
  52309. */
  52310. readonly name: string;
  52311. /**
  52312. * The scene the component belongs to.
  52313. */
  52314. scene: Scene;
  52315. /**
  52316. * Creates a new instance of the component for the given scene
  52317. * @param scene Defines the scene to register the component in
  52318. */
  52319. constructor(scene: Scene);
  52320. /**
  52321. * Registers the component in a given scene
  52322. */
  52323. register(): void;
  52324. /**
  52325. * Rebuilds the elements related to this component in case of
  52326. * context lost for instance.
  52327. */
  52328. rebuild(): void;
  52329. /**
  52330. * Disposes the component and the associated ressources
  52331. */
  52332. dispose(): void;
  52333. private _gatherRenderTargets;
  52334. }
  52335. }
  52336. declare module BABYLON {
  52337. /** @hidden */
  52338. export var motionBlurPixelShader: {
  52339. name: string;
  52340. shader: string;
  52341. };
  52342. }
  52343. declare module BABYLON {
  52344. /**
  52345. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52346. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52347. * As an example, all you have to do is to create the post-process:
  52348. * var mb = new BABYLON.MotionBlurPostProcess(
  52349. * 'mb', // The name of the effect.
  52350. * scene, // The scene containing the objects to blur according to their velocity.
  52351. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52352. * camera // The camera to apply the render pass to.
  52353. * );
  52354. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52355. */
  52356. export class MotionBlurPostProcess extends PostProcess {
  52357. /**
  52358. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52359. */
  52360. motionStrength: number;
  52361. /**
  52362. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52363. */
  52364. /**
  52365. * Sets the number of iterations to be used for motion blur quality
  52366. */
  52367. motionBlurSamples: number;
  52368. private _motionBlurSamples;
  52369. private _geometryBufferRenderer;
  52370. /**
  52371. * Creates a new instance MotionBlurPostProcess
  52372. * @param name The name of the effect.
  52373. * @param scene The scene containing the objects to blur according to their velocity.
  52374. * @param options The required width/height ratio to downsize to before computing the render pass.
  52375. * @param camera The camera to apply the render pass to.
  52376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52377. * @param engine The engine which the post process will be applied. (default: current engine)
  52378. * @param reusable If the post process can be reused on the same frame. (default: false)
  52379. * @param textureType Type of textures used when performing the post process. (default: 0)
  52380. * @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)
  52381. */
  52382. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52383. /**
  52384. * Disposes the post process.
  52385. * @param camera The camera to dispose the post process on.
  52386. */
  52387. dispose(camera?: Camera): void;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /** @hidden */
  52392. export var refractionPixelShader: {
  52393. name: string;
  52394. shader: string;
  52395. };
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Post process which applies a refractin texture
  52400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52401. */
  52402. export class RefractionPostProcess extends PostProcess {
  52403. /** the base color of the refraction (used to taint the rendering) */
  52404. color: Color3;
  52405. /** simulated refraction depth */
  52406. depth: number;
  52407. /** the coefficient of the base color (0 to remove base color tainting) */
  52408. colorLevel: number;
  52409. private _refTexture;
  52410. private _ownRefractionTexture;
  52411. /**
  52412. * Gets or sets the refraction texture
  52413. * Please note that you are responsible for disposing the texture if you set it manually
  52414. */
  52415. refractionTexture: Texture;
  52416. /**
  52417. * Initializes the RefractionPostProcess
  52418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52419. * @param name The name of the effect.
  52420. * @param refractionTextureUrl Url of the refraction texture to use
  52421. * @param color the base color of the refraction (used to taint the rendering)
  52422. * @param depth simulated refraction depth
  52423. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52424. * @param camera The camera to apply the render pass to.
  52425. * @param options The required width/height ratio to downsize to before computing the render pass.
  52426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52427. * @param engine The engine which the post process will be applied. (default: current engine)
  52428. * @param reusable If the post process can be reused on the same frame. (default: false)
  52429. */
  52430. constructor(name: string, refractionTextureUrl: string,
  52431. /** the base color of the refraction (used to taint the rendering) */
  52432. color: Color3,
  52433. /** simulated refraction depth */
  52434. depth: number,
  52435. /** the coefficient of the base color (0 to remove base color tainting) */
  52436. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52437. /**
  52438. * Disposes of the post process
  52439. * @param camera Camera to dispose post process on
  52440. */
  52441. dispose(camera: Camera): void;
  52442. }
  52443. }
  52444. declare module BABYLON {
  52445. /** @hidden */
  52446. export var sharpenPixelShader: {
  52447. name: string;
  52448. shader: string;
  52449. };
  52450. }
  52451. declare module BABYLON {
  52452. /**
  52453. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52454. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52455. */
  52456. export class SharpenPostProcess extends PostProcess {
  52457. /**
  52458. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52459. */
  52460. colorAmount: number;
  52461. /**
  52462. * How much sharpness should be applied (default: 0.3)
  52463. */
  52464. edgeAmount: number;
  52465. /**
  52466. * Creates a new instance ConvolutionPostProcess
  52467. * @param name The name of the effect.
  52468. * @param options The required width/height ratio to downsize to before computing the render pass.
  52469. * @param camera The camera to apply the render pass to.
  52470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52471. * @param engine The engine which the post process will be applied. (default: current engine)
  52472. * @param reusable If the post process can be reused on the same frame. (default: false)
  52473. * @param textureType Type of textures used when performing the post process. (default: 0)
  52474. * @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)
  52475. */
  52476. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52477. }
  52478. }
  52479. declare module BABYLON {
  52480. /**
  52481. * PostProcessRenderPipeline
  52482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52483. */
  52484. export class PostProcessRenderPipeline {
  52485. private engine;
  52486. private _renderEffects;
  52487. private _renderEffectsForIsolatedPass;
  52488. /**
  52489. * List of inspectable custom properties (used by the Inspector)
  52490. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52491. */
  52492. inspectableCustomProperties: IInspectable[];
  52493. /**
  52494. * @hidden
  52495. */
  52496. protected _cameras: Camera[];
  52497. /** @hidden */
  52498. _name: string;
  52499. /**
  52500. * Gets pipeline name
  52501. */
  52502. readonly name: string;
  52503. /**
  52504. * Initializes a PostProcessRenderPipeline
  52505. * @param engine engine to add the pipeline to
  52506. * @param name name of the pipeline
  52507. */
  52508. constructor(engine: Engine, name: string);
  52509. /**
  52510. * Gets the class name
  52511. * @returns "PostProcessRenderPipeline"
  52512. */
  52513. getClassName(): string;
  52514. /**
  52515. * If all the render effects in the pipeline are supported
  52516. */
  52517. readonly isSupported: boolean;
  52518. /**
  52519. * Adds an effect to the pipeline
  52520. * @param renderEffect the effect to add
  52521. */
  52522. addEffect(renderEffect: PostProcessRenderEffect): void;
  52523. /** @hidden */
  52524. _rebuild(): void;
  52525. /** @hidden */
  52526. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52527. /** @hidden */
  52528. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52529. /** @hidden */
  52530. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52531. /** @hidden */
  52532. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52533. /** @hidden */
  52534. _attachCameras(cameras: Camera, unique: boolean): void;
  52535. /** @hidden */
  52536. _attachCameras(cameras: Camera[], unique: boolean): void;
  52537. /** @hidden */
  52538. _detachCameras(cameras: Camera): void;
  52539. /** @hidden */
  52540. _detachCameras(cameras: Nullable<Camera[]>): void;
  52541. /** @hidden */
  52542. _update(): void;
  52543. /** @hidden */
  52544. _reset(): void;
  52545. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52546. /**
  52547. * Disposes of the pipeline
  52548. */
  52549. dispose(): void;
  52550. }
  52551. }
  52552. declare module BABYLON {
  52553. /**
  52554. * PostProcessRenderPipelineManager class
  52555. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52556. */
  52557. export class PostProcessRenderPipelineManager {
  52558. private _renderPipelines;
  52559. /**
  52560. * Initializes a PostProcessRenderPipelineManager
  52561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52562. */
  52563. constructor();
  52564. /**
  52565. * Gets the list of supported render pipelines
  52566. */
  52567. readonly supportedPipelines: PostProcessRenderPipeline[];
  52568. /**
  52569. * Adds a pipeline to the manager
  52570. * @param renderPipeline The pipeline to add
  52571. */
  52572. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52573. /**
  52574. * Attaches a camera to the pipeline
  52575. * @param renderPipelineName The name of the pipeline to attach to
  52576. * @param cameras the camera to attach
  52577. * @param unique if the camera can be attached multiple times to the pipeline
  52578. */
  52579. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52580. /**
  52581. * Detaches a camera from the pipeline
  52582. * @param renderPipelineName The name of the pipeline to detach from
  52583. * @param cameras the camera to detach
  52584. */
  52585. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52586. /**
  52587. * Enables an effect by name on a pipeline
  52588. * @param renderPipelineName the name of the pipeline to enable the effect in
  52589. * @param renderEffectName the name of the effect to enable
  52590. * @param cameras the cameras that the effect should be enabled on
  52591. */
  52592. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52593. /**
  52594. * Disables an effect by name on a pipeline
  52595. * @param renderPipelineName the name of the pipeline to disable the effect in
  52596. * @param renderEffectName the name of the effect to disable
  52597. * @param cameras the cameras that the effect should be disabled on
  52598. */
  52599. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52600. /**
  52601. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52602. */
  52603. update(): void;
  52604. /** @hidden */
  52605. _rebuild(): void;
  52606. /**
  52607. * Disposes of the manager and pipelines
  52608. */
  52609. dispose(): void;
  52610. }
  52611. }
  52612. declare module BABYLON {
  52613. interface Scene {
  52614. /** @hidden (Backing field) */
  52615. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52616. /**
  52617. * Gets the postprocess render pipeline manager
  52618. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52619. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52620. */
  52621. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52622. }
  52623. /**
  52624. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52625. */
  52626. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52627. /**
  52628. * The component name helpfull to identify the component in the list of scene components.
  52629. */
  52630. readonly name: string;
  52631. /**
  52632. * The scene the component belongs to.
  52633. */
  52634. scene: Scene;
  52635. /**
  52636. * Creates a new instance of the component for the given scene
  52637. * @param scene Defines the scene to register the component in
  52638. */
  52639. constructor(scene: Scene);
  52640. /**
  52641. * Registers the component in a given scene
  52642. */
  52643. register(): void;
  52644. /**
  52645. * Rebuilds the elements related to this component in case of
  52646. * context lost for instance.
  52647. */
  52648. rebuild(): void;
  52649. /**
  52650. * Disposes the component and the associated ressources
  52651. */
  52652. dispose(): void;
  52653. private _gatherRenderTargets;
  52654. }
  52655. }
  52656. declare module BABYLON {
  52657. /**
  52658. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52659. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52660. */
  52661. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52662. private _scene;
  52663. private _camerasToBeAttached;
  52664. /**
  52665. * ID of the sharpen post process,
  52666. */
  52667. private readonly SharpenPostProcessId;
  52668. /**
  52669. * @ignore
  52670. * ID of the image processing post process;
  52671. */
  52672. readonly ImageProcessingPostProcessId: string;
  52673. /**
  52674. * @ignore
  52675. * ID of the Fast Approximate Anti-Aliasing post process;
  52676. */
  52677. readonly FxaaPostProcessId: string;
  52678. /**
  52679. * ID of the chromatic aberration post process,
  52680. */
  52681. private readonly ChromaticAberrationPostProcessId;
  52682. /**
  52683. * ID of the grain post process
  52684. */
  52685. private readonly GrainPostProcessId;
  52686. /**
  52687. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52688. */
  52689. sharpen: SharpenPostProcess;
  52690. private _sharpenEffect;
  52691. private bloom;
  52692. /**
  52693. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52694. */
  52695. depthOfField: DepthOfFieldEffect;
  52696. /**
  52697. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52698. */
  52699. fxaa: FxaaPostProcess;
  52700. /**
  52701. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52702. */
  52703. imageProcessing: ImageProcessingPostProcess;
  52704. /**
  52705. * Chromatic aberration post process which will shift rgb colors in the image
  52706. */
  52707. chromaticAberration: ChromaticAberrationPostProcess;
  52708. private _chromaticAberrationEffect;
  52709. /**
  52710. * Grain post process which add noise to the image
  52711. */
  52712. grain: GrainPostProcess;
  52713. private _grainEffect;
  52714. /**
  52715. * Glow post process which adds a glow to emissive areas of the image
  52716. */
  52717. private _glowLayer;
  52718. /**
  52719. * Animations which can be used to tweak settings over a period of time
  52720. */
  52721. animations: Animation[];
  52722. private _imageProcessingConfigurationObserver;
  52723. private _sharpenEnabled;
  52724. private _bloomEnabled;
  52725. private _depthOfFieldEnabled;
  52726. private _depthOfFieldBlurLevel;
  52727. private _fxaaEnabled;
  52728. private _imageProcessingEnabled;
  52729. private _defaultPipelineTextureType;
  52730. private _bloomScale;
  52731. private _chromaticAberrationEnabled;
  52732. private _grainEnabled;
  52733. private _buildAllowed;
  52734. /**
  52735. * Gets active scene
  52736. */
  52737. readonly scene: Scene;
  52738. /**
  52739. * Enable or disable the sharpen process from the pipeline
  52740. */
  52741. sharpenEnabled: boolean;
  52742. private _resizeObserver;
  52743. private _hardwareScaleLevel;
  52744. private _bloomKernel;
  52745. /**
  52746. * Specifies the size of the bloom blur kernel, relative to the final output size
  52747. */
  52748. bloomKernel: number;
  52749. /**
  52750. * Specifies the weight of the bloom in the final rendering
  52751. */
  52752. private _bloomWeight;
  52753. /**
  52754. * Specifies the luma threshold for the area that will be blurred by the bloom
  52755. */
  52756. private _bloomThreshold;
  52757. private _hdr;
  52758. /**
  52759. * The strength of the bloom.
  52760. */
  52761. bloomWeight: number;
  52762. /**
  52763. * The strength of the bloom.
  52764. */
  52765. bloomThreshold: number;
  52766. /**
  52767. * The scale of the bloom, lower value will provide better performance.
  52768. */
  52769. bloomScale: number;
  52770. /**
  52771. * Enable or disable the bloom from the pipeline
  52772. */
  52773. bloomEnabled: boolean;
  52774. private _rebuildBloom;
  52775. /**
  52776. * If the depth of field is enabled.
  52777. */
  52778. depthOfFieldEnabled: boolean;
  52779. /**
  52780. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52781. */
  52782. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52783. /**
  52784. * If the anti aliasing is enabled.
  52785. */
  52786. fxaaEnabled: boolean;
  52787. private _samples;
  52788. /**
  52789. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52790. */
  52791. samples: number;
  52792. /**
  52793. * If image processing is enabled.
  52794. */
  52795. imageProcessingEnabled: boolean;
  52796. /**
  52797. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52798. */
  52799. glowLayerEnabled: boolean;
  52800. /**
  52801. * Enable or disable the chromaticAberration process from the pipeline
  52802. */
  52803. chromaticAberrationEnabled: boolean;
  52804. /**
  52805. * Enable or disable the grain process from the pipeline
  52806. */
  52807. grainEnabled: boolean;
  52808. /**
  52809. * @constructor
  52810. * @param name - The rendering pipeline name (default: "")
  52811. * @param hdr - If high dynamic range textures should be used (default: true)
  52812. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52813. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52814. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52815. */
  52816. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52817. /**
  52818. * Get the class name
  52819. * @returns "DefaultRenderingPipeline"
  52820. */
  52821. getClassName(): string;
  52822. /**
  52823. * Force the compilation of the entire pipeline.
  52824. */
  52825. prepare(): void;
  52826. private _hasCleared;
  52827. private _prevPostProcess;
  52828. private _prevPrevPostProcess;
  52829. private _setAutoClearAndTextureSharing;
  52830. private _depthOfFieldSceneObserver;
  52831. private _buildPipeline;
  52832. private _disposePostProcesses;
  52833. /**
  52834. * Adds a camera to the pipeline
  52835. * @param camera the camera to be added
  52836. */
  52837. addCamera(camera: Camera): void;
  52838. /**
  52839. * Removes a camera from the pipeline
  52840. * @param camera the camera to remove
  52841. */
  52842. removeCamera(camera: Camera): void;
  52843. /**
  52844. * Dispose of the pipeline and stop all post processes
  52845. */
  52846. dispose(): void;
  52847. /**
  52848. * Serialize the rendering pipeline (Used when exporting)
  52849. * @returns the serialized object
  52850. */
  52851. serialize(): any;
  52852. /**
  52853. * Parse the serialized pipeline
  52854. * @param source Source pipeline.
  52855. * @param scene The scene to load the pipeline to.
  52856. * @param rootUrl The URL of the serialized pipeline.
  52857. * @returns An instantiated pipeline from the serialized object.
  52858. */
  52859. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52860. }
  52861. }
  52862. declare module BABYLON {
  52863. /** @hidden */
  52864. export var lensHighlightsPixelShader: {
  52865. name: string;
  52866. shader: string;
  52867. };
  52868. }
  52869. declare module BABYLON {
  52870. /** @hidden */
  52871. export var depthOfFieldPixelShader: {
  52872. name: string;
  52873. shader: string;
  52874. };
  52875. }
  52876. declare module BABYLON {
  52877. /**
  52878. * BABYLON.JS Chromatic Aberration GLSL Shader
  52879. * Author: Olivier Guyot
  52880. * Separates very slightly R, G and B colors on the edges of the screen
  52881. * Inspired by Francois Tarlier & Martins Upitis
  52882. */
  52883. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52884. /**
  52885. * @ignore
  52886. * The chromatic aberration PostProcess id in the pipeline
  52887. */
  52888. LensChromaticAberrationEffect: string;
  52889. /**
  52890. * @ignore
  52891. * The highlights enhancing PostProcess id in the pipeline
  52892. */
  52893. HighlightsEnhancingEffect: string;
  52894. /**
  52895. * @ignore
  52896. * The depth-of-field PostProcess id in the pipeline
  52897. */
  52898. LensDepthOfFieldEffect: string;
  52899. private _scene;
  52900. private _depthTexture;
  52901. private _grainTexture;
  52902. private _chromaticAberrationPostProcess;
  52903. private _highlightsPostProcess;
  52904. private _depthOfFieldPostProcess;
  52905. private _edgeBlur;
  52906. private _grainAmount;
  52907. private _chromaticAberration;
  52908. private _distortion;
  52909. private _highlightsGain;
  52910. private _highlightsThreshold;
  52911. private _dofDistance;
  52912. private _dofAperture;
  52913. private _dofDarken;
  52914. private _dofPentagon;
  52915. private _blurNoise;
  52916. /**
  52917. * @constructor
  52918. *
  52919. * Effect parameters are as follow:
  52920. * {
  52921. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52922. * edge_blur: number; // from 0 to x (1 for realism)
  52923. * distortion: number; // from 0 to x (1 for realism)
  52924. * grain_amount: number; // from 0 to 1
  52925. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52926. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52927. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52928. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52929. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52930. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52931. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52932. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52933. * }
  52934. * Note: if an effect parameter is unset, effect is disabled
  52935. *
  52936. * @param name The rendering pipeline name
  52937. * @param parameters - An object containing all parameters (see above)
  52938. * @param scene The scene linked to this pipeline
  52939. * @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)
  52940. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52941. */
  52942. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52943. /**
  52944. * Get the class name
  52945. * @returns "LensRenderingPipeline"
  52946. */
  52947. getClassName(): string;
  52948. /**
  52949. * Gets associated scene
  52950. */
  52951. readonly scene: Scene;
  52952. /**
  52953. * Gets or sets the edge blur
  52954. */
  52955. edgeBlur: number;
  52956. /**
  52957. * Gets or sets the grain amount
  52958. */
  52959. grainAmount: number;
  52960. /**
  52961. * Gets or sets the chromatic aberration amount
  52962. */
  52963. chromaticAberration: number;
  52964. /**
  52965. * Gets or sets the depth of field aperture
  52966. */
  52967. dofAperture: number;
  52968. /**
  52969. * Gets or sets the edge distortion
  52970. */
  52971. edgeDistortion: number;
  52972. /**
  52973. * Gets or sets the depth of field distortion
  52974. */
  52975. dofDistortion: number;
  52976. /**
  52977. * Gets or sets the darken out of focus amount
  52978. */
  52979. darkenOutOfFocus: number;
  52980. /**
  52981. * Gets or sets a boolean indicating if blur noise is enabled
  52982. */
  52983. blurNoise: boolean;
  52984. /**
  52985. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52986. */
  52987. pentagonBokeh: boolean;
  52988. /**
  52989. * Gets or sets the highlight grain amount
  52990. */
  52991. highlightsGain: number;
  52992. /**
  52993. * Gets or sets the highlight threshold
  52994. */
  52995. highlightsThreshold: number;
  52996. /**
  52997. * Sets the amount of blur at the edges
  52998. * @param amount blur amount
  52999. */
  53000. setEdgeBlur(amount: number): void;
  53001. /**
  53002. * Sets edge blur to 0
  53003. */
  53004. disableEdgeBlur(): void;
  53005. /**
  53006. * Sets the amout of grain
  53007. * @param amount Amount of grain
  53008. */
  53009. setGrainAmount(amount: number): void;
  53010. /**
  53011. * Set grain amount to 0
  53012. */
  53013. disableGrain(): void;
  53014. /**
  53015. * Sets the chromatic aberration amount
  53016. * @param amount amount of chromatic aberration
  53017. */
  53018. setChromaticAberration(amount: number): void;
  53019. /**
  53020. * Sets chromatic aberration amount to 0
  53021. */
  53022. disableChromaticAberration(): void;
  53023. /**
  53024. * Sets the EdgeDistortion amount
  53025. * @param amount amount of EdgeDistortion
  53026. */
  53027. setEdgeDistortion(amount: number): void;
  53028. /**
  53029. * Sets edge distortion to 0
  53030. */
  53031. disableEdgeDistortion(): void;
  53032. /**
  53033. * Sets the FocusDistance amount
  53034. * @param amount amount of FocusDistance
  53035. */
  53036. setFocusDistance(amount: number): void;
  53037. /**
  53038. * Disables depth of field
  53039. */
  53040. disableDepthOfField(): void;
  53041. /**
  53042. * Sets the Aperture amount
  53043. * @param amount amount of Aperture
  53044. */
  53045. setAperture(amount: number): void;
  53046. /**
  53047. * Sets the DarkenOutOfFocus amount
  53048. * @param amount amount of DarkenOutOfFocus
  53049. */
  53050. setDarkenOutOfFocus(amount: number): void;
  53051. private _pentagonBokehIsEnabled;
  53052. /**
  53053. * Creates a pentagon bokeh effect
  53054. */
  53055. enablePentagonBokeh(): void;
  53056. /**
  53057. * Disables the pentagon bokeh effect
  53058. */
  53059. disablePentagonBokeh(): void;
  53060. /**
  53061. * Enables noise blur
  53062. */
  53063. enableNoiseBlur(): void;
  53064. /**
  53065. * Disables noise blur
  53066. */
  53067. disableNoiseBlur(): void;
  53068. /**
  53069. * Sets the HighlightsGain amount
  53070. * @param amount amount of HighlightsGain
  53071. */
  53072. setHighlightsGain(amount: number): void;
  53073. /**
  53074. * Sets the HighlightsThreshold amount
  53075. * @param amount amount of HighlightsThreshold
  53076. */
  53077. setHighlightsThreshold(amount: number): void;
  53078. /**
  53079. * Disables highlights
  53080. */
  53081. disableHighlights(): void;
  53082. /**
  53083. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53084. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53085. */
  53086. dispose(disableDepthRender?: boolean): void;
  53087. private _createChromaticAberrationPostProcess;
  53088. private _createHighlightsPostProcess;
  53089. private _createDepthOfFieldPostProcess;
  53090. private _createGrainTexture;
  53091. }
  53092. }
  53093. declare module BABYLON {
  53094. /** @hidden */
  53095. export var ssao2PixelShader: {
  53096. name: string;
  53097. shader: string;
  53098. };
  53099. }
  53100. declare module BABYLON {
  53101. /** @hidden */
  53102. export var ssaoCombinePixelShader: {
  53103. name: string;
  53104. shader: string;
  53105. };
  53106. }
  53107. declare module BABYLON {
  53108. /**
  53109. * Render pipeline to produce ssao effect
  53110. */
  53111. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53112. /**
  53113. * @ignore
  53114. * The PassPostProcess id in the pipeline that contains the original scene color
  53115. */
  53116. SSAOOriginalSceneColorEffect: string;
  53117. /**
  53118. * @ignore
  53119. * The SSAO PostProcess id in the pipeline
  53120. */
  53121. SSAORenderEffect: string;
  53122. /**
  53123. * @ignore
  53124. * The horizontal blur PostProcess id in the pipeline
  53125. */
  53126. SSAOBlurHRenderEffect: string;
  53127. /**
  53128. * @ignore
  53129. * The vertical blur PostProcess id in the pipeline
  53130. */
  53131. SSAOBlurVRenderEffect: string;
  53132. /**
  53133. * @ignore
  53134. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53135. */
  53136. SSAOCombineRenderEffect: string;
  53137. /**
  53138. * The output strength of the SSAO post-process. Default value is 1.0.
  53139. */
  53140. totalStrength: number;
  53141. /**
  53142. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53143. */
  53144. maxZ: number;
  53145. /**
  53146. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53147. */
  53148. minZAspect: number;
  53149. private _samples;
  53150. /**
  53151. * Number of samples used for the SSAO calculations. Default value is 8
  53152. */
  53153. samples: number;
  53154. private _textureSamples;
  53155. /**
  53156. * Number of samples to use for antialiasing
  53157. */
  53158. textureSamples: number;
  53159. /**
  53160. * Ratio object used for SSAO ratio and blur ratio
  53161. */
  53162. private _ratio;
  53163. /**
  53164. * Dynamically generated sphere sampler.
  53165. */
  53166. private _sampleSphere;
  53167. /**
  53168. * Blur filter offsets
  53169. */
  53170. private _samplerOffsets;
  53171. private _expensiveBlur;
  53172. /**
  53173. * If bilateral blur should be used
  53174. */
  53175. expensiveBlur: boolean;
  53176. /**
  53177. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53178. */
  53179. radius: number;
  53180. /**
  53181. * The base color of the SSAO post-process
  53182. * The final result is "base + ssao" between [0, 1]
  53183. */
  53184. base: number;
  53185. /**
  53186. * Support test.
  53187. */
  53188. static readonly IsSupported: boolean;
  53189. private _scene;
  53190. private _depthTexture;
  53191. private _normalTexture;
  53192. private _randomTexture;
  53193. private _originalColorPostProcess;
  53194. private _ssaoPostProcess;
  53195. private _blurHPostProcess;
  53196. private _blurVPostProcess;
  53197. private _ssaoCombinePostProcess;
  53198. private _firstUpdate;
  53199. /**
  53200. * Gets active scene
  53201. */
  53202. readonly scene: Scene;
  53203. /**
  53204. * @constructor
  53205. * @param name The rendering pipeline name
  53206. * @param scene The scene linked to this pipeline
  53207. * @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 }
  53208. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53209. */
  53210. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53211. /**
  53212. * Get the class name
  53213. * @returns "SSAO2RenderingPipeline"
  53214. */
  53215. getClassName(): string;
  53216. /**
  53217. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53218. */
  53219. dispose(disableGeometryBufferRenderer?: boolean): void;
  53220. private _createBlurPostProcess;
  53221. /** @hidden */
  53222. _rebuild(): void;
  53223. private _bits;
  53224. private _radicalInverse_VdC;
  53225. private _hammersley;
  53226. private _hemisphereSample_uniform;
  53227. private _generateHemisphere;
  53228. private _createSSAOPostProcess;
  53229. private _createSSAOCombinePostProcess;
  53230. private _createRandomTexture;
  53231. /**
  53232. * Serialize the rendering pipeline (Used when exporting)
  53233. * @returns the serialized object
  53234. */
  53235. serialize(): any;
  53236. /**
  53237. * Parse the serialized pipeline
  53238. * @param source Source pipeline.
  53239. * @param scene The scene to load the pipeline to.
  53240. * @param rootUrl The URL of the serialized pipeline.
  53241. * @returns An instantiated pipeline from the serialized object.
  53242. */
  53243. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53244. }
  53245. }
  53246. declare module BABYLON {
  53247. /** @hidden */
  53248. export var ssaoPixelShader: {
  53249. name: string;
  53250. shader: string;
  53251. };
  53252. }
  53253. declare module BABYLON {
  53254. /**
  53255. * Render pipeline to produce ssao effect
  53256. */
  53257. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53258. /**
  53259. * @ignore
  53260. * The PassPostProcess id in the pipeline that contains the original scene color
  53261. */
  53262. SSAOOriginalSceneColorEffect: string;
  53263. /**
  53264. * @ignore
  53265. * The SSAO PostProcess id in the pipeline
  53266. */
  53267. SSAORenderEffect: string;
  53268. /**
  53269. * @ignore
  53270. * The horizontal blur PostProcess id in the pipeline
  53271. */
  53272. SSAOBlurHRenderEffect: string;
  53273. /**
  53274. * @ignore
  53275. * The vertical blur PostProcess id in the pipeline
  53276. */
  53277. SSAOBlurVRenderEffect: string;
  53278. /**
  53279. * @ignore
  53280. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53281. */
  53282. SSAOCombineRenderEffect: string;
  53283. /**
  53284. * The output strength of the SSAO post-process. Default value is 1.0.
  53285. */
  53286. totalStrength: number;
  53287. /**
  53288. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53289. */
  53290. radius: number;
  53291. /**
  53292. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53293. * Must not be equal to fallOff and superior to fallOff.
  53294. * Default value is 0.0075
  53295. */
  53296. area: number;
  53297. /**
  53298. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53299. * Must not be equal to area and inferior to area.
  53300. * Default value is 0.000001
  53301. */
  53302. fallOff: number;
  53303. /**
  53304. * The base color of the SSAO post-process
  53305. * The final result is "base + ssao" between [0, 1]
  53306. */
  53307. base: number;
  53308. private _scene;
  53309. private _depthTexture;
  53310. private _randomTexture;
  53311. private _originalColorPostProcess;
  53312. private _ssaoPostProcess;
  53313. private _blurHPostProcess;
  53314. private _blurVPostProcess;
  53315. private _ssaoCombinePostProcess;
  53316. private _firstUpdate;
  53317. /**
  53318. * Gets active scene
  53319. */
  53320. readonly scene: Scene;
  53321. /**
  53322. * @constructor
  53323. * @param name - The rendering pipeline name
  53324. * @param scene - The scene linked to this pipeline
  53325. * @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 }
  53326. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53327. */
  53328. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53329. /**
  53330. * Get the class name
  53331. * @returns "SSAORenderingPipeline"
  53332. */
  53333. getClassName(): string;
  53334. /**
  53335. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53336. */
  53337. dispose(disableDepthRender?: boolean): void;
  53338. private _createBlurPostProcess;
  53339. /** @hidden */
  53340. _rebuild(): void;
  53341. private _createSSAOPostProcess;
  53342. private _createSSAOCombinePostProcess;
  53343. private _createRandomTexture;
  53344. }
  53345. }
  53346. declare module BABYLON {
  53347. /** @hidden */
  53348. export var standardPixelShader: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module BABYLON {
  53354. /**
  53355. * Standard rendering pipeline
  53356. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53357. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53358. */
  53359. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53360. /**
  53361. * Public members
  53362. */
  53363. /**
  53364. * Post-process which contains the original scene color before the pipeline applies all the effects
  53365. */
  53366. originalPostProcess: Nullable<PostProcess>;
  53367. /**
  53368. * Post-process used to down scale an image x4
  53369. */
  53370. downSampleX4PostProcess: Nullable<PostProcess>;
  53371. /**
  53372. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53373. */
  53374. brightPassPostProcess: Nullable<PostProcess>;
  53375. /**
  53376. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53377. */
  53378. blurHPostProcesses: PostProcess[];
  53379. /**
  53380. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53381. */
  53382. blurVPostProcesses: PostProcess[];
  53383. /**
  53384. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53385. */
  53386. textureAdderPostProcess: Nullable<PostProcess>;
  53387. /**
  53388. * Post-process used to create volumetric lighting effect
  53389. */
  53390. volumetricLightPostProcess: Nullable<PostProcess>;
  53391. /**
  53392. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53393. */
  53394. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53395. /**
  53396. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53397. */
  53398. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53399. /**
  53400. * Post-process used to merge the volumetric light effect and the real scene color
  53401. */
  53402. volumetricLightMergePostProces: Nullable<PostProcess>;
  53403. /**
  53404. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53405. */
  53406. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53407. /**
  53408. * Base post-process used to calculate the average luminance of the final image for HDR
  53409. */
  53410. luminancePostProcess: Nullable<PostProcess>;
  53411. /**
  53412. * Post-processes used to create down sample post-processes in order to get
  53413. * the average luminance of the final image for HDR
  53414. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53415. */
  53416. luminanceDownSamplePostProcesses: PostProcess[];
  53417. /**
  53418. * Post-process used to create a HDR effect (light adaptation)
  53419. */
  53420. hdrPostProcess: Nullable<PostProcess>;
  53421. /**
  53422. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53423. */
  53424. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53425. /**
  53426. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53427. */
  53428. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53429. /**
  53430. * Post-process used to merge the final HDR post-process and the real scene color
  53431. */
  53432. hdrFinalPostProcess: Nullable<PostProcess>;
  53433. /**
  53434. * Post-process used to create a lens flare effect
  53435. */
  53436. lensFlarePostProcess: Nullable<PostProcess>;
  53437. /**
  53438. * Post-process that merges the result of the lens flare post-process and the real scene color
  53439. */
  53440. lensFlareComposePostProcess: Nullable<PostProcess>;
  53441. /**
  53442. * Post-process used to create a motion blur effect
  53443. */
  53444. motionBlurPostProcess: Nullable<PostProcess>;
  53445. /**
  53446. * Post-process used to create a depth of field effect
  53447. */
  53448. depthOfFieldPostProcess: Nullable<PostProcess>;
  53449. /**
  53450. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53451. */
  53452. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53453. /**
  53454. * Represents the brightness threshold in order to configure the illuminated surfaces
  53455. */
  53456. brightThreshold: number;
  53457. /**
  53458. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53459. */
  53460. blurWidth: number;
  53461. /**
  53462. * Sets if the blur for highlighted surfaces must be only horizontal
  53463. */
  53464. horizontalBlur: boolean;
  53465. /**
  53466. * Sets the overall exposure used by the pipeline
  53467. */
  53468. exposure: number;
  53469. /**
  53470. * Texture used typically to simulate "dirty" on camera lens
  53471. */
  53472. lensTexture: Nullable<Texture>;
  53473. /**
  53474. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53475. */
  53476. volumetricLightCoefficient: number;
  53477. /**
  53478. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53479. */
  53480. volumetricLightPower: number;
  53481. /**
  53482. * Used the set the blur intensity to smooth the volumetric lights
  53483. */
  53484. volumetricLightBlurScale: number;
  53485. /**
  53486. * Light (spot or directional) used to generate the volumetric lights rays
  53487. * The source light must have a shadow generate so the pipeline can get its
  53488. * depth map
  53489. */
  53490. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53491. /**
  53492. * For eye adaptation, represents the minimum luminance the eye can see
  53493. */
  53494. hdrMinimumLuminance: number;
  53495. /**
  53496. * For eye adaptation, represents the decrease luminance speed
  53497. */
  53498. hdrDecreaseRate: number;
  53499. /**
  53500. * For eye adaptation, represents the increase luminance speed
  53501. */
  53502. hdrIncreaseRate: number;
  53503. /**
  53504. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53505. */
  53506. lensColorTexture: Nullable<Texture>;
  53507. /**
  53508. * The overall strengh for the lens flare effect
  53509. */
  53510. lensFlareStrength: number;
  53511. /**
  53512. * Dispersion coefficient for lens flare ghosts
  53513. */
  53514. lensFlareGhostDispersal: number;
  53515. /**
  53516. * Main lens flare halo width
  53517. */
  53518. lensFlareHaloWidth: number;
  53519. /**
  53520. * Based on the lens distortion effect, defines how much the lens flare result
  53521. * is distorted
  53522. */
  53523. lensFlareDistortionStrength: number;
  53524. /**
  53525. * Lens star texture must be used to simulate rays on the flares and is available
  53526. * in the documentation
  53527. */
  53528. lensStarTexture: Nullable<Texture>;
  53529. /**
  53530. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53531. * flare effect by taking account of the dirt texture
  53532. */
  53533. lensFlareDirtTexture: Nullable<Texture>;
  53534. /**
  53535. * Represents the focal length for the depth of field effect
  53536. */
  53537. depthOfFieldDistance: number;
  53538. /**
  53539. * Represents the blur intensity for the blurred part of the depth of field effect
  53540. */
  53541. depthOfFieldBlurWidth: number;
  53542. /**
  53543. * For motion blur, defines how much the image is blurred by the movement
  53544. */
  53545. motionStrength: number;
  53546. /**
  53547. * List of animations for the pipeline (IAnimatable implementation)
  53548. */
  53549. animations: Animation[];
  53550. /**
  53551. * Private members
  53552. */
  53553. private _scene;
  53554. private _currentDepthOfFieldSource;
  53555. private _basePostProcess;
  53556. private _hdrCurrentLuminance;
  53557. private _floatTextureType;
  53558. private _ratio;
  53559. private _bloomEnabled;
  53560. private _depthOfFieldEnabled;
  53561. private _vlsEnabled;
  53562. private _lensFlareEnabled;
  53563. private _hdrEnabled;
  53564. private _motionBlurEnabled;
  53565. private _fxaaEnabled;
  53566. private _motionBlurSamples;
  53567. private _volumetricLightStepsCount;
  53568. private _samples;
  53569. /**
  53570. * @ignore
  53571. * Specifies if the bloom pipeline is enabled
  53572. */
  53573. BloomEnabled: boolean;
  53574. /**
  53575. * @ignore
  53576. * Specifies if the depth of field pipeline is enabed
  53577. */
  53578. DepthOfFieldEnabled: boolean;
  53579. /**
  53580. * @ignore
  53581. * Specifies if the lens flare pipeline is enabed
  53582. */
  53583. LensFlareEnabled: boolean;
  53584. /**
  53585. * @ignore
  53586. * Specifies if the HDR pipeline is enabled
  53587. */
  53588. HDREnabled: boolean;
  53589. /**
  53590. * @ignore
  53591. * Specifies if the volumetric lights scattering effect is enabled
  53592. */
  53593. VLSEnabled: boolean;
  53594. /**
  53595. * @ignore
  53596. * Specifies if the motion blur effect is enabled
  53597. */
  53598. MotionBlurEnabled: boolean;
  53599. /**
  53600. * Specifies if anti-aliasing is enabled
  53601. */
  53602. fxaaEnabled: boolean;
  53603. /**
  53604. * Specifies the number of steps used to calculate the volumetric lights
  53605. * Typically in interval [50, 200]
  53606. */
  53607. volumetricLightStepsCount: number;
  53608. /**
  53609. * Specifies the number of samples used for the motion blur effect
  53610. * Typically in interval [16, 64]
  53611. */
  53612. motionBlurSamples: number;
  53613. /**
  53614. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53615. */
  53616. samples: number;
  53617. /**
  53618. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53619. * @constructor
  53620. * @param name The rendering pipeline name
  53621. * @param scene The scene linked to this pipeline
  53622. * @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)
  53623. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53624. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53625. */
  53626. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53627. private _buildPipeline;
  53628. private _createDownSampleX4PostProcess;
  53629. private _createBrightPassPostProcess;
  53630. private _createBlurPostProcesses;
  53631. private _createTextureAdderPostProcess;
  53632. private _createVolumetricLightPostProcess;
  53633. private _createLuminancePostProcesses;
  53634. private _createHdrPostProcess;
  53635. private _createLensFlarePostProcess;
  53636. private _createDepthOfFieldPostProcess;
  53637. private _createMotionBlurPostProcess;
  53638. private _getDepthTexture;
  53639. private _disposePostProcesses;
  53640. /**
  53641. * Dispose of the pipeline and stop all post processes
  53642. */
  53643. dispose(): void;
  53644. /**
  53645. * Serialize the rendering pipeline (Used when exporting)
  53646. * @returns the serialized object
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parse the serialized pipeline
  53651. * @param source Source pipeline.
  53652. * @param scene The scene to load the pipeline to.
  53653. * @param rootUrl The URL of the serialized pipeline.
  53654. * @returns An instantiated pipeline from the serialized object.
  53655. */
  53656. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53657. /**
  53658. * Luminance steps
  53659. */
  53660. static LuminanceSteps: number;
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. /** @hidden */
  53665. export var tonemapPixelShader: {
  53666. name: string;
  53667. shader: string;
  53668. };
  53669. }
  53670. declare module BABYLON {
  53671. /** Defines operator used for tonemapping */
  53672. export enum TonemappingOperator {
  53673. /** Hable */
  53674. Hable = 0,
  53675. /** Reinhard */
  53676. Reinhard = 1,
  53677. /** HejiDawson */
  53678. HejiDawson = 2,
  53679. /** Photographic */
  53680. Photographic = 3
  53681. }
  53682. /**
  53683. * Defines a post process to apply tone mapping
  53684. */
  53685. export class TonemapPostProcess extends PostProcess {
  53686. private _operator;
  53687. /** Defines the required exposure adjustement */
  53688. exposureAdjustment: number;
  53689. /**
  53690. * Creates a new TonemapPostProcess
  53691. * @param name defines the name of the postprocess
  53692. * @param _operator defines the operator to use
  53693. * @param exposureAdjustment defines the required exposure adjustement
  53694. * @param camera defines the camera to use (can be null)
  53695. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53696. * @param engine defines the hosting engine (can be ignore if camera is set)
  53697. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53698. */
  53699. constructor(name: string, _operator: TonemappingOperator,
  53700. /** Defines the required exposure adjustement */
  53701. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53702. }
  53703. }
  53704. declare module BABYLON {
  53705. /** @hidden */
  53706. export var depthVertexShader: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module BABYLON {
  53712. /** @hidden */
  53713. export var volumetricLightScatteringPixelShader: {
  53714. name: string;
  53715. shader: string;
  53716. };
  53717. }
  53718. declare module BABYLON {
  53719. /** @hidden */
  53720. export var volumetricLightScatteringPassPixelShader: {
  53721. name: string;
  53722. shader: string;
  53723. };
  53724. }
  53725. declare module BABYLON {
  53726. /**
  53727. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53728. */
  53729. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53730. private _volumetricLightScatteringPass;
  53731. private _volumetricLightScatteringRTT;
  53732. private _viewPort;
  53733. private _screenCoordinates;
  53734. private _cachedDefines;
  53735. /**
  53736. * If not undefined, the mesh position is computed from the attached node position
  53737. */
  53738. attachedNode: {
  53739. position: Vector3;
  53740. };
  53741. /**
  53742. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53743. */
  53744. customMeshPosition: Vector3;
  53745. /**
  53746. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53747. */
  53748. useCustomMeshPosition: boolean;
  53749. /**
  53750. * If the post-process should inverse the light scattering direction
  53751. */
  53752. invert: boolean;
  53753. /**
  53754. * The internal mesh used by the post-process
  53755. */
  53756. mesh: Mesh;
  53757. /**
  53758. * @hidden
  53759. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53760. */
  53761. useDiffuseColor: boolean;
  53762. /**
  53763. * Array containing the excluded meshes not rendered in the internal pass
  53764. */
  53765. excludedMeshes: AbstractMesh[];
  53766. /**
  53767. * Controls the overall intensity of the post-process
  53768. */
  53769. exposure: number;
  53770. /**
  53771. * Dissipates each sample's contribution in range [0, 1]
  53772. */
  53773. decay: number;
  53774. /**
  53775. * Controls the overall intensity of each sample
  53776. */
  53777. weight: number;
  53778. /**
  53779. * Controls the density of each sample
  53780. */
  53781. density: number;
  53782. /**
  53783. * @constructor
  53784. * @param name The post-process name
  53785. * @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)
  53786. * @param camera The camera that the post-process will be attached to
  53787. * @param mesh The mesh used to create the light scattering
  53788. * @param samples The post-process quality, default 100
  53789. * @param samplingModeThe post-process filtering mode
  53790. * @param engine The babylon engine
  53791. * @param reusable If the post-process is reusable
  53792. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53793. */
  53794. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53795. /**
  53796. * Returns the string "VolumetricLightScatteringPostProcess"
  53797. * @returns "VolumetricLightScatteringPostProcess"
  53798. */
  53799. getClassName(): string;
  53800. private _isReady;
  53801. /**
  53802. * Sets the new light position for light scattering effect
  53803. * @param position The new custom light position
  53804. */
  53805. setCustomMeshPosition(position: Vector3): void;
  53806. /**
  53807. * Returns the light position for light scattering effect
  53808. * @return Vector3 The custom light position
  53809. */
  53810. getCustomMeshPosition(): Vector3;
  53811. /**
  53812. * Disposes the internal assets and detaches the post-process from the camera
  53813. */
  53814. dispose(camera: Camera): void;
  53815. /**
  53816. * Returns the render target texture used by the post-process
  53817. * @return the render target texture used by the post-process
  53818. */
  53819. getPass(): RenderTargetTexture;
  53820. private _meshExcluded;
  53821. private _createPass;
  53822. private _updateMeshScreenCoordinates;
  53823. /**
  53824. * Creates a default mesh for the Volumeric Light Scattering post-process
  53825. * @param name The mesh name
  53826. * @param scene The scene where to create the mesh
  53827. * @return the default mesh
  53828. */
  53829. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53830. }
  53831. }
  53832. declare module BABYLON {
  53833. interface Scene {
  53834. /** @hidden (Backing field) */
  53835. _boundingBoxRenderer: BoundingBoxRenderer;
  53836. /** @hidden (Backing field) */
  53837. _forceShowBoundingBoxes: boolean;
  53838. /**
  53839. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53840. */
  53841. forceShowBoundingBoxes: boolean;
  53842. /**
  53843. * Gets the bounding box renderer associated with the scene
  53844. * @returns a BoundingBoxRenderer
  53845. */
  53846. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53847. }
  53848. interface AbstractMesh {
  53849. /** @hidden (Backing field) */
  53850. _showBoundingBox: boolean;
  53851. /**
  53852. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53853. */
  53854. showBoundingBox: boolean;
  53855. }
  53856. /**
  53857. * Component responsible of rendering the bounding box of the meshes in a scene.
  53858. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53859. */
  53860. export class BoundingBoxRenderer implements ISceneComponent {
  53861. /**
  53862. * The component name helpfull to identify the component in the list of scene components.
  53863. */
  53864. readonly name: string;
  53865. /**
  53866. * The scene the component belongs to.
  53867. */
  53868. scene: Scene;
  53869. /**
  53870. * Color of the bounding box lines placed in front of an object
  53871. */
  53872. frontColor: Color3;
  53873. /**
  53874. * Color of the bounding box lines placed behind an object
  53875. */
  53876. backColor: Color3;
  53877. /**
  53878. * Defines if the renderer should show the back lines or not
  53879. */
  53880. showBackLines: boolean;
  53881. /**
  53882. * @hidden
  53883. */
  53884. renderList: SmartArray<BoundingBox>;
  53885. private _colorShader;
  53886. private _vertexBuffers;
  53887. private _indexBuffer;
  53888. /**
  53889. * Instantiates a new bounding box renderer in a scene.
  53890. * @param scene the scene the renderer renders in
  53891. */
  53892. constructor(scene: Scene);
  53893. /**
  53894. * Registers the component in a given scene
  53895. */
  53896. register(): void;
  53897. private _evaluateSubMesh;
  53898. private _activeMesh;
  53899. private _prepareRessources;
  53900. private _createIndexBuffer;
  53901. /**
  53902. * Rebuilds the elements related to this component in case of
  53903. * context lost for instance.
  53904. */
  53905. rebuild(): void;
  53906. /**
  53907. * @hidden
  53908. */
  53909. reset(): void;
  53910. /**
  53911. * Render the bounding boxes of a specific rendering group
  53912. * @param renderingGroupId defines the rendering group to render
  53913. */
  53914. render(renderingGroupId: number): void;
  53915. /**
  53916. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53917. * @param mesh Define the mesh to render the occlusion bounding box for
  53918. */
  53919. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53920. /**
  53921. * Dispose and release the resources attached to this renderer.
  53922. */
  53923. dispose(): void;
  53924. }
  53925. }
  53926. declare module BABYLON {
  53927. /** @hidden */
  53928. export var depthPixelShader: {
  53929. name: string;
  53930. shader: string;
  53931. };
  53932. }
  53933. declare module BABYLON {
  53934. /**
  53935. * This represents a depth renderer in Babylon.
  53936. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53937. */
  53938. export class DepthRenderer {
  53939. private _scene;
  53940. private _depthMap;
  53941. private _effect;
  53942. private _cachedDefines;
  53943. private _camera;
  53944. /**
  53945. * Specifiess that the depth renderer will only be used within
  53946. * the camera it is created for.
  53947. * This can help forcing its rendering during the camera processing.
  53948. */
  53949. useOnlyInActiveCamera: boolean;
  53950. /** @hidden */
  53951. static _SceneComponentInitialization: (scene: Scene) => void;
  53952. /**
  53953. * Instantiates a depth renderer
  53954. * @param scene The scene the renderer belongs to
  53955. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53956. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53957. */
  53958. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53959. /**
  53960. * Creates the depth rendering effect and checks if the effect is ready.
  53961. * @param subMesh The submesh to be used to render the depth map of
  53962. * @param useInstances If multiple world instances should be used
  53963. * @returns if the depth renderer is ready to render the depth map
  53964. */
  53965. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53966. /**
  53967. * Gets the texture which the depth map will be written to.
  53968. * @returns The depth map texture
  53969. */
  53970. getDepthMap(): RenderTargetTexture;
  53971. /**
  53972. * Disposes of the depth renderer.
  53973. */
  53974. dispose(): void;
  53975. }
  53976. }
  53977. declare module BABYLON {
  53978. interface Scene {
  53979. /** @hidden (Backing field) */
  53980. _depthRenderer: {
  53981. [id: string]: DepthRenderer;
  53982. };
  53983. /**
  53984. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53985. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53986. * @returns the created depth renderer
  53987. */
  53988. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53989. /**
  53990. * Disables a depth renderer for a given camera
  53991. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53992. */
  53993. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53994. }
  53995. /**
  53996. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53997. * in several rendering techniques.
  53998. */
  53999. export class DepthRendererSceneComponent implements ISceneComponent {
  54000. /**
  54001. * The component name helpfull to identify the component in the list of scene components.
  54002. */
  54003. readonly name: string;
  54004. /**
  54005. * The scene the component belongs to.
  54006. */
  54007. scene: Scene;
  54008. /**
  54009. * Creates a new instance of the component for the given scene
  54010. * @param scene Defines the scene to register the component in
  54011. */
  54012. constructor(scene: Scene);
  54013. /**
  54014. * Registers the component in a given scene
  54015. */
  54016. register(): void;
  54017. /**
  54018. * Rebuilds the elements related to this component in case of
  54019. * context lost for instance.
  54020. */
  54021. rebuild(): void;
  54022. /**
  54023. * Disposes the component and the associated ressources
  54024. */
  54025. dispose(): void;
  54026. private _gatherRenderTargets;
  54027. private _gatherActiveCameraRenderTargets;
  54028. }
  54029. }
  54030. declare module BABYLON {
  54031. /** @hidden */
  54032. export var outlinePixelShader: {
  54033. name: string;
  54034. shader: string;
  54035. };
  54036. }
  54037. declare module BABYLON {
  54038. /** @hidden */
  54039. export var outlineVertexShader: {
  54040. name: string;
  54041. shader: string;
  54042. };
  54043. }
  54044. declare module BABYLON {
  54045. interface Scene {
  54046. /** @hidden */
  54047. _outlineRenderer: OutlineRenderer;
  54048. /**
  54049. * Gets the outline renderer associated with the scene
  54050. * @returns a OutlineRenderer
  54051. */
  54052. getOutlineRenderer(): OutlineRenderer;
  54053. }
  54054. interface AbstractMesh {
  54055. /** @hidden (Backing field) */
  54056. _renderOutline: boolean;
  54057. /**
  54058. * Gets or sets a boolean indicating if the outline must be rendered as well
  54059. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54060. */
  54061. renderOutline: boolean;
  54062. /** @hidden (Backing field) */
  54063. _renderOverlay: boolean;
  54064. /**
  54065. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54066. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54067. */
  54068. renderOverlay: boolean;
  54069. }
  54070. /**
  54071. * This class is responsible to draw bothe outline/overlay of meshes.
  54072. * It should not be used directly but through the available method on mesh.
  54073. */
  54074. export class OutlineRenderer implements ISceneComponent {
  54075. /**
  54076. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54077. */
  54078. private static _StencilReference;
  54079. /**
  54080. * The name of the component. Each component must have a unique name.
  54081. */
  54082. name: string;
  54083. /**
  54084. * The scene the component belongs to.
  54085. */
  54086. scene: Scene;
  54087. /**
  54088. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54089. */
  54090. zOffset: number;
  54091. private _engine;
  54092. private _effect;
  54093. private _cachedDefines;
  54094. private _savedDepthWrite;
  54095. /**
  54096. * Instantiates a new outline renderer. (There could be only one per scene).
  54097. * @param scene Defines the scene it belongs to
  54098. */
  54099. constructor(scene: Scene);
  54100. /**
  54101. * Register the component to one instance of a scene.
  54102. */
  54103. register(): void;
  54104. /**
  54105. * Rebuilds the elements related to this component in case of
  54106. * context lost for instance.
  54107. */
  54108. rebuild(): void;
  54109. /**
  54110. * Disposes the component and the associated ressources.
  54111. */
  54112. dispose(): void;
  54113. /**
  54114. * Renders the outline in the canvas.
  54115. * @param subMesh Defines the sumesh to render
  54116. * @param batch Defines the batch of meshes in case of instances
  54117. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54118. */
  54119. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54120. /**
  54121. * Returns whether or not the outline renderer is ready for a given submesh.
  54122. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54123. * @param subMesh Defines the submesh to check readyness for
  54124. * @param useInstances Defines wheter wee are trying to render instances or not
  54125. * @returns true if ready otherwise false
  54126. */
  54127. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54128. private _beforeRenderingMesh;
  54129. private _afterRenderingMesh;
  54130. }
  54131. }
  54132. declare module BABYLON {
  54133. /**
  54134. * Defines the list of states available for a task inside a AssetsManager
  54135. */
  54136. export enum AssetTaskState {
  54137. /**
  54138. * Initialization
  54139. */
  54140. INIT = 0,
  54141. /**
  54142. * Running
  54143. */
  54144. RUNNING = 1,
  54145. /**
  54146. * Done
  54147. */
  54148. DONE = 2,
  54149. /**
  54150. * Error
  54151. */
  54152. ERROR = 3
  54153. }
  54154. /**
  54155. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54156. */
  54157. export abstract class AbstractAssetTask {
  54158. /**
  54159. * Task name
  54160. */ name: string;
  54161. /**
  54162. * Callback called when the task is successful
  54163. */
  54164. onSuccess: (task: any) => void;
  54165. /**
  54166. * Callback called when the task is not successful
  54167. */
  54168. onError: (task: any, message?: string, exception?: any) => void;
  54169. /**
  54170. * Creates a new AssetsManager
  54171. * @param name defines the name of the task
  54172. */
  54173. constructor(
  54174. /**
  54175. * Task name
  54176. */ name: string);
  54177. private _isCompleted;
  54178. private _taskState;
  54179. private _errorObject;
  54180. /**
  54181. * Get if the task is completed
  54182. */
  54183. readonly isCompleted: boolean;
  54184. /**
  54185. * Gets the current state of the task
  54186. */
  54187. readonly taskState: AssetTaskState;
  54188. /**
  54189. * Gets the current error object (if task is in error)
  54190. */
  54191. readonly errorObject: {
  54192. message?: string;
  54193. exception?: any;
  54194. };
  54195. /**
  54196. * Internal only
  54197. * @hidden
  54198. */
  54199. _setErrorObject(message?: string, exception?: any): void;
  54200. /**
  54201. * Execute the current task
  54202. * @param scene defines the scene where you want your assets to be loaded
  54203. * @param onSuccess is a callback called when the task is successfully executed
  54204. * @param onError is a callback called if an error occurs
  54205. */
  54206. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54207. /**
  54208. * Execute the current task
  54209. * @param scene defines the scene where you want your assets to be loaded
  54210. * @param onSuccess is a callback called when the task is successfully executed
  54211. * @param onError is a callback called if an error occurs
  54212. */
  54213. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54214. /**
  54215. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54216. * This can be used with failed tasks that have the reason for failure fixed.
  54217. */
  54218. reset(): void;
  54219. private onErrorCallback;
  54220. private onDoneCallback;
  54221. }
  54222. /**
  54223. * Define the interface used by progress events raised during assets loading
  54224. */
  54225. export interface IAssetsProgressEvent {
  54226. /**
  54227. * Defines the number of remaining tasks to process
  54228. */
  54229. remainingCount: number;
  54230. /**
  54231. * Defines the total number of tasks
  54232. */
  54233. totalCount: number;
  54234. /**
  54235. * Defines the task that was just processed
  54236. */
  54237. task: AbstractAssetTask;
  54238. }
  54239. /**
  54240. * Class used to share progress information about assets loading
  54241. */
  54242. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54243. /**
  54244. * Defines the number of remaining tasks to process
  54245. */
  54246. remainingCount: number;
  54247. /**
  54248. * Defines the total number of tasks
  54249. */
  54250. totalCount: number;
  54251. /**
  54252. * Defines the task that was just processed
  54253. */
  54254. task: AbstractAssetTask;
  54255. /**
  54256. * Creates a AssetsProgressEvent
  54257. * @param remainingCount defines the number of remaining tasks to process
  54258. * @param totalCount defines the total number of tasks
  54259. * @param task defines the task that was just processed
  54260. */
  54261. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54262. }
  54263. /**
  54264. * Define a task used by AssetsManager to load meshes
  54265. */
  54266. export class MeshAssetTask extends AbstractAssetTask {
  54267. /**
  54268. * Defines the name of the task
  54269. */
  54270. name: string;
  54271. /**
  54272. * Defines the list of mesh's names you want to load
  54273. */
  54274. meshesNames: any;
  54275. /**
  54276. * Defines the root url to use as a base to load your meshes and associated resources
  54277. */
  54278. rootUrl: string;
  54279. /**
  54280. * Defines the filename of the scene to load from
  54281. */
  54282. sceneFilename: string;
  54283. /**
  54284. * Gets the list of loaded meshes
  54285. */
  54286. loadedMeshes: Array<AbstractMesh>;
  54287. /**
  54288. * Gets the list of loaded particle systems
  54289. */
  54290. loadedParticleSystems: Array<IParticleSystem>;
  54291. /**
  54292. * Gets the list of loaded skeletons
  54293. */
  54294. loadedSkeletons: Array<Skeleton>;
  54295. /**
  54296. * Gets the list of loaded animation groups
  54297. */
  54298. loadedAnimationGroups: Array<AnimationGroup>;
  54299. /**
  54300. * Callback called when the task is successful
  54301. */
  54302. onSuccess: (task: MeshAssetTask) => void;
  54303. /**
  54304. * Callback called when the task is successful
  54305. */
  54306. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54307. /**
  54308. * Creates a new MeshAssetTask
  54309. * @param name defines the name of the task
  54310. * @param meshesNames defines the list of mesh's names you want to load
  54311. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54312. * @param sceneFilename defines the filename of the scene to load from
  54313. */
  54314. constructor(
  54315. /**
  54316. * Defines the name of the task
  54317. */
  54318. name: string,
  54319. /**
  54320. * Defines the list of mesh's names you want to load
  54321. */
  54322. meshesNames: any,
  54323. /**
  54324. * Defines the root url to use as a base to load your meshes and associated resources
  54325. */
  54326. rootUrl: string,
  54327. /**
  54328. * Defines the filename of the scene to load from
  54329. */
  54330. sceneFilename: string);
  54331. /**
  54332. * Execute the current task
  54333. * @param scene defines the scene where you want your assets to be loaded
  54334. * @param onSuccess is a callback called when the task is successfully executed
  54335. * @param onError is a callback called if an error occurs
  54336. */
  54337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54338. }
  54339. /**
  54340. * Define a task used by AssetsManager to load text content
  54341. */
  54342. export class TextFileAssetTask extends AbstractAssetTask {
  54343. /**
  54344. * Defines the name of the task
  54345. */
  54346. name: string;
  54347. /**
  54348. * Defines the location of the file to load
  54349. */
  54350. url: string;
  54351. /**
  54352. * Gets the loaded text string
  54353. */
  54354. text: string;
  54355. /**
  54356. * Callback called when the task is successful
  54357. */
  54358. onSuccess: (task: TextFileAssetTask) => void;
  54359. /**
  54360. * Callback called when the task is successful
  54361. */
  54362. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54363. /**
  54364. * Creates a new TextFileAssetTask object
  54365. * @param name defines the name of the task
  54366. * @param url defines the location of the file to load
  54367. */
  54368. constructor(
  54369. /**
  54370. * Defines the name of the task
  54371. */
  54372. name: string,
  54373. /**
  54374. * Defines the location of the file to load
  54375. */
  54376. url: string);
  54377. /**
  54378. * Execute the current task
  54379. * @param scene defines the scene where you want your assets to be loaded
  54380. * @param onSuccess is a callback called when the task is successfully executed
  54381. * @param onError is a callback called if an error occurs
  54382. */
  54383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54384. }
  54385. /**
  54386. * Define a task used by AssetsManager to load binary data
  54387. */
  54388. export class BinaryFileAssetTask extends AbstractAssetTask {
  54389. /**
  54390. * Defines the name of the task
  54391. */
  54392. name: string;
  54393. /**
  54394. * Defines the location of the file to load
  54395. */
  54396. url: string;
  54397. /**
  54398. * Gets the lodaded data (as an array buffer)
  54399. */
  54400. data: ArrayBuffer;
  54401. /**
  54402. * Callback called when the task is successful
  54403. */
  54404. onSuccess: (task: BinaryFileAssetTask) => void;
  54405. /**
  54406. * Callback called when the task is successful
  54407. */
  54408. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54409. /**
  54410. * Creates a new BinaryFileAssetTask object
  54411. * @param name defines the name of the new task
  54412. * @param url defines the location of the file to load
  54413. */
  54414. constructor(
  54415. /**
  54416. * Defines the name of the task
  54417. */
  54418. name: string,
  54419. /**
  54420. * Defines the location of the file to load
  54421. */
  54422. url: string);
  54423. /**
  54424. * Execute the current task
  54425. * @param scene defines the scene where you want your assets to be loaded
  54426. * @param onSuccess is a callback called when the task is successfully executed
  54427. * @param onError is a callback called if an error occurs
  54428. */
  54429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54430. }
  54431. /**
  54432. * Define a task used by AssetsManager to load images
  54433. */
  54434. export class ImageAssetTask extends AbstractAssetTask {
  54435. /**
  54436. * Defines the name of the task
  54437. */
  54438. name: string;
  54439. /**
  54440. * Defines the location of the image to load
  54441. */
  54442. url: string;
  54443. /**
  54444. * Gets the loaded images
  54445. */
  54446. image: HTMLImageElement;
  54447. /**
  54448. * Callback called when the task is successful
  54449. */
  54450. onSuccess: (task: ImageAssetTask) => void;
  54451. /**
  54452. * Callback called when the task is successful
  54453. */
  54454. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54455. /**
  54456. * Creates a new ImageAssetTask
  54457. * @param name defines the name of the task
  54458. * @param url defines the location of the image to load
  54459. */
  54460. constructor(
  54461. /**
  54462. * Defines the name of the task
  54463. */
  54464. name: string,
  54465. /**
  54466. * Defines the location of the image to load
  54467. */
  54468. url: string);
  54469. /**
  54470. * Execute the current task
  54471. * @param scene defines the scene where you want your assets to be loaded
  54472. * @param onSuccess is a callback called when the task is successfully executed
  54473. * @param onError is a callback called if an error occurs
  54474. */
  54475. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54476. }
  54477. /**
  54478. * Defines the interface used by texture loading tasks
  54479. */
  54480. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54481. /**
  54482. * Gets the loaded texture
  54483. */
  54484. texture: TEX;
  54485. }
  54486. /**
  54487. * Define a task used by AssetsManager to load 2D textures
  54488. */
  54489. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54490. /**
  54491. * Defines the name of the task
  54492. */
  54493. name: string;
  54494. /**
  54495. * Defines the location of the file to load
  54496. */
  54497. url: string;
  54498. /**
  54499. * Defines if mipmap should not be generated (default is false)
  54500. */
  54501. noMipmap?: boolean | undefined;
  54502. /**
  54503. * Defines if texture must be inverted on Y axis (default is false)
  54504. */
  54505. invertY?: boolean | undefined;
  54506. /**
  54507. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54508. */
  54509. samplingMode: number;
  54510. /**
  54511. * Gets the loaded texture
  54512. */
  54513. texture: Texture;
  54514. /**
  54515. * Callback called when the task is successful
  54516. */
  54517. onSuccess: (task: TextureAssetTask) => void;
  54518. /**
  54519. * Callback called when the task is successful
  54520. */
  54521. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54522. /**
  54523. * Creates a new TextureAssetTask object
  54524. * @param name defines the name of the task
  54525. * @param url defines the location of the file to load
  54526. * @param noMipmap defines if mipmap should not be generated (default is false)
  54527. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54528. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54529. */
  54530. constructor(
  54531. /**
  54532. * Defines the name of the task
  54533. */
  54534. name: string,
  54535. /**
  54536. * Defines the location of the file to load
  54537. */
  54538. url: string,
  54539. /**
  54540. * Defines if mipmap should not be generated (default is false)
  54541. */
  54542. noMipmap?: boolean | undefined,
  54543. /**
  54544. * Defines if texture must be inverted on Y axis (default is false)
  54545. */
  54546. invertY?: boolean | undefined,
  54547. /**
  54548. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54549. */
  54550. samplingMode?: number);
  54551. /**
  54552. * Execute the current task
  54553. * @param scene defines the scene where you want your assets to be loaded
  54554. * @param onSuccess is a callback called when the task is successfully executed
  54555. * @param onError is a callback called if an error occurs
  54556. */
  54557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54558. }
  54559. /**
  54560. * Define a task used by AssetsManager to load cube textures
  54561. */
  54562. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54563. /**
  54564. * Defines the name of the task
  54565. */
  54566. name: string;
  54567. /**
  54568. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54569. */
  54570. url: string;
  54571. /**
  54572. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54573. */
  54574. extensions?: string[] | undefined;
  54575. /**
  54576. * Defines if mipmaps should not be generated (default is false)
  54577. */
  54578. noMipmap?: boolean | undefined;
  54579. /**
  54580. * Defines the explicit list of files (undefined by default)
  54581. */
  54582. files?: string[] | undefined;
  54583. /**
  54584. * Gets the loaded texture
  54585. */
  54586. texture: CubeTexture;
  54587. /**
  54588. * Callback called when the task is successful
  54589. */
  54590. onSuccess: (task: CubeTextureAssetTask) => void;
  54591. /**
  54592. * Callback called when the task is successful
  54593. */
  54594. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54595. /**
  54596. * Creates a new CubeTextureAssetTask
  54597. * @param name defines the name of the task
  54598. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54599. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54600. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54601. * @param files defines the explicit list of files (undefined by default)
  54602. */
  54603. constructor(
  54604. /**
  54605. * Defines the name of the task
  54606. */
  54607. name: string,
  54608. /**
  54609. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54610. */
  54611. url: string,
  54612. /**
  54613. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54614. */
  54615. extensions?: string[] | undefined,
  54616. /**
  54617. * Defines if mipmaps should not be generated (default is false)
  54618. */
  54619. noMipmap?: boolean | undefined,
  54620. /**
  54621. * Defines the explicit list of files (undefined by default)
  54622. */
  54623. files?: string[] | undefined);
  54624. /**
  54625. * Execute the current task
  54626. * @param scene defines the scene where you want your assets to be loaded
  54627. * @param onSuccess is a callback called when the task is successfully executed
  54628. * @param onError is a callback called if an error occurs
  54629. */
  54630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54631. }
  54632. /**
  54633. * Define a task used by AssetsManager to load HDR cube textures
  54634. */
  54635. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54636. /**
  54637. * Defines the name of the task
  54638. */
  54639. name: string;
  54640. /**
  54641. * Defines the location of the file to load
  54642. */
  54643. url: string;
  54644. /**
  54645. * Defines the desired size (the more it increases the longer the generation will be)
  54646. */
  54647. size: number;
  54648. /**
  54649. * Defines if mipmaps should not be generated (default is false)
  54650. */
  54651. noMipmap: boolean;
  54652. /**
  54653. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54654. */
  54655. generateHarmonics: boolean;
  54656. /**
  54657. * 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)
  54658. */
  54659. gammaSpace: boolean;
  54660. /**
  54661. * Internal Use Only
  54662. */
  54663. reserved: boolean;
  54664. /**
  54665. * Gets the loaded texture
  54666. */
  54667. texture: HDRCubeTexture;
  54668. /**
  54669. * Callback called when the task is successful
  54670. */
  54671. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54672. /**
  54673. * Callback called when the task is successful
  54674. */
  54675. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54676. /**
  54677. * Creates a new HDRCubeTextureAssetTask object
  54678. * @param name defines the name of the task
  54679. * @param url defines the location of the file to load
  54680. * @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.
  54681. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54682. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54683. * @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)
  54684. * @param reserved Internal use only
  54685. */
  54686. constructor(
  54687. /**
  54688. * Defines the name of the task
  54689. */
  54690. name: string,
  54691. /**
  54692. * Defines the location of the file to load
  54693. */
  54694. url: string,
  54695. /**
  54696. * Defines the desired size (the more it increases the longer the generation will be)
  54697. */
  54698. size: number,
  54699. /**
  54700. * Defines if mipmaps should not be generated (default is false)
  54701. */
  54702. noMipmap?: boolean,
  54703. /**
  54704. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54705. */
  54706. generateHarmonics?: boolean,
  54707. /**
  54708. * 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)
  54709. */
  54710. gammaSpace?: boolean,
  54711. /**
  54712. * Internal Use Only
  54713. */
  54714. reserved?: boolean);
  54715. /**
  54716. * Execute the current task
  54717. * @param scene defines the scene where you want your assets to be loaded
  54718. * @param onSuccess is a callback called when the task is successfully executed
  54719. * @param onError is a callback called if an error occurs
  54720. */
  54721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54722. }
  54723. /**
  54724. * This class can be used to easily import assets into a scene
  54725. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54726. */
  54727. export class AssetsManager {
  54728. private _scene;
  54729. private _isLoading;
  54730. protected _tasks: AbstractAssetTask[];
  54731. protected _waitingTasksCount: number;
  54732. protected _totalTasksCount: number;
  54733. /**
  54734. * Callback called when all tasks are processed
  54735. */
  54736. onFinish: (tasks: AbstractAssetTask[]) => void;
  54737. /**
  54738. * Callback called when a task is successful
  54739. */
  54740. onTaskSuccess: (task: AbstractAssetTask) => void;
  54741. /**
  54742. * Callback called when a task had an error
  54743. */
  54744. onTaskError: (task: AbstractAssetTask) => void;
  54745. /**
  54746. * Callback called when a task is done (whatever the result is)
  54747. */
  54748. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54749. /**
  54750. * Observable called when all tasks are processed
  54751. */
  54752. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54753. /**
  54754. * Observable called when a task had an error
  54755. */
  54756. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54757. /**
  54758. * Observable called when all tasks were executed
  54759. */
  54760. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54761. /**
  54762. * Observable called when a task is done (whatever the result is)
  54763. */
  54764. onProgressObservable: Observable<IAssetsProgressEvent>;
  54765. /**
  54766. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54767. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54768. */
  54769. useDefaultLoadingScreen: boolean;
  54770. /**
  54771. * Creates a new AssetsManager
  54772. * @param scene defines the scene to work on
  54773. */
  54774. constructor(scene: Scene);
  54775. /**
  54776. * Add a MeshAssetTask to the list of active tasks
  54777. * @param taskName defines the name of the new task
  54778. * @param meshesNames defines the name of meshes to load
  54779. * @param rootUrl defines the root url to use to locate files
  54780. * @param sceneFilename defines the filename of the scene file
  54781. * @returns a new MeshAssetTask object
  54782. */
  54783. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54784. /**
  54785. * Add a TextFileAssetTask to the list of active tasks
  54786. * @param taskName defines the name of the new task
  54787. * @param url defines the url of the file to load
  54788. * @returns a new TextFileAssetTask object
  54789. */
  54790. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54791. /**
  54792. * Add a BinaryFileAssetTask to the list of active tasks
  54793. * @param taskName defines the name of the new task
  54794. * @param url defines the url of the file to load
  54795. * @returns a new BinaryFileAssetTask object
  54796. */
  54797. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54798. /**
  54799. * Add a ImageAssetTask to the list of active tasks
  54800. * @param taskName defines the name of the new task
  54801. * @param url defines the url of the file to load
  54802. * @returns a new ImageAssetTask object
  54803. */
  54804. addImageTask(taskName: string, url: string): ImageAssetTask;
  54805. /**
  54806. * Add a TextureAssetTask to the list of active tasks
  54807. * @param taskName defines the name of the new task
  54808. * @param url defines the url of the file to load
  54809. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54810. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54811. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54812. * @returns a new TextureAssetTask object
  54813. */
  54814. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54815. /**
  54816. * Add a CubeTextureAssetTask to the list of active tasks
  54817. * @param taskName defines the name of the new task
  54818. * @param url defines the url of the file to load
  54819. * @param extensions defines the extension to use to load the cube map (can be null)
  54820. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54821. * @param files defines the list of files to load (can be null)
  54822. * @returns a new CubeTextureAssetTask object
  54823. */
  54824. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54825. /**
  54826. *
  54827. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54828. * @param taskName defines the name of the new task
  54829. * @param url defines the url of the file to load
  54830. * @param size defines the size you want for the cubemap (can be null)
  54831. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54832. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54833. * @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)
  54834. * @param reserved Internal use only
  54835. * @returns a new HDRCubeTextureAssetTask object
  54836. */
  54837. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54838. /**
  54839. * Remove a task from the assets manager.
  54840. * @param task the task to remove
  54841. */
  54842. removeTask(task: AbstractAssetTask): void;
  54843. private _decreaseWaitingTasksCount;
  54844. private _runTask;
  54845. /**
  54846. * Reset the AssetsManager and remove all tasks
  54847. * @return the current instance of the AssetsManager
  54848. */
  54849. reset(): AssetsManager;
  54850. /**
  54851. * Start the loading process
  54852. * @return the current instance of the AssetsManager
  54853. */
  54854. load(): AssetsManager;
  54855. /**
  54856. * Start the loading process as an async operation
  54857. * @return a promise returning the list of failed tasks
  54858. */
  54859. loadAsync(): Promise<void>;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /**
  54864. * Wrapper class for promise with external resolve and reject.
  54865. */
  54866. export class Deferred<T> {
  54867. /**
  54868. * The promise associated with this deferred object.
  54869. */
  54870. readonly promise: Promise<T>;
  54871. private _resolve;
  54872. private _reject;
  54873. /**
  54874. * The resolve method of the promise associated with this deferred object.
  54875. */
  54876. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54877. /**
  54878. * The reject method of the promise associated with this deferred object.
  54879. */
  54880. readonly reject: (reason?: any) => void;
  54881. /**
  54882. * Constructor for this deferred object.
  54883. */
  54884. constructor();
  54885. }
  54886. }
  54887. declare module BABYLON {
  54888. /**
  54889. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54890. */
  54891. export class MeshExploder {
  54892. private _centerMesh;
  54893. private _meshes;
  54894. private _meshesOrigins;
  54895. private _toCenterVectors;
  54896. private _scaledDirection;
  54897. private _newPosition;
  54898. private _centerPosition;
  54899. /**
  54900. * Explodes meshes from a center mesh.
  54901. * @param meshes The meshes to explode.
  54902. * @param centerMesh The mesh to be center of explosion.
  54903. */
  54904. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54905. private _setCenterMesh;
  54906. /**
  54907. * Get class name
  54908. * @returns "MeshExploder"
  54909. */
  54910. getClassName(): string;
  54911. /**
  54912. * "Exploded meshes"
  54913. * @returns Array of meshes with the centerMesh at index 0.
  54914. */
  54915. getMeshes(): Array<Mesh>;
  54916. /**
  54917. * Explodes meshes giving a specific direction
  54918. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54919. */
  54920. explode(direction?: number): void;
  54921. }
  54922. }
  54923. declare module BABYLON {
  54924. /**
  54925. * Class used to help managing file picking and drag'n'drop
  54926. */
  54927. export class FilesInput {
  54928. /**
  54929. * List of files ready to be loaded
  54930. */
  54931. static readonly FilesToLoad: {
  54932. [key: string]: File;
  54933. };
  54934. /**
  54935. * Callback called when a file is processed
  54936. */
  54937. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54938. private _engine;
  54939. private _currentScene;
  54940. private _sceneLoadedCallback;
  54941. private _progressCallback;
  54942. private _additionalRenderLoopLogicCallback;
  54943. private _textureLoadingCallback;
  54944. private _startingProcessingFilesCallback;
  54945. private _onReloadCallback;
  54946. private _errorCallback;
  54947. private _elementToMonitor;
  54948. private _sceneFileToLoad;
  54949. private _filesToLoad;
  54950. /**
  54951. * Creates a new FilesInput
  54952. * @param engine defines the rendering engine
  54953. * @param scene defines the hosting scene
  54954. * @param sceneLoadedCallback callback called when scene is loaded
  54955. * @param progressCallback callback called to track progress
  54956. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54957. * @param textureLoadingCallback callback called when a texture is loading
  54958. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54959. * @param onReloadCallback callback called when a reload is requested
  54960. * @param errorCallback callback call if an error occurs
  54961. */
  54962. 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);
  54963. private _dragEnterHandler;
  54964. private _dragOverHandler;
  54965. private _dropHandler;
  54966. /**
  54967. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54968. * @param elementToMonitor defines the DOM element to track
  54969. */
  54970. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54971. /**
  54972. * Release all associated resources
  54973. */
  54974. dispose(): void;
  54975. private renderFunction;
  54976. private drag;
  54977. private drop;
  54978. private _traverseFolder;
  54979. private _processFiles;
  54980. /**
  54981. * Load files from a drop event
  54982. * @param event defines the drop event to use as source
  54983. */
  54984. loadFiles(event: any): void;
  54985. private _processReload;
  54986. /**
  54987. * Reload the current scene from the loaded files
  54988. */
  54989. reload(): void;
  54990. }
  54991. }
  54992. declare module BABYLON {
  54993. /**
  54994. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54995. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54996. */
  54997. export class SceneOptimization {
  54998. /**
  54999. * Defines the priority of this optimization (0 by default which means first in the list)
  55000. */
  55001. priority: number;
  55002. /**
  55003. * Gets a string describing the action executed by the current optimization
  55004. * @returns description string
  55005. */
  55006. getDescription(): string;
  55007. /**
  55008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55009. * @param scene defines the current scene where to apply this optimization
  55010. * @param optimizer defines the current optimizer
  55011. * @returns true if everything that can be done was applied
  55012. */
  55013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55014. /**
  55015. * Creates the SceneOptimization object
  55016. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55017. * @param desc defines the description associated with the optimization
  55018. */
  55019. constructor(
  55020. /**
  55021. * Defines the priority of this optimization (0 by default which means first in the list)
  55022. */
  55023. priority?: number);
  55024. }
  55025. /**
  55026. * Defines an optimization used to reduce the size of render target textures
  55027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55028. */
  55029. export class TextureOptimization extends SceneOptimization {
  55030. /**
  55031. * Defines the priority of this optimization (0 by default which means first in the list)
  55032. */
  55033. priority: number;
  55034. /**
  55035. * 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
  55036. */
  55037. maximumSize: number;
  55038. /**
  55039. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55040. */
  55041. step: number;
  55042. /**
  55043. * Gets a string describing the action executed by the current optimization
  55044. * @returns description string
  55045. */
  55046. getDescription(): string;
  55047. /**
  55048. * Creates the TextureOptimization object
  55049. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55050. * @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
  55051. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55052. */
  55053. constructor(
  55054. /**
  55055. * Defines the priority of this optimization (0 by default which means first in the list)
  55056. */
  55057. priority?: number,
  55058. /**
  55059. * 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
  55060. */
  55061. maximumSize?: number,
  55062. /**
  55063. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55064. */
  55065. step?: number);
  55066. /**
  55067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55068. * @param scene defines the current scene where to apply this optimization
  55069. * @param optimizer defines the current optimizer
  55070. * @returns true if everything that can be done was applied
  55071. */
  55072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55073. }
  55074. /**
  55075. * Defines an optimization used to increase or decrease the rendering resolution
  55076. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55077. */
  55078. export class HardwareScalingOptimization extends SceneOptimization {
  55079. /**
  55080. * Defines the priority of this optimization (0 by default which means first in the list)
  55081. */
  55082. priority: number;
  55083. /**
  55084. * Defines the maximum scale to use (2 by default)
  55085. */
  55086. maximumScale: number;
  55087. /**
  55088. * Defines the step to use between two passes (0.5 by default)
  55089. */
  55090. step: number;
  55091. private _currentScale;
  55092. private _directionOffset;
  55093. /**
  55094. * Gets a string describing the action executed by the current optimization
  55095. * @return description string
  55096. */
  55097. getDescription(): string;
  55098. /**
  55099. * Creates the HardwareScalingOptimization object
  55100. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55101. * @param maximumScale defines the maximum scale to use (2 by default)
  55102. * @param step defines the step to use between two passes (0.5 by default)
  55103. */
  55104. constructor(
  55105. /**
  55106. * Defines the priority of this optimization (0 by default which means first in the list)
  55107. */
  55108. priority?: number,
  55109. /**
  55110. * Defines the maximum scale to use (2 by default)
  55111. */
  55112. maximumScale?: number,
  55113. /**
  55114. * Defines the step to use between two passes (0.5 by default)
  55115. */
  55116. step?: number);
  55117. /**
  55118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55119. * @param scene defines the current scene where to apply this optimization
  55120. * @param optimizer defines the current optimizer
  55121. * @returns true if everything that can be done was applied
  55122. */
  55123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55124. }
  55125. /**
  55126. * Defines an optimization used to remove shadows
  55127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55128. */
  55129. export class ShadowsOptimization extends SceneOptimization {
  55130. /**
  55131. * Gets a string describing the action executed by the current optimization
  55132. * @return description string
  55133. */
  55134. getDescription(): string;
  55135. /**
  55136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55137. * @param scene defines the current scene where to apply this optimization
  55138. * @param optimizer defines the current optimizer
  55139. * @returns true if everything that can be done was applied
  55140. */
  55141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55142. }
  55143. /**
  55144. * Defines an optimization used to turn post-processes off
  55145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55146. */
  55147. export class PostProcessesOptimization extends SceneOptimization {
  55148. /**
  55149. * Gets a string describing the action executed by the current optimization
  55150. * @return description string
  55151. */
  55152. getDescription(): string;
  55153. /**
  55154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55155. * @param scene defines the current scene where to apply this optimization
  55156. * @param optimizer defines the current optimizer
  55157. * @returns true if everything that can be done was applied
  55158. */
  55159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55160. }
  55161. /**
  55162. * Defines an optimization used to turn lens flares off
  55163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55164. */
  55165. export class LensFlaresOptimization extends SceneOptimization {
  55166. /**
  55167. * Gets a string describing the action executed by the current optimization
  55168. * @return description string
  55169. */
  55170. getDescription(): string;
  55171. /**
  55172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55173. * @param scene defines the current scene where to apply this optimization
  55174. * @param optimizer defines the current optimizer
  55175. * @returns true if everything that can be done was applied
  55176. */
  55177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55178. }
  55179. /**
  55180. * Defines an optimization based on user defined callback.
  55181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55182. */
  55183. export class CustomOptimization extends SceneOptimization {
  55184. /**
  55185. * Callback called to apply the custom optimization.
  55186. */
  55187. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55188. /**
  55189. * Callback called to get custom description
  55190. */
  55191. onGetDescription: () => string;
  55192. /**
  55193. * Gets a string describing the action executed by the current optimization
  55194. * @returns description string
  55195. */
  55196. getDescription(): string;
  55197. /**
  55198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55199. * @param scene defines the current scene where to apply this optimization
  55200. * @param optimizer defines the current optimizer
  55201. * @returns true if everything that can be done was applied
  55202. */
  55203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55204. }
  55205. /**
  55206. * Defines an optimization used to turn particles off
  55207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55208. */
  55209. export class ParticlesOptimization extends SceneOptimization {
  55210. /**
  55211. * Gets a string describing the action executed by the current optimization
  55212. * @return description string
  55213. */
  55214. getDescription(): string;
  55215. /**
  55216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55217. * @param scene defines the current scene where to apply this optimization
  55218. * @param optimizer defines the current optimizer
  55219. * @returns true if everything that can be done was applied
  55220. */
  55221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55222. }
  55223. /**
  55224. * Defines an optimization used to turn render targets off
  55225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55226. */
  55227. export class RenderTargetsOptimization extends SceneOptimization {
  55228. /**
  55229. * Gets a string describing the action executed by the current optimization
  55230. * @return description string
  55231. */
  55232. getDescription(): string;
  55233. /**
  55234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55235. * @param scene defines the current scene where to apply this optimization
  55236. * @param optimizer defines the current optimizer
  55237. * @returns true if everything that can be done was applied
  55238. */
  55239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55240. }
  55241. /**
  55242. * Defines an optimization used to merge meshes with compatible materials
  55243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55244. */
  55245. export class MergeMeshesOptimization extends SceneOptimization {
  55246. private static _UpdateSelectionTree;
  55247. /**
  55248. * Gets or sets a boolean which defines if optimization octree has to be updated
  55249. */
  55250. /**
  55251. * Gets or sets a boolean which defines if optimization octree has to be updated
  55252. */
  55253. static UpdateSelectionTree: boolean;
  55254. /**
  55255. * Gets a string describing the action executed by the current optimization
  55256. * @return description string
  55257. */
  55258. getDescription(): string;
  55259. private _canBeMerged;
  55260. /**
  55261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55262. * @param scene defines the current scene where to apply this optimization
  55263. * @param optimizer defines the current optimizer
  55264. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55265. * @returns true if everything that can be done was applied
  55266. */
  55267. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55268. }
  55269. /**
  55270. * Defines a list of options used by SceneOptimizer
  55271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55272. */
  55273. export class SceneOptimizerOptions {
  55274. /**
  55275. * Defines the target frame rate to reach (60 by default)
  55276. */
  55277. targetFrameRate: number;
  55278. /**
  55279. * Defines the interval between two checkes (2000ms by default)
  55280. */
  55281. trackerDuration: number;
  55282. /**
  55283. * Gets the list of optimizations to apply
  55284. */
  55285. optimizations: SceneOptimization[];
  55286. /**
  55287. * Creates a new list of options used by SceneOptimizer
  55288. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55289. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55290. */
  55291. constructor(
  55292. /**
  55293. * Defines the target frame rate to reach (60 by default)
  55294. */
  55295. targetFrameRate?: number,
  55296. /**
  55297. * Defines the interval between two checkes (2000ms by default)
  55298. */
  55299. trackerDuration?: number);
  55300. /**
  55301. * Add a new optimization
  55302. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55303. * @returns the current SceneOptimizerOptions
  55304. */
  55305. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55306. /**
  55307. * Add a new custom optimization
  55308. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55309. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55310. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55311. * @returns the current SceneOptimizerOptions
  55312. */
  55313. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55314. /**
  55315. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55316. * @param targetFrameRate defines the target frame rate (60 by default)
  55317. * @returns a SceneOptimizerOptions object
  55318. */
  55319. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55320. /**
  55321. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55322. * @param targetFrameRate defines the target frame rate (60 by default)
  55323. * @returns a SceneOptimizerOptions object
  55324. */
  55325. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55326. /**
  55327. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55328. * @param targetFrameRate defines the target frame rate (60 by default)
  55329. * @returns a SceneOptimizerOptions object
  55330. */
  55331. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55332. }
  55333. /**
  55334. * Class used to run optimizations in order to reach a target frame rate
  55335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55336. */
  55337. export class SceneOptimizer implements IDisposable {
  55338. private _isRunning;
  55339. private _options;
  55340. private _scene;
  55341. private _currentPriorityLevel;
  55342. private _targetFrameRate;
  55343. private _trackerDuration;
  55344. private _currentFrameRate;
  55345. private _sceneDisposeObserver;
  55346. private _improvementMode;
  55347. /**
  55348. * Defines an observable called when the optimizer reaches the target frame rate
  55349. */
  55350. onSuccessObservable: Observable<SceneOptimizer>;
  55351. /**
  55352. * Defines an observable called when the optimizer enables an optimization
  55353. */
  55354. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55355. /**
  55356. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55357. */
  55358. onFailureObservable: Observable<SceneOptimizer>;
  55359. /**
  55360. * Gets a boolean indicating if the optimizer is in improvement mode
  55361. */
  55362. readonly isInImprovementMode: boolean;
  55363. /**
  55364. * Gets the current priority level (0 at start)
  55365. */
  55366. readonly currentPriorityLevel: number;
  55367. /**
  55368. * Gets the current frame rate checked by the SceneOptimizer
  55369. */
  55370. readonly currentFrameRate: number;
  55371. /**
  55372. * Gets or sets the current target frame rate (60 by default)
  55373. */
  55374. /**
  55375. * Gets or sets the current target frame rate (60 by default)
  55376. */
  55377. targetFrameRate: number;
  55378. /**
  55379. * Gets or sets the current interval between two checks (every 2000ms by default)
  55380. */
  55381. /**
  55382. * Gets or sets the current interval between two checks (every 2000ms by default)
  55383. */
  55384. trackerDuration: number;
  55385. /**
  55386. * Gets the list of active optimizations
  55387. */
  55388. readonly optimizations: SceneOptimization[];
  55389. /**
  55390. * Creates a new SceneOptimizer
  55391. * @param scene defines the scene to work on
  55392. * @param options defines the options to use with the SceneOptimizer
  55393. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55394. * @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)
  55395. */
  55396. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55397. /**
  55398. * Stops the current optimizer
  55399. */
  55400. stop(): void;
  55401. /**
  55402. * Reset the optimizer to initial step (current priority level = 0)
  55403. */
  55404. reset(): void;
  55405. /**
  55406. * Start the optimizer. By default it will try to reach a specific framerate
  55407. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55408. */
  55409. start(): void;
  55410. private _checkCurrentState;
  55411. /**
  55412. * Release all resources
  55413. */
  55414. dispose(): void;
  55415. /**
  55416. * Helper function to create a SceneOptimizer with one single line of code
  55417. * @param scene defines the scene to work on
  55418. * @param options defines the options to use with the SceneOptimizer
  55419. * @param onSuccess defines a callback to call on success
  55420. * @param onFailure defines a callback to call on failure
  55421. * @returns the new SceneOptimizer object
  55422. */
  55423. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Class used to serialize a scene into a string
  55429. */
  55430. export class SceneSerializer {
  55431. /**
  55432. * Clear cache used by a previous serialization
  55433. */
  55434. static ClearCache(): void;
  55435. /**
  55436. * Serialize a scene into a JSON compatible object
  55437. * @param scene defines the scene to serialize
  55438. * @returns a JSON compatible object
  55439. */
  55440. static Serialize(scene: Scene): any;
  55441. /**
  55442. * Serialize a mesh into a JSON compatible object
  55443. * @param toSerialize defines the mesh to serialize
  55444. * @param withParents defines if parents must be serialized as well
  55445. * @param withChildren defines if children must be serialized as well
  55446. * @returns a JSON compatible object
  55447. */
  55448. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55449. }
  55450. }
  55451. declare module BABYLON {
  55452. /**
  55453. * Class used to host texture specific utilities
  55454. */
  55455. export class TextureTools {
  55456. /**
  55457. * Uses the GPU to create a copy texture rescaled at a given size
  55458. * @param texture Texture to copy from
  55459. * @param width defines the desired width
  55460. * @param height defines the desired height
  55461. * @param useBilinearMode defines if bilinear mode has to be used
  55462. * @return the generated texture
  55463. */
  55464. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55465. }
  55466. }
  55467. declare module BABYLON {
  55468. /**
  55469. * This represents the different options avilable for the video capture.
  55470. */
  55471. export interface VideoRecorderOptions {
  55472. /** Defines the mime type of the video */
  55473. mimeType: string;
  55474. /** Defines the video the video should be recorded at */
  55475. fps: number;
  55476. /** Defines the chunk size for the recording data */
  55477. recordChunckSize: number;
  55478. /** The audio tracks to attach to the record */
  55479. audioTracks?: MediaStreamTrack[];
  55480. }
  55481. /**
  55482. * This can helps recording videos from BabylonJS.
  55483. * This is based on the available WebRTC functionalities of the browser.
  55484. *
  55485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55486. */
  55487. export class VideoRecorder {
  55488. private static readonly _defaultOptions;
  55489. /**
  55490. * Returns wehther or not the VideoRecorder is available in your browser.
  55491. * @param engine Defines the Babylon Engine to check the support for
  55492. * @returns true if supported otherwise false
  55493. */
  55494. static IsSupported(engine: Engine): boolean;
  55495. private readonly _options;
  55496. private _canvas;
  55497. private _mediaRecorder;
  55498. private _recordedChunks;
  55499. private _fileName;
  55500. private _resolve;
  55501. private _reject;
  55502. /**
  55503. * True wether a recording is already in progress.
  55504. */
  55505. readonly isRecording: boolean;
  55506. /**
  55507. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55508. * a video file.
  55509. * @param engine Defines the BabylonJS Engine you wish to record
  55510. * @param options Defines options that can be used to customized the capture
  55511. */
  55512. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55513. /**
  55514. * Stops the current recording before the default capture timeout passed in the startRecording
  55515. * functions.
  55516. */
  55517. stopRecording(): void;
  55518. /**
  55519. * Starts recording the canvas for a max duration specified in parameters.
  55520. * @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.
  55521. * @param maxDuration Defines the maximum recording time in seconds.
  55522. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55523. * @return a promise callback at the end of the recording with the video data in Blob.
  55524. */
  55525. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55526. /**
  55527. * Releases internal resources used during the recording.
  55528. */
  55529. dispose(): void;
  55530. private _handleDataAvailable;
  55531. private _handleError;
  55532. private _handleStop;
  55533. }
  55534. }
  55535. declare module BABYLON {
  55536. /**
  55537. * Helper class to push actions to a pool of workers.
  55538. */
  55539. export class WorkerPool implements IDisposable {
  55540. private _workerInfos;
  55541. private _pendingActions;
  55542. /**
  55543. * Constructor
  55544. * @param workers Array of workers to use for actions
  55545. */
  55546. constructor(workers: Array<Worker>);
  55547. /**
  55548. * Terminates all workers and clears any pending actions.
  55549. */
  55550. dispose(): void;
  55551. /**
  55552. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55553. * pended until a worker has completed its action.
  55554. * @param action The action to perform. Call onComplete when the action is complete.
  55555. */
  55556. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55557. private _execute;
  55558. }
  55559. }
  55560. declare module BABYLON {
  55561. /**
  55562. * Class containing a set of static utilities functions for screenshots
  55563. */
  55564. export class ScreenshotTools {
  55565. /**
  55566. * Captures a screenshot of the current rendering
  55567. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55568. * @param engine defines the rendering engine
  55569. * @param camera defines the source camera
  55570. * @param size This parameter can be set to a single number or to an object with the
  55571. * following (optional) properties: precision, width, height. If a single number is passed,
  55572. * it will be used for both width and height. If an object is passed, the screenshot size
  55573. * will be derived from the parameters. The precision property is a multiplier allowing
  55574. * rendering at a higher or lower resolution
  55575. * @param successCallback defines the callback receives a single parameter which contains the
  55576. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55577. * src parameter of an <img> to display it
  55578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55579. * Check your browser for supported MIME types
  55580. */
  55581. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55582. /**
  55583. * Generates an image screenshot from the specified camera.
  55584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55585. * @param engine The engine to use for rendering
  55586. * @param camera The camera to use for rendering
  55587. * @param size This parameter can be set to a single number or to an object with the
  55588. * following (optional) properties: precision, width, height. If a single number is passed,
  55589. * it will be used for both width and height. If an object is passed, the screenshot size
  55590. * will be derived from the parameters. The precision property is a multiplier allowing
  55591. * rendering at a higher or lower resolution
  55592. * @param successCallback The callback receives a single parameter which contains the
  55593. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55594. * src parameter of an <img> to display it
  55595. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55596. * Check your browser for supported MIME types
  55597. * @param samples Texture samples (default: 1)
  55598. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55599. * @param fileName A name for for the downloaded file.
  55600. */
  55601. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55602. }
  55603. }
  55604. declare module BABYLON {
  55605. /**
  55606. * A cursor which tracks a point on a path
  55607. */
  55608. export class PathCursor {
  55609. private path;
  55610. /**
  55611. * Stores path cursor callbacks for when an onchange event is triggered
  55612. */
  55613. private _onchange;
  55614. /**
  55615. * The value of the path cursor
  55616. */
  55617. value: number;
  55618. /**
  55619. * The animation array of the path cursor
  55620. */
  55621. animations: Animation[];
  55622. /**
  55623. * Initializes the path cursor
  55624. * @param path The path to track
  55625. */
  55626. constructor(path: Path2);
  55627. /**
  55628. * Gets the cursor point on the path
  55629. * @returns A point on the path cursor at the cursor location
  55630. */
  55631. getPoint(): Vector3;
  55632. /**
  55633. * Moves the cursor ahead by the step amount
  55634. * @param step The amount to move the cursor forward
  55635. * @returns This path cursor
  55636. */
  55637. moveAhead(step?: number): PathCursor;
  55638. /**
  55639. * Moves the cursor behind by the step amount
  55640. * @param step The amount to move the cursor back
  55641. * @returns This path cursor
  55642. */
  55643. moveBack(step?: number): PathCursor;
  55644. /**
  55645. * Moves the cursor by the step amount
  55646. * If the step amount is greater than one, an exception is thrown
  55647. * @param step The amount to move the cursor
  55648. * @returns This path cursor
  55649. */
  55650. move(step: number): PathCursor;
  55651. /**
  55652. * Ensures that the value is limited between zero and one
  55653. * @returns This path cursor
  55654. */
  55655. private ensureLimits;
  55656. /**
  55657. * Runs onchange callbacks on change (used by the animation engine)
  55658. * @returns This path cursor
  55659. */
  55660. private raiseOnChange;
  55661. /**
  55662. * Executes a function on change
  55663. * @param f A path cursor onchange callback
  55664. * @returns This path cursor
  55665. */
  55666. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55667. }
  55668. }
  55669. declare module BABYLON {
  55670. /** @hidden */
  55671. export var blurPixelShader: {
  55672. name: string;
  55673. shader: string;
  55674. };
  55675. }
  55676. declare module BABYLON {
  55677. /** @hidden */
  55678. export var bones300Declaration: {
  55679. name: string;
  55680. shader: string;
  55681. };
  55682. }
  55683. declare module BABYLON {
  55684. /** @hidden */
  55685. export var instances300Declaration: {
  55686. name: string;
  55687. shader: string;
  55688. };
  55689. }
  55690. declare module BABYLON {
  55691. /** @hidden */
  55692. export var pointCloudVertexDeclaration: {
  55693. name: string;
  55694. shader: string;
  55695. };
  55696. }
  55697. // Mixins
  55698. interface Window {
  55699. mozIndexedDB: IDBFactory;
  55700. webkitIndexedDB: IDBFactory;
  55701. msIndexedDB: IDBFactory;
  55702. webkitURL: typeof URL;
  55703. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55704. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55705. WebGLRenderingContext: WebGLRenderingContext;
  55706. MSGesture: MSGesture;
  55707. CANNON: any;
  55708. AudioContext: AudioContext;
  55709. webkitAudioContext: AudioContext;
  55710. PointerEvent: any;
  55711. Math: Math;
  55712. Uint8Array: Uint8ArrayConstructor;
  55713. Float32Array: Float32ArrayConstructor;
  55714. mozURL: typeof URL;
  55715. msURL: typeof URL;
  55716. VRFrameData: any; // WebVR, from specs 1.1
  55717. DracoDecoderModule: any;
  55718. setImmediate(handler: (...args: any[]) => void): number;
  55719. }
  55720. interface HTMLCanvasElement {
  55721. requestPointerLock(): void;
  55722. msRequestPointerLock?(): void;
  55723. mozRequestPointerLock?(): void;
  55724. webkitRequestPointerLock?(): void;
  55725. /** Track wether a record is in progress */
  55726. isRecording: boolean;
  55727. /** Capture Stream method defined by some browsers */
  55728. captureStream(fps?: number): MediaStream;
  55729. }
  55730. interface CanvasRenderingContext2D {
  55731. msImageSmoothingEnabled: boolean;
  55732. }
  55733. interface MouseEvent {
  55734. mozMovementX: number;
  55735. mozMovementY: number;
  55736. webkitMovementX: number;
  55737. webkitMovementY: number;
  55738. msMovementX: number;
  55739. msMovementY: number;
  55740. }
  55741. interface Navigator {
  55742. mozGetVRDevices: (any: any) => any;
  55743. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55744. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55745. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55746. webkitGetGamepads(): Gamepad[];
  55747. msGetGamepads(): Gamepad[];
  55748. webkitGamepads(): Gamepad[];
  55749. }
  55750. interface HTMLVideoElement {
  55751. mozSrcObject: any;
  55752. }
  55753. interface Math {
  55754. fround(x: number): number;
  55755. imul(a: number, b: number): number;
  55756. }
  55757. interface WebGLProgram {
  55758. context?: WebGLRenderingContext;
  55759. vertexShader?: WebGLShader;
  55760. fragmentShader?: WebGLShader;
  55761. isParallelCompiled: boolean;
  55762. onCompiled?: () => void;
  55763. }
  55764. interface WebGLRenderingContext {
  55765. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55766. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55767. vertexAttribDivisor(index: number, divisor: number): void;
  55768. createVertexArray(): any;
  55769. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55770. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55771. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55772. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55773. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55774. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55775. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55776. // Queries
  55777. createQuery(): WebGLQuery;
  55778. deleteQuery(query: WebGLQuery): void;
  55779. beginQuery(target: number, query: WebGLQuery): void;
  55780. endQuery(target: number): void;
  55781. getQueryParameter(query: WebGLQuery, pname: number): any;
  55782. getQuery(target: number, pname: number): any;
  55783. MAX_SAMPLES: number;
  55784. RGBA8: number;
  55785. READ_FRAMEBUFFER: number;
  55786. DRAW_FRAMEBUFFER: number;
  55787. UNIFORM_BUFFER: number;
  55788. HALF_FLOAT_OES: number;
  55789. RGBA16F: number;
  55790. RGBA32F: number;
  55791. R32F: number;
  55792. RG32F: number;
  55793. RGB32F: number;
  55794. R16F: number;
  55795. RG16F: number;
  55796. RGB16F: number;
  55797. RED: number;
  55798. RG: number;
  55799. R8: number;
  55800. RG8: number;
  55801. UNSIGNED_INT_24_8: number;
  55802. DEPTH24_STENCIL8: number;
  55803. /* Multiple Render Targets */
  55804. drawBuffers(buffers: number[]): void;
  55805. readBuffer(src: number): void;
  55806. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55807. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55808. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55809. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55810. // Occlusion Query
  55811. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55812. ANY_SAMPLES_PASSED: number;
  55813. QUERY_RESULT_AVAILABLE: number;
  55814. QUERY_RESULT: number;
  55815. }
  55816. interface WebGLBuffer {
  55817. references: number;
  55818. capacity: number;
  55819. is32Bits: boolean;
  55820. }
  55821. interface WebGLProgram {
  55822. transformFeedback?: WebGLTransformFeedback | null;
  55823. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55824. }
  55825. interface EXT_disjoint_timer_query {
  55826. QUERY_COUNTER_BITS_EXT: number;
  55827. TIME_ELAPSED_EXT: number;
  55828. TIMESTAMP_EXT: number;
  55829. GPU_DISJOINT_EXT: number;
  55830. QUERY_RESULT_EXT: number;
  55831. QUERY_RESULT_AVAILABLE_EXT: number;
  55832. queryCounterEXT(query: WebGLQuery, target: number): void;
  55833. createQueryEXT(): WebGLQuery;
  55834. beginQueryEXT(target: number, query: WebGLQuery): void;
  55835. endQueryEXT(target: number): void;
  55836. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55837. deleteQueryEXT(query: WebGLQuery): void;
  55838. }
  55839. interface WebGLUniformLocation {
  55840. _currentState: any;
  55841. }
  55842. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55843. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55844. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55845. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55846. interface WebGLRenderingContext {
  55847. readonly RASTERIZER_DISCARD: number;
  55848. readonly DEPTH_COMPONENT24: number;
  55849. readonly TEXTURE_3D: number;
  55850. readonly TEXTURE_2D_ARRAY: number;
  55851. readonly TEXTURE_COMPARE_FUNC: number;
  55852. readonly TEXTURE_COMPARE_MODE: number;
  55853. readonly COMPARE_REF_TO_TEXTURE: number;
  55854. readonly TEXTURE_WRAP_R: number;
  55855. readonly HALF_FLOAT: number;
  55856. readonly RGB8: number;
  55857. readonly RED_INTEGER: number;
  55858. readonly RG_INTEGER: number;
  55859. readonly RGB_INTEGER: number;
  55860. readonly RGBA_INTEGER: number;
  55861. readonly R8_SNORM: number;
  55862. readonly RG8_SNORM: number;
  55863. readonly RGB8_SNORM: number;
  55864. readonly RGBA8_SNORM: number;
  55865. readonly R8I: number;
  55866. readonly RG8I: number;
  55867. readonly RGB8I: number;
  55868. readonly RGBA8I: number;
  55869. readonly R8UI: number;
  55870. readonly RG8UI: number;
  55871. readonly RGB8UI: number;
  55872. readonly RGBA8UI: number;
  55873. readonly R16I: number;
  55874. readonly RG16I: number;
  55875. readonly RGB16I: number;
  55876. readonly RGBA16I: number;
  55877. readonly R16UI: number;
  55878. readonly RG16UI: number;
  55879. readonly RGB16UI: number;
  55880. readonly RGBA16UI: number;
  55881. readonly R32I: number;
  55882. readonly RG32I: number;
  55883. readonly RGB32I: number;
  55884. readonly RGBA32I: number;
  55885. readonly R32UI: number;
  55886. readonly RG32UI: number;
  55887. readonly RGB32UI: number;
  55888. readonly RGBA32UI: number;
  55889. readonly RGB10_A2UI: number;
  55890. readonly R11F_G11F_B10F: number;
  55891. readonly RGB9_E5: number;
  55892. readonly RGB10_A2: number;
  55893. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55894. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55895. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55896. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55897. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55898. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55899. 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;
  55900. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55901. readonly TRANSFORM_FEEDBACK: number;
  55902. readonly INTERLEAVED_ATTRIBS: number;
  55903. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55904. createTransformFeedback(): WebGLTransformFeedback;
  55905. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55906. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55907. beginTransformFeedback(primitiveMode: number): void;
  55908. endTransformFeedback(): void;
  55909. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55910. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55911. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55912. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55913. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55914. }
  55915. interface ImageBitmap {
  55916. readonly width: number;
  55917. readonly height: number;
  55918. close(): void;
  55919. }
  55920. interface WebGLQuery extends WebGLObject {
  55921. }
  55922. declare var WebGLQuery: {
  55923. prototype: WebGLQuery;
  55924. new(): WebGLQuery;
  55925. };
  55926. interface WebGLSampler extends WebGLObject {
  55927. }
  55928. declare var WebGLSampler: {
  55929. prototype: WebGLSampler;
  55930. new(): WebGLSampler;
  55931. };
  55932. interface WebGLSync extends WebGLObject {
  55933. }
  55934. declare var WebGLSync: {
  55935. prototype: WebGLSync;
  55936. new(): WebGLSync;
  55937. };
  55938. interface WebGLTransformFeedback extends WebGLObject {
  55939. }
  55940. declare var WebGLTransformFeedback: {
  55941. prototype: WebGLTransformFeedback;
  55942. new(): WebGLTransformFeedback;
  55943. };
  55944. interface WebGLVertexArrayObject extends WebGLObject {
  55945. }
  55946. declare var WebGLVertexArrayObject: {
  55947. prototype: WebGLVertexArrayObject;
  55948. new(): WebGLVertexArrayObject;
  55949. };
  55950. // Type definitions for WebVR API
  55951. // Project: https://w3c.github.io/webvr/
  55952. // Definitions by: six a <https://github.com/lostfictions>
  55953. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55954. interface VRDisplay extends EventTarget {
  55955. /**
  55956. * Dictionary of capabilities describing the VRDisplay.
  55957. */
  55958. readonly capabilities: VRDisplayCapabilities;
  55959. /**
  55960. * z-depth defining the far plane of the eye view frustum
  55961. * enables mapping of values in the render target depth
  55962. * attachment to scene coordinates. Initially set to 10000.0.
  55963. */
  55964. depthFar: number;
  55965. /**
  55966. * z-depth defining the near plane of the eye view frustum
  55967. * enables mapping of values in the render target depth
  55968. * attachment to scene coordinates. Initially set to 0.01.
  55969. */
  55970. depthNear: number;
  55971. /**
  55972. * An identifier for this distinct VRDisplay. Used as an
  55973. * association point in the Gamepad API.
  55974. */
  55975. readonly displayId: number;
  55976. /**
  55977. * A display name, a user-readable name identifying it.
  55978. */
  55979. readonly displayName: string;
  55980. readonly isConnected: boolean;
  55981. readonly isPresenting: boolean;
  55982. /**
  55983. * If this VRDisplay supports room-scale experiences, the optional
  55984. * stage attribute contains details on the room-scale parameters.
  55985. */
  55986. readonly stageParameters: VRStageParameters | null;
  55987. /**
  55988. * Passing the value returned by `requestAnimationFrame` to
  55989. * `cancelAnimationFrame` will unregister the callback.
  55990. * @param handle Define the hanle of the request to cancel
  55991. */
  55992. cancelAnimationFrame(handle: number): void;
  55993. /**
  55994. * Stops presenting to the VRDisplay.
  55995. * @returns a promise to know when it stopped
  55996. */
  55997. exitPresent(): Promise<void>;
  55998. /**
  55999. * Return the current VREyeParameters for the given eye.
  56000. * @param whichEye Define the eye we want the parameter for
  56001. * @returns the eye parameters
  56002. */
  56003. getEyeParameters(whichEye: string): VREyeParameters;
  56004. /**
  56005. * Populates the passed VRFrameData with the information required to render
  56006. * the current frame.
  56007. * @param frameData Define the data structure to populate
  56008. * @returns true if ok otherwise false
  56009. */
  56010. getFrameData(frameData: VRFrameData): boolean;
  56011. /**
  56012. * Get the layers currently being presented.
  56013. * @returns the list of VR layers
  56014. */
  56015. getLayers(): VRLayer[];
  56016. /**
  56017. * Return a VRPose containing the future predicted pose of the VRDisplay
  56018. * when the current frame will be presented. The value returned will not
  56019. * change until JavaScript has returned control to the browser.
  56020. *
  56021. * The VRPose will contain the position, orientation, velocity,
  56022. * and acceleration of each of these properties.
  56023. * @returns the pose object
  56024. */
  56025. getPose(): VRPose;
  56026. /**
  56027. * Return the current instantaneous pose of the VRDisplay, with no
  56028. * prediction applied.
  56029. * @returns the current instantaneous pose
  56030. */
  56031. getImmediatePose(): VRPose;
  56032. /**
  56033. * The callback passed to `requestAnimationFrame` will be called
  56034. * any time a new frame should be rendered. When the VRDisplay is
  56035. * presenting the callback will be called at the native refresh
  56036. * rate of the HMD. When not presenting this function acts
  56037. * identically to how window.requestAnimationFrame acts. Content should
  56038. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56039. * asynchronously from other displays and at differing refresh rates.
  56040. * @param callback Define the eaction to run next frame
  56041. * @returns the request handle it
  56042. */
  56043. requestAnimationFrame(callback: FrameRequestCallback): number;
  56044. /**
  56045. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56046. * Repeat calls while already presenting will update the VRLayers being displayed.
  56047. * @param layers Define the list of layer to present
  56048. * @returns a promise to know when the request has been fulfilled
  56049. */
  56050. requestPresent(layers: VRLayer[]): Promise<void>;
  56051. /**
  56052. * Reset the pose for this display, treating its current position and
  56053. * orientation as the "origin/zero" values. VRPose.position,
  56054. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56055. * updated when calling resetPose(). This should be called in only
  56056. * sitting-space experiences.
  56057. */
  56058. resetPose(): void;
  56059. /**
  56060. * The VRLayer provided to the VRDisplay will be captured and presented
  56061. * in the HMD. Calling this function has the same effect on the source
  56062. * canvas as any other operation that uses its source image, and canvases
  56063. * created without preserveDrawingBuffer set to true will be cleared.
  56064. * @param pose Define the pose to submit
  56065. */
  56066. submitFrame(pose?: VRPose): void;
  56067. }
  56068. declare var VRDisplay: {
  56069. prototype: VRDisplay;
  56070. new(): VRDisplay;
  56071. };
  56072. interface VRLayer {
  56073. leftBounds?: number[] | Float32Array | null;
  56074. rightBounds?: number[] | Float32Array | null;
  56075. source?: HTMLCanvasElement | null;
  56076. }
  56077. interface VRDisplayCapabilities {
  56078. readonly canPresent: boolean;
  56079. readonly hasExternalDisplay: boolean;
  56080. readonly hasOrientation: boolean;
  56081. readonly hasPosition: boolean;
  56082. readonly maxLayers: number;
  56083. }
  56084. interface VREyeParameters {
  56085. /** @deprecated */
  56086. readonly fieldOfView: VRFieldOfView;
  56087. readonly offset: Float32Array;
  56088. readonly renderHeight: number;
  56089. readonly renderWidth: number;
  56090. }
  56091. interface VRFieldOfView {
  56092. readonly downDegrees: number;
  56093. readonly leftDegrees: number;
  56094. readonly rightDegrees: number;
  56095. readonly upDegrees: number;
  56096. }
  56097. interface VRFrameData {
  56098. readonly leftProjectionMatrix: Float32Array;
  56099. readonly leftViewMatrix: Float32Array;
  56100. readonly pose: VRPose;
  56101. readonly rightProjectionMatrix: Float32Array;
  56102. readonly rightViewMatrix: Float32Array;
  56103. readonly timestamp: number;
  56104. }
  56105. interface VRPose {
  56106. readonly angularAcceleration: Float32Array | null;
  56107. readonly angularVelocity: Float32Array | null;
  56108. readonly linearAcceleration: Float32Array | null;
  56109. readonly linearVelocity: Float32Array | null;
  56110. readonly orientation: Float32Array | null;
  56111. readonly position: Float32Array | null;
  56112. readonly timestamp: number;
  56113. }
  56114. interface VRStageParameters {
  56115. sittingToStandingTransform?: Float32Array;
  56116. sizeX?: number;
  56117. sizeY?: number;
  56118. }
  56119. interface Navigator {
  56120. getVRDisplays(): Promise<VRDisplay[]>;
  56121. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56122. }
  56123. interface Window {
  56124. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56125. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56126. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56127. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56128. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56129. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56130. }
  56131. interface Gamepad {
  56132. readonly displayId: number;
  56133. }
  56134. interface XRDevice {
  56135. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56136. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56137. }
  56138. interface XRSession {
  56139. getInputSources(): Array<any>;
  56140. baseLayer: XRWebGLLayer;
  56141. requestFrameOfReference(type: string): Promise<void>;
  56142. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56143. end(): Promise<void>;
  56144. requestAnimationFrame: Function;
  56145. addEventListener: Function;
  56146. }
  56147. interface XRSessionCreationOptions {
  56148. outputContext?: WebGLRenderingContext | null;
  56149. immersive?: boolean;
  56150. environmentIntegration?: boolean;
  56151. }
  56152. interface XRLayer {
  56153. getViewport: Function;
  56154. framebufferWidth: number;
  56155. framebufferHeight: number;
  56156. }
  56157. interface XRView {
  56158. projectionMatrix: Float32Array;
  56159. }
  56160. interface XRFrame {
  56161. getDevicePose: Function;
  56162. getInputPose: Function;
  56163. views: Array<XRView>;
  56164. baseLayer: XRLayer;
  56165. }
  56166. interface XRFrameOfReference {
  56167. }
  56168. interface XRWebGLLayer extends XRLayer {
  56169. framebuffer: WebGLFramebuffer;
  56170. }
  56171. declare var XRWebGLLayer: {
  56172. prototype: XRWebGLLayer;
  56173. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56174. };